public function register(Application $app)
 {
     $this->app = $app;
     $app['file'] = function ($app) {
         return new FileProvider($app);
     };
     $app->extend('migrator', function ($migrator, $app) {
         $migrator->setLoader(new FilesystemLoader($app['locator']));
         return $migrator;
     });
     $app->extend('view', function ($view, $app) {
         $view->setEngine($app['tmpl']);
         $view->set('app', $app);
         $view->set('url', $app['url']);
         return $view;
     });
     $app['extensions'] = function ($app) {
         $loader = new ExtensionLoader();
         $repository = new ExtensionRepository($app['config']['extension.path'], $loader);
         $installer = new PackageInstaller($repository, $loader);
         return new ExtensionManager($app, $repository, $installer, $app['autoloader'], $app['locator']);
     };
     $app['config']['app.storage'] = ltrim($app['config']['app.storage'] ?: 'storage', '/');
     $app['path.storage'] = $app['config']['locator.paths.storage'] = rtrim($app['path'] . '/' . $app['config']['app.storage'], '/');
     $app['extensions.boot'] = [];
 }
 public function register(Application $app)
 {
     if (!$app['config']['profiler.enabled']) {
         return;
     }
     if (!(class_exists('SQLite3') || class_exists('PDO') && in_array('sqlite', \PDO::getAvailableDrivers(), true))) {
         return;
     }
     $app['profiler'] = function ($app) {
         $profiler = new Profiler($app['profiler.storage']);
         if ($app['events'] instanceof TraceableEventDispatcherInterface) {
             $app['events']->setProfiler($profiler);
         }
         return $profiler;
     };
     $app['profiler.storage'] = function ($app) {
         return new SqliteProfilerStorage('sqlite:' . $app['config']['profiler.file'], '', '', 86400);
     };
     $app['profiler.stopwatch'] = function () {
         return new Stopwatch();
     };
     $app->extend('events', function ($dispatcher, $app) {
         return new TraceableEventDispatcher($dispatcher, $app['profiler.stopwatch']);
     });
 }
 protected function getApplication()
 {
     $this->request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
     $app = new Application();
     $app['session'] = new Session(new MockArraySessionStorage());
     $app['request'] = $this->request;
     $app->boot();
     return $app;
 }
 public function boot(Application $app)
 {
     $app->on('kernel.response', function (FilterResponseEvent $event) use($app) {
         if (isset($app['cookie.init'])) {
             foreach ($app['cookie']->getQueuedCookies() as $cookie) {
                 $event->getResponse()->headers->setCookie($cookie);
             }
         }
     });
 }
 public function register(Application $app)
 {
     $debug = isset($app['config']) ? $app['config']['app.debug'] : true;
     $handler = ExceptionHandler::register($debug);
     ErrorHandler::register(E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_RECOVERABLE_ERROR);
     if ($cli = $app->runningInConsole() or $debug) {
         ini_set('display_errors', 1);
     }
     $app['exception'] = $handler;
 }
 public function boot(Application $app)
 {
     $app->on('kernel.terminate', function () use($app) {
         if ($app['mailer.initialized']) {
             try {
                 $app['swift.spooltransport']->getSpool()->flushQueue($app['swift.transport']);
             } catch (\Exception $e) {
             }
         }
     });
 }
 public function register(Application $app)
 {
     $this->app = $app;
     $app['file'] = function ($app) {
         return new FileProvider($app);
     };
     $app->extend('view', function ($view, $app) {
         $view->setEngine($app['tmpl']);
         $view->set('app', $app);
         $view->set('url', $app['url']);
         return $view;
     });
     $app['extensions'] = function ($app) {
         $loader = new ExtensionLoader();
         $repository = new ExtensionRepository($app['config']['extension.path'], $loader);
         $installer = new PackageInstaller($repository, $loader);
         return new ExtensionManager($app, $repository, $installer, $app['autoloader'], $app['locator']);
     };
     $app['extensions.boot'] = [];
 }
Ejemplo n.º 8
0
 /**
  * {@inheritdoc}
  */
 public function boot(Application $app)
 {
     $this->registerLanguages($app['translator']);
     $this->registerResources($app['locator']);
     if ($this->getConfig('parameters.settings')) {
         if (is_array($defaults = $this->getConfig('parameters.settings.defaults'))) {
             $this->parameters = array_replace($this->parameters, $defaults);
         }
         if (is_array($settings = $this['option']->get("{$this->name}:settings"))) {
             $this->parameters = array_replace($this->parameters, $settings);
         }
     }
     $app->on('system.site', function () use($app) {
         $this->registerRenderer($app['view.sections'], $app['view']);
     });
     $app->on('system.positions', function ($event) {
         foreach ($this->getConfig('positions', []) as $id => $position) {
             list($name, $description) = array_merge((array) $position, ['']);
             $event->register($id, $name, $description);
         }
     });
 }
Ejemplo n.º 9
0
<?php

use Pagekit\Framework\Application;
$loader = (require __DIR__ . '/autoload.php');
$config = (require __DIR__ . '/config.php');
$app = new Application($config);
$app['autoloader'] = $loader;
$app['autoloader']->addPsr4('Pagekit\\', $app['path.extensions'] . '/system/src');
date_default_timezone_set($app['config']['app.timezone']);
foreach ($app['config']['app.providers'] as $provider) {
    $app->register($provider);
}
try {
    class InstallerException extends RuntimeException
    {
    }
    if (!$app['config.file']) {
        throw new InstallerException('No config.');
    }
    $app['db']->connect();
    if (!$app['cache']->fetch('installed')) {
        if (!$app['db']->getSchemaManager()->tablesExist($app['db']->getPrefix() . 'system_option')) {
            throw new InstallerException('Not installed.');
        }
        $app['cache']->save('installed', true);
    }
    $app['extensions.boot'] = function ($app) {
        return array_merge($app['config']->get('extension.core', []), $app['option']->get('system:extensions', []));
    };
} catch (InstallerException $e) {
    $requirements = (require __DIR__ . '/requirements.php');