Bob\Application::__construct PHP Method

__construct() public method

# Public: Initialize the application.
public __construct ( )
    function __construct()
    {
        $app = $this;
        $this['tasks'] = $this->share(function () {
            return new TaskRegistry();
        });
        $this['config.load_path'] = array('./bob_tasks');
        $this['config.file'] = 'bob_config.php';
        $this['default_task_class'] = "\\Bob\\Task";
        $this['task_factory'] = $this->protect(function ($name) use($app) {
            $action = null;
            $prerequisites = null;
            $class = $app['default_task_class'];
            foreach (array_filter(array_slice(func_get_args(), 1)) as $arg) {
                switch (true) {
                    case is_callable($arg):
                        $action = $arg;
                        break;
                    case is_string($arg) and class_exists($arg):
                        $class = $arg;
                        break;
                    case is_array($arg):
                    case $arg instanceof \Traversable:
                    case $arg instanceof \Iterator:
                        $prerequisites = $arg;
                        break;
                }
            }
            if (empty($name)) {
                throw new \InvalidArgumentException('Name cannot be empty');
            }
            if ($app->taskDefined($name)) {
                $task = $app['tasks'][$name];
            } else {
                $task = new $class($name, $app);
                $app->defineTask($task);
            }
            $task->enhance($prerequisites, $action);
            return $task;
        });
        $this['log.verbose'] = false;
        $this['log'] = $this->share(function () use($app) {
            $log = new Logger("bob");
            $stderrHandler = new StreamHandler(STDERR, $app['log.verbose'] ? Logger::DEBUG : Logger::WARNING);
            $stderrHandler->setFormatter(new LineFormatter("%channel%: [%level_name%] %message%" . PHP_EOL));
            $log->pushHandler($stderrHandler);
            return $log;
        });
        $this['invocation_chain'] = $this->share(function () {
            return new TaskInvocationChain();
        });
    }