Beispiel #1
0
 /**
  * @param string $class
  * @param int $priority
  * @return Storage
  */
 public function add($class, $priority = self::PRIORITY_DEFAULT) : Storage
 {
     $this->container->bind($class, $class);
     $instance = $this->container->make($class);
     $this->storage->insert($instance, $priority);
     return $this;
 }
Beispiel #2
0
 /**
  * @param $class
  * @return $this
  */
 public function add($class)
 {
     $this->container->bind($class, $class);
     $subscriber = $this->container->make($class);
     $this->subscribers[] = $subscriber;
     $subscriber->handle();
     return $this;
 }
 /**
  * @param Container $container
  */
 protected function registerContainerBindings(Container $container)
 {
     $entityManager = $container->make('Doctrine\\ORM\\EntityManagerInterface');
     $container->bind('Crisu83\\Overseer\\Storage\\RoleStorage', function () use($entityManager) {
         return new RoleStorage($entityManager);
     });
     $container->bind('Crisu83\\Overseer\\Storage\\PermissionStorage', function () use($entityManager) {
         return new PermissionStorage($entityManager);
     });
     $container->bind('Crisu83\\Overseer\\Storage\\AssignmentStorage', function () use($entityManager) {
         return new AssignmentStorage($entityManager);
     });
 }
 /**
  * Registers container bindings.
  *
  * @param Container        $container
  * @param ConfigRepository $config
  */
 protected function registerBindings(Container $container, ConfigRepository $config)
 {
     $container->bind(OAuth2Service::class, function ($container) use($config) {
         return $this->createService($container, $config[self::CONFIG_KEY]);
     });
     $container->alias(OAuth2Service::class, OAuth2ServiceContract::class);
 }
 /**
  * Register the bindings.
  *
  * @param \Illuminate\Contracts\Container\Container $app
  *
  * @return void
  */
 protected function registerBindings(Application $app)
 {
     $app->bind('telegram.bot', function ($app) {
         $manager = $app['telegram'];
         return $manager->bot();
     });
     $app->alias('telegram.bot', Api::class);
 }
Beispiel #6
0
 /**
  * Bind the given security context to the Request and Container.
  *
  * @param string  $context
  * @param Request $request
  */
 public function bindContext($context, Request $request)
 {
     $security = $this->getSecurity($context);
     $this->container->instance(SecurityApi::class, $security);
     $this->container->bind(UrlGeneratorContract::class, function () use($security) {
         return $security->url();
     });
     $this->container->bind([UrlGenerator::class => 'url'], function (Container $container) use($security) {
         /** @var PermissionAwareUrlGeneratorExtension $url */
         $url = $container->make(PermissionAwareUrlGeneratorExtension::class);
         $url->setUrlGenerator($security->url());
         return $url;
     });
     $request->setUserResolver(function () use($security) {
         return $security->getUser();
     });
 }
 public function register(Container $container)
 {
     $container->bind(Relay::class, function (Container $container) {
         /** @var RelayBuilder $relayBuilder */
         $relayBuilder = $container->make(RelayBuilder::class);
         $queue = array_merge([$container->make(ResponseSender::class), $container->make(NikicFastRoute::class, ['actionAttributeName' => App::DEFAULT_ACTION_ATTRIBUTE_NAME, 'parametersAttributeName' => App::DEFAULT_PARAMETERS_ATTRIBUTE_NAME])], $container->tagged('middleware.error_handler'), $container->tagged('middleware.early'), $container->tagged('middleware'), $container->tagged('middleware.late'), [$container->make(ActionHandler::class, ['actionAttributeName' => App::DEFAULT_ACTION_ATTRIBUTE_NAME])]);
         return $relayBuilder->newInstance($queue);
     });
 }
 public function register(Container $container)
 {
     $container->bind(FastRoute\Dispatcher::class, function (Container $container) {
         $routeCollector = $container->make(FastRoute\RouteCollector::class);
         return new FastRoute\Dispatcher\GroupCountBased($routeCollector->getData());
     });
     $container->bind(FastRoute\RouteParser::class, FastRoute\RouteParser\Std::class);
     $container->bind(FastRoute\DataGenerator::class, FastRoute\DataGenerator\GroupCountBased::class);
     $container->afterResolving(FastRoute\RouteCollector::class, function (FastRoute\RouteCollector $routeCollector, Container $container) {
         /** @var RouteProvider $routeProvider */
         foreach ($container->tagged('route_provider') as $routeProvider) {
             $routeProvider->addRoutes($routeCollector);
         }
     });
     $container->bind(ParametersReader::class, function () {
         return new ParametersReader(App::DEFAULT_PARAMETERS_ATTRIBUTE_NAME);
     });
 }
Beispiel #9
0
 /**
  * Binds the previous virtual binding into the Laravel service container.
  * This will map the interface to the concrete class, then create an alias
  * for the interface so it can later be referenced by its short name.
  */
 public function solidify()
 {
     if (count($this->lastBinding) < 2) {
         throw new BindingException("Container injection can't be completed as a previous " . "binding operation hasn't yet to occur.");
     }
     $alias = $this->lastBinding['alias'];
     $concrete = $this->lastBinding['concrete'];
     $this->container->bind($alias, function ($app) use($concrete) {
         return $app->make($concrete);
     });
 }
