<?php
/**
 * Boot code for TeamBuddy
 */

// General error handling
function exception_error_handler($errno, $errstr, $errfile, $errline ) {
    throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
}
set_error_handler("exception_error_handler");

// Include Francis FW
$dependencies = dirname( __FILE__ ) . '/../../../../../dependencies';
require_once $dependencies . '/Francis/config/boot_francis.php';

// Construct paths
Francis_Utils_Config::set( 'path.root', realpath( dirname( __FILE__ ) . '/../../..' ) );

// Set autoloader
Francis_Core_Autoloader::attachLocator( new Francis_Core_Locator( 'TB', Francis_Utils_Config::get( 'path.root' ) . '/src' ) );

// Setting application version
$version = '0.0';
$versionArr = json_decode( file_get_contents( Francis_Utils_Config::get( 'path.root' ) . '/version.json' ), true );
if ( is_array( $versionArr ) && isset( $versionArr[ 'version' ] ) ) {
    $version = $versionArr[ 'version' ];
}
Francis_Utils_Config::set( 'version', $version );