/**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('newrelic', function ($app) {
         return new RocketeerNewrelicConfig($app['config']->get('rocketeer-newrelic::config'));
     });
     return $app;
 }
Exemplo n.º 2
0
 public function make(RequestContainer $requestContainer, Container $app)
 {
     if ($requestContainer->getId()) {
         return new InstanceQuery($app->make('query_builders'), $requestContainer);
     }
     return new CollectionQuery($app->make('query_builders'), $requestContainer);
 }
Exemplo n.º 3
0
 protected function createApplicationContainer()
 {
     $this->app = new \TestContainer();
     $this->app->singleton('config', function () {
         return new \Illuminate\Config\Repository();
     });
     $this->registerConfigure();
     $eventServiceProvider = new \Illuminate\Encryption\EncryptionServiceProvider($this->app);
     $eventServiceProvider->register();
     $eventServiceProvider = new \Illuminate\Events\EventServiceProvider($this->app);
     $eventServiceProvider->register();
     $queueProvider = new \Illuminate\Queue\QueueServiceProvider($this->app);
     $queueProvider->register();
     $sessionProvider = new \Illuminate\Session\SessionServiceProvider($this->app);
     $sessionProvider->register();
     $this->registerDatabase();
     $this->registerCache();
     $couchbaseProvider = new \Ytake\LaravelCouchbase\CouchbaseServiceProvider($this->app);
     $couchbaseProvider->register();
     $couchbaseProvider->boot();
     $this->app->bind(\Illuminate\Container\Container::class, function () {
         return $this->app;
     });
     (new \Illuminate\Events\EventServiceProvider($this->app))->register();
     \Illuminate\Container\Container::setInstance($this->app);
 }
Exemplo n.º 4
0
 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('slack', function ($app) {
         return new Client($app['config']->get('rocketeer-slack::url'));
     });
     return $app;
 }
Exemplo n.º 5
0
 /**
  * Deteremine if the request passes the authorization check.
  *
  * @return bool
  */
 protected function passesAuthorization()
 {
     if (method_exists($this, 'authorize')) {
         return $this->container->call([$this, 'authorize']);
     }
     return false;
 }
Exemplo n.º 6
0
 /**
  * Changes the set SMS driver
  *
  * @param $driver
  */
 public function driver($driver)
 {
     $this->container['sms.sender'] = $this->container->share(function ($app) use($driver) {
         return (new DriverManager($app))->driver($driver);
     });
     $this->driver = $this->container['sms.sender'];
 }
Exemplo n.º 7
0
 /**
  * Call the given seeder.
  *
  * @param  \Closure|string  $seeder
  * @return void
  */
 protected function call($seeder)
 {
     if ($seeder instanceof Closure) {
         return $this->container->call($seeder);
     }
     $this->container->call($seeder, [], 'seed');
 }
 /**
  * Setup the IoC container instance.
  *
  * @param  \Illuminate\Container\Container|null  $container
  * @return void
  */
 protected function setupContainer($container)
 {
     $this->container = $container ?: new Container();
     if (!$this->container->bound('config')) {
         $this->container->instance('config', new Fluent());
     }
 }
 /**
  * Execute the required command against the command handler.
  *
  * @param Command $command
  * @return mixed
  */
 public function execute(Command $command)
 {
     $handler = $this->commandTranslator->getCommandHandler($command);
     $commandName = $this->getCommandName($command);
     $this->log->info("New command [{$commandName}]", get_object_vars($command));
     return $this->app->make($handler)->handle($command);
 }
 /**
  * Bind additional classes to the Container
  *
  * @param Container $app
  *
  * @return void
  */
 public function register(Container $app)
 {
     $app->bind('campfire', function ($app) {
         return new Campfire($app['config']->get('rocketeer-campfire::config'));
     });
     return $app;
 }
 /**
  * @param Container $app
  *
  * @return AwsServiceProvider
  */
 private function setupServiceProvider(Container $app)
 {
     // Create and register the provider.
     $provider = new AwsServiceProvider($app);
     $app->register($provider);
     $provider->boot();
     return $provider;
 }