Beispiel #10
0
 protected function upgrade()
 {
     $this->container->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
         return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
     });
     $migrator = $this->container->make('Flarum\\Migrations\\Migrator');
     $migrator->run(base_path('core/migrations'));
     foreach ($migrator->getNotes() as $note) {
         $this->info($note);
     }
     $extensions = $this->container->make('Flarum\\Support\\ExtensionManager');
     $migrator = $extensions->getMigrator();
     foreach ($extensions->getInfo() as $extension) {
         $this->info('Upgrading extension: ' . $extension->name);
         $extensions->enable($extension->name);
         foreach ($migrator->getNotes() as $note) {
             $this->info($note);
         }
     }
 }
Beispiel #11
0
 protected function runMigrations()
 {
     $this->container->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
         return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
     });
     $migrator = $this->container->make('Flarum\\Migrations\\Migrator');
     $migrator->getRepository()->createRepository();
     $migrator->run(__DIR__ . '/../../../migrations');
     foreach ($migrator->getNotes() as $note) {
         $this->info($note);
     }
 }
 /**
  * @param Container $container
  */
 protected function registerContainerBindings(Container $container)
 {
     $container->bind(AccessTokenStorage::class, function () {
         return new AccessTokenStorage();
     });
     $container->bind(ClientStorage::class, function () {
         return new ClientStorage();
     });
     $container->bind(RefreshTokenStorage::class, function () {
         return new RefreshTokenStorage();
     });
     $container->bind(ScopeStorage::class, function () {
         return new ScopeStorage();
     });
     $container->bind(SessionStorage::class, function () {
         return new SessionStorage();
     });
     $container->bind(AccessTokenInterface::class, AccessTokenStorage::class);
     $container->bind(ClientInterface::class, ClientStorage::class);
     $container->bind(RefreshTokenInterface::class, RefreshTokenStorage::class);
     $container->bind(ScopeInterface::class, ScopeStorage::class);
     $container->bind(SessionInterface::class, SessionStorage::class);
 }
Beispiel #13
0
 public function upgrade()
 {
     $this->container->bind('Illuminate\\Database\\Schema\\Builder', function ($container) {
         return $container->make('Illuminate\\Database\\ConnectionInterface')->getSchemaBuilder();
     });
     $migrator = $this->container->make('Flarum\\Database\\Migrator');
     $migrator->run(base_path('core/migrations'));
     foreach ($migrator->getNotes() as $note) {
         $this->info($note);
     }
     $extensions = $this->container->make('Flarum\\Extension\\ExtensionManager');
     $migrator = $extensions->getMigrator();
     foreach ($extensions->getInfo() as $name => $extension) {
         if (!$extensions->isEnabled($name)) {
             continue;
         }
         $this->info('Migrating extension: ' . $name);
         $extensions->migrate($name);
         foreach ($migrator->getNotes() as $note) {
             $this->info($note);
         }
     }
     $this->container->make('Flarum\\Settings\\SettingsRepositoryInterface')->set('version', $this->container->version());
 }
 /**
  * @param ReflectionParameter[] $arguments
  *
  * @return Request|null
  */
 public function getRequest(array $arguments)
 {
     foreach ($arguments as $argument) {
         if ($argument->getClass() === null) {
             continue;
         }
         $type = $argument->getClass()->getName();
         if ($type === ApiCheckableRequest::class || in_array(ApiCheckableRequest::class, class_parents($type))) {
             $this->app->bind('illuminated.skipCheckableRequest', true);
             $instance = $this->app->make($type);
             if ($instance instanceof ApiCheckableRequest) {
                 return $instance;
             }
         }
     }
     return null;
 }
 /**
  * weaving
  */
 public function weave()
 {
     if (is_null($this->aspectResolver)) {
         return;
     }
     foreach ($this->aspectResolver->getResolver() as $class => $pointcuts) {
         $bind = (new AspectBind($this->filesystem, $this->configure['cache_dir'], $this->cacheable))->bind($class, $pointcuts);
         $compiledClass = $this->compiler->compile($class, $bind);
         if (isset($this->app->contextual[$class])) {
             $this->resolveContextualBindings($class, $compiledClass);
         }
         $this->app->bind($class, function (Container $app) use($bind, $compiledClass) {
             $instance = $app->make($compiledClass);
             $instance->bindings = $bind->getBindings();
             return $instance;
         });
     }
 }
 /**
  * Bind the interfaces to their implementations.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 public function registerInterfaceBindings(Application $app)
 {
     $app->bind(ClientInterface::class, FluentClient::class);
     $app->bind(ScopeInterface::class, FluentScope::class);
     $app->bind(SessionInterface::class, FluentSession::class);
     $app->bind(AuthCodeInterface::class, FluentAuthCode::class);
     $app->bind(AccessTokenInterface::class, FluentAccessToken::class);
     $app->bind(RefreshTokenInterface::class, FluentRefreshToken::class);
 }
 /**
  * Register the bindings.
  *
  * @param \Illuminate\Contracts\Container\Container $app
  *
  * @return void
  */
 protected function registerBindings(Application $app)
 {
     $app->bind('pusher.connection', function ($app) {
         $manager = $app['pusher'];
         return $manager->connection();
     });
     $app->alias('pusher.connection', Pusher::class);
 }
 /**
  * Wrap and register the middleware in the Container.
  *
  * @param  string          $abstract
  * @param  callable|string $callable
  * @param  array           $params
  */
 public function bind($abstract, $callable, $params = [])
 {
     $this->container->bind($abstract, function () use($callable, $params) {
         return $this->wrap($callable, $params);
     });
 }
 public function bind($abstract, $concrete = null, $shared = false)
 {
     $this->container->bind($abstract, $concrete, $shared);
 }
 /**
  * @param array|string $abstract
  * @param string|\Closure|null $concrete
  */
 public function bind($abstract, $concrete = null)
 {
     $this->container->bind($abstract, $concrete);
 }