Пример #1
0
 /**
  * Constructor.
  *
  * @param array $values
  */
 public function __construct(array $values = array())
 {
     parent::__construct();
     $this['events'] = function () {
         $events = new EventDispatcher();
         $events->subscribe(new AccessListener());
         $events->subscribe(new ExceptionListener());
         $events->subscribe(new ResponseListener());
         $events->subscribe(new RouterListener());
         return $events;
     };
     $this['plugins'] = function ($app) {
         $manager = new PluginManager($app);
         $manager->addLoader(new EventLoader($app));
         $manager->addPath($app['path.vendor'] . '/yootheme/framework/plugins/*/plugin.php');
         return $manager;
     };
     $this['router'] = function ($app) {
         return new Router($app['controllers']);
     };
     $this['controllers'] = function ($app) {
         return new ControllerCollection($app);
     };
     $this['csrf'] = function () {
         return new DefaultCsrfProvider();
     };
     $this['locator'] = function () {
         return new ResourceLocator();
     };
     $this['config'] = function () {
         return new Config();
     };
     $this['user'] = function ($app) {
         return $app['users']->get();
     };
     $this['filter'] = function () {
         return new FilterManager();
     };
     $this['translator'] = function ($app) {
         $translator = new Translator($app['locator']);
         if (isset($app['locale'])) {
             $translator->setLocale($app['locale']);
         }
         return $translator;
     };
     $values = array_replace(array('app' => $this, 'debug' => false, 'version' => null), $values);
     foreach ($values as $key => $value) {
         $this[$key] = $value;
     }
 }
Пример #2
0
 /**
  * Constructor.
  *
  * @param array $values
  */
 public function __construct(array $values = array())
 {
     parent::__construct();
     $this['events'] = function () {
         $dispatcher = new EventDispatcher();
         $dispatcher->addSubscriber(new AccessListener());
         $dispatcher->addSubscriber(new ExceptionListener());
         $dispatcher->addSubscriber(new ResponseListener());
         $dispatcher->addSubscriber(new RouterListener());
         return $dispatcher;
     };
     $this['plugins'] = function ($app) {
         $manager = new PluginManager();
         $manager->addPath($app['path.framework'] . '/plugins/*/plugin.php');
         return $manager;
     };
     $this['router'] = function ($app) {
         return new Router($app['controllers']);
     };
     $this['controllers'] = function ($app) {
         return new ControllerCollection($app);
     };
     $this['csrf'] = function () {
         return new DefaultCsrfProvider();
     };
     $this['locator'] = function () {
         return new ResourceLocator();
     };
     $this['config'] = function () {
         return new Config();
     };
     $this['user'] = function ($app) {
         return $app['users']->get();
     };
     $values = array_replace(array('app' => $this, 'debug' => false, 'version' => null, 'path.framework' => dirname(__DIR__)), $values);
     foreach ($values as $key => $value) {
         $this[$key] = $value;
     }
 }