Exemplo n.º 12
0
 /**
  * @return \Illuminate\Container\Container
  */
 public static function getContainer()
 {
     if (!self::$container) {
         self::$container = new \Illuminate\Container\Container();
         self::$container->bind('app', self::$container);
     }
     return self::$container;
 }
 /**
  * @param array $keys
  * @return \LW\Statistics\StatisticsProviderCollection
  */
 protected function makeProvidersCollection($keys)
 {
     $collection = new StatisticsProviderCollection();
     foreach ($keys as $name) {
         $collection->add($name, $this->container->make($this->providerMap[$name]));
     }
     return $collection;
 }
Exemplo n.º 14
0
 /**
  * Refresh modal object.
  *
  * @throws RepositoryException
  *
  * @return Model
  */
 public function makeModel()
 {
     $model = $this->app->make($this->model());
     if (!$model instanceof Model) {
         throw new RepositoryException("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model");
     }
     return $this->model = $model;
 }
 /**
  * @return ContainerInterface
  */
 private function createContainer(array $map = [])
 {
     $container = new Container();
     foreach ($map as $key => $value) {
         $container->bind($key, $value);
     }
     return new LaravelContainer($container);
 }
Exemplo n.º 16
0
 /**
  * Call the given controller instance method.
  *
  * @param  \Illuminate\Routing\Controller  $instance
  * @param  \Illuminate\Routing\Route  $route
  * @param  \Illuminate\Http\Request  $request
  * @param  string  $method
  * @return mixed
  */
 protected function callWithinStack($instance, $route, $request, $method)
 {
     $middleware = $this->getMiddleware($instance, $method);
     $shouldSkipMiddleware = $this->container->bound('middleware.disable') && $this->container->make('middleware.disable') === true;
     return (new Pipeline($this->container))->send($request)->through($shouldSkipMiddleware ? [] : $middleware)->then(function ($request) use($instance, $route, $method) {
         return $this->router->prepareResponse($request, $this->call($instance, $route, $method));
     });
 }
 public function register(Container $app)
 {
     $settings = ['username' => $app['config']->get('rocketeer-slack-unofficial::config')['url'], 'channel' => $app['config']->get('rocketeer-slack-unofficial::config')['channel'], 'link_names' => true, 'icon' => ':rocket:'];
     $app->bind('slack', function ($app) use($settings) {
         return new Client($app['config']->get('rocketeer-slack-unofficial::config')['hook-url'], $settings);
     });
     return $app;
 }
Exemplo n.º 18
0
 /**
  * @param       $class
  * @param array $args
  * @return mixed
  * @throws RepositoryException
  */
 protected function makeCriteria($class, array $args)
 {
     $criteria = $this->app->make($class, $args);
     if (!$criteria instanceof CriteriaContract) {
         throw new RepositoryException("Class {$class} must be an instance of GuilhermeGonzaga\\Repository\\Criteria\\Criteria");
     }
     return $criteria;
 }
Exemplo n.º 19
0
 /**
  * 初始化,注入container
  *
  * @param Container $container
  */
 public function __construct(Container $container)
 {
     $this->container = $container;
     // 初始化 DB类 TODO 应该用 事件监听的方式来初始化 因为有可能在不需要db的情况下也初始化了
     $container->make('db');
     if (method_exists($this, '__init__')) {
         return call_user_func_array(array($this, '__init__'), array());
     }
 }
Exemplo n.º 20
0
 /**
  * Resolve an instance of the given seeder class.
  *
  * @param  string  $class
  * @return \Illuminate\Database\Seeder
  */
 protected function resolve($class)
 {
     if (isset($this->container)) {
         $instance = $this->container->make($class);
         return $instance->setContainer($this->container)->setCommand($this->command);
     } else {
         return new $class();
     }
 }
 protected function createContainer()
 {
     $container = new Container();
     $container->instance('array_iterator', new \ArrayIterator(range(1, 5)));
     $container->bind('error', function () {
         throw new \RuntimeException();
     });
     return new LaravelContainerAdapter($container);
 }
