PathFinder::init PHP Method

init() public method

public init ( )
    public function init()
    {
        parent::init();
        $this->app->pathfinder = $this;
        $this->addDefaultLocations();
        // Unregister previously defined loader
        if (function_exists('agile_toolkit_temporary_load_class')) {
            spl_autoload_unregister('agile_toolkit_temporary_load_class');
            // collect information about previusly loaded files
            foreach ($GLOBALS['agile_toolkit_temporary_load_class_log'] as $class => $path) {
                $this->info('Loaded class %s from file %s', $class, $path);
            }
        }
        $self = $this;
        // Register preceeding autoload method. We want to get a first shot at
        // loading classes
        spl_autoload_register(function ($class) use($self) {
            try {
                $path = $self->loadClass($class);
                if ($path) {
                    $self->info('Loaded class %s from file %s', $class, $path);
                }
            } catch (Exception $e) {
                // ignore exceptions
            }
        }, true, true);
        if (!$this->report_autoload_errors) {
            return;
        }
        // If we couldn't load the class, let's throw exception
        spl_autoload_register(function ($class) use($self) {
            try {
                $self->loadClass($class);
            } catch (Exception $e) {
                // If due to your PHP version, it says that
                // autoloader may not throw exceptions, then you should
                // add PHP verion check here and skip to next line.
                // PHP 5.5 - throwing seems to work out OK
                throw $e;
                /* unreachable code
                   $self->app->caughtException($e);
                   */
            }
        });
    }