Example #1
0
 /**
  * Unsubscribe a listener.
  *
  * @param ListenerInterface $subscriber
  */
 public static function unsubscribe(ListenerInterface $subscriber)
 {
     static::instantiate();
     static::$instance->removeSubscriber($subscriber);
 }
Example #2
0
 /**
  * @param                  $config
  * @param SilexApplication $app
  * @param                  $events
  * @param Forge            $container
  * @param                  $global_scope
  *
  * @return mixed
  */
 private function registerInstances($config, $app, $events, $container, $global_scope)
 {
     $app['config'] = $config;
     $app['nine.events'] = $events;
     $app['illuminate.container'] = $container;
     $container->instance('illuminate.container', $container);
     $container->instance('illuminate.events', new Dispatcher());
     $container->instance('app', $app);
     $container->add('app', function () use($app) {
         return $app;
     });
     // align the Nine Events object with the Core EventDispatcher (Symfony)
     Events::setEventDispatcher($app['dispatcher']);
     // additional $app registrations. @formatter:off
     $app['app.context'] = 'console';
     $app['container'] = $container;
     $app['global.scope'] = $global_scope;
     $app['app.factory'] = $this;
     $app['paths'] = $container['Paths'];
     //@formatter:on
     return $app;
 }
Example #3
0
 /**
  * @param array $paths
  *
  * @return Application
  */
 private function makeApplication(array $paths) : Application
 {
     // this is the Illuminate Container
     $container = Forge::getInstance();
     // we'll start by loading the configuration into the Forge Container
     $container->add([Scope::class, 'context'], function () {
         return new Scope();
     });
     $container->add('environment', function () use($container) {
         return $container['GlobalScope'];
     });
     $container->singleton([GlobalScope::class, 'GlobalScope'], $global_scope = new GlobalScope($this));
     $container->singleton([Paths::class, 'Paths'], new Paths($paths));
     $container->singleton([Config::class, 'Config'], $config = Config::createFromFolder(\CONFIG));
     $container->singleton([Events::class, 'Events'], $events = Events::getInstance());
     $container->add('paths', function () use($container) {
         return $container['Paths'];
     });
     $container->add('config', function () use($container) {
         return $container['Config'];
     });
     // the reason we are here
     $app = new NineApplication($container, $config, $events, $global_scope);
     // align the Nine Events object with the Core EventDispatcher (Symfony)
     Events::setEventDispatcher($app['dispatcher']);
     $app['app.context'] = 'app';
     // register the new Application
     $container->singleton([NineApplication::class, 'Application'], $app);
     // synchronize the Application instance with the forge.
     Forge::setApplication($app);
     // additional $app registrations. @formatter:off
     $app['container'] = $container;
     $app['global.scope'] = $global_scope;
     $app['app.factory'] = $this;
     $app['flashbag'] = $app->factory(function () use($app) {
         return $app['session']->getFlashBag();
     });
     $app['paths'] = $container['Paths'];
     //@formatter:on
     return $app;
 }