Exemplo n.º 22
0
 /**
  * Makes a request.
  *
  * @param Request $request A Request instance
  * @return Response A Response instance
  * @throws \Exception
  */
 protected function doRequest($request)
 {
     $uses = array_flip(class_uses_recursive(get_class($this->app)));
     if (isset($uses[RoutesRequests::class])) {
         return $this->response = $this->app->prepareResponse($this->app->handle($request));
     } else {
         throw new \Exception(sprintf('The application is not using the %s trait.', RoutesRequests::class));
     }
 }
Exemplo n.º 23
0
 /**
  * @return $this
  */
 protected function parseIncludes()
 {
     $request = $this->application->make('Illuminate\\Http\\Request');
     $paramIncludes = Config::get('reloquent.fractal.params.include', 'include');
     if ($request->has($paramIncludes)) {
         $this->fractal->parseIncludes($request->get($paramIncludes));
     }
     return $this;
 }
Exemplo n.º 24
0
 /**
  * Bind the Warkham classes to the Container
  *
  * @param Container $app
  *
  * @return Container
  */
 public function bindWarkhamClasses(Container $app)
 {
     $app->singleton('warkham', function ($app) {
         $methodDispatcher = array('Warkham\\Fields\\', Warkham::FIELDSPACE);
         $methodDispatcher = new MethodDispatcher($app, $methodDispatcher);
         return new Warkham($app, $methodDispatcher);
     });
     return $app;
 }
Exemplo n.º 25
0
 /** @test */
 public function it_can_retrieve_dynamic_objects_from_the_container()
 {
     $container = new Container();
     $container->bind('foo', function () {
         return 'bar';
     });
     $handler = new EventHandlerStub($container);
     $this->assertSame('bar', $handler->foo);
 }
Exemplo n.º 26
0
 /**
  * Call the given controller instance method.
  *
  * @param  \Illuminate\Routing\Controller  $instance
  * @param  \Illuminate\Routing\Route  $route
  * @param  \Illuminate\Http\Request  $request
  * @param  string  $method
  * @return mixed
  */
 protected function callWithinStack($instance, $route, $request, $method)
 {
     $middleware = $this->getMiddleware($instance, $method);
     $shouldSkipMiddleware = $this->container->bound('middleware.disable') && $this->container->make('middleware.disable') === true;
     // Here we will make a stack onion instance to execute this request in, which gives
     // us the ability to define middlewares on controllers.
     return (new Pipeline($this->container))->send($request)->through($shouldSkipMiddleware ? [] : $middleware)->then(function ($request) use($instance, $route, $method) {
         return $this->router->prepareResponse($request, $this->call($instance, $route, $method));
     });
 }
Exemplo n.º 27
0
 /**
  * @param Container $app
  * @param array     $providers
  */
 private function bindings(Container &$app, array $providers)
 {
     Collection::make($providers)->map(function ($provider) use($app) {
         return $app->make($provider, [$app]);
     })->filter(function ($object) {
         return is_a($object, ServiceProvider::class);
     })->each(function (ServiceProvider $provider) {
         $provider->register();
     });
 }
Exemplo n.º 28
0
 public function strip($text)
 {
     foreach ($this->getFormatters() as $formatter) {
         $formatter = $this->container->make($formatter);
         if (method_exists($formatter, 'strip')) {
             $text = $formatter->strip($text);
         }
     }
     return $text;
 }
Exemplo n.º 29
0
 public function __construct(array $attributes)
 {
     $this->encrypter = new Encrypter('088409730f085dd15e8e3a7d429dd185', 'AES-256-CBC');
     $app = new Container();
     $app->singleton('app', 'Illuminate\\Container\\Container');
     $app->singleton('config', 'Illuminate\\Config\\Repository');
     $app['config']->set('elocrypt.prefix', '__ELOCRYPT__:');
     Facade::setFacadeApplication($app);
     parent::__construct($attributes);
 }
Exemplo n.º 30
-1
 /**
  * Get the IoC Container
  *
  * @param string $make A dependency to fetch
  *
  * @return Container
  */
 public static function getContainer($make = null)
 {
     if ($make) {
         return static::$container->make($make);
     }
     return static::$container;
 }