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); }
/** * ExtensionRegistrar constructor. */ public function __construct() { $this->container = $this->getContainer(); $this->events = $this->container->make('events'); $this->router = $this->container->make('router'); $this->setting = $this->container->make('setting'); }
/** * Get the validator instance for the request. * * @param array $rules * @param array $messages * @param array $customAttributes * @return Validator */ protected function getValidatorInstance(array $rules, array $messages = array(), array $customAttributes = array()) { $factory = $this->app->make('Illuminate\\Contracts\\Validation\\Factory'); $validator = $factory->make([], $rules, $messages, $customAttributes); $validator->addCustomAttributes($customAttributes); return $validator; }
/** * 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); }
/** * @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; }
/** * 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; }
/** * Get the validator instance for the request. * * @return \Illuminate\Contracts\Validation\Validator */ protected function getValidatorInstance() { $factory = $this->container->make(ValidationFactory::class); if (method_exists($this, 'validator')) { return $this->container->call([$this, 'validator'], compact('factory')); } return $factory->make($this->all(), $this->container->call([$this, 'rules']), $this->messages(), $this->attributes()); }
/** * 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)); }); }
/** * Get the validator instance for the request. * * @return \Illuminate\Validation\Validator */ protected function getValidatorInstance() { $factory = $this->container->make('Illuminate\\Validation\\Factory'); if (method_exists($this, 'validator')) { return $this->container->call([$this, 'validator'], compact('factory')); } return $factory->make($this->all(), $this->container->call([$this, 'rules']), $this->messages()); }
/** * @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; }
/** * @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; }
/** * 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(); } }
/** * Constructor. * * @param array $viewPaths * @param string $cachePath * @param Container $container */ public function __construct($viewPaths, $cachePath, ContainerInterface $container = null) { $this->viewPaths = $viewPaths; $this->cachePath = $cachePath; $this->container = $container ?: new Container(); $this->setupContainer(); (new ViewServiceProvider($this->container))->register(); $this->engineResolver = $this->container->make('view.engine.resolver'); }
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; }
/** * @test */ public function it_should_auto_inject_dependencies_from_parent_container() { $this->parent->singleton(Helper::class, function () { return new Helper(uniqid()); }); /** @var Service $service */ $service = $this->local->make(Service::class); $this->assertInstanceOf(Service::class, $service); $this->assertEquals($this->parent->make(Helper::class)->key, $service->helper->key); }
/** * 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)); }); }
/** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { $schedule->command('inspire')->hourly(); $container = new Container(); $notificationService = $container->make('\\Broadcasters\\Providers\\NotificationsServiceProvider'); $channelService = $container->make('\\Broadcasters\\Providers\\ChannelServiceProvider'); $notificationService->notify($schedule, $channelService); /* $notifications = []; $notifications[] = [ 'msg'=>"Coming up Himalaya Fatafat at 12:00", 'time'=>"11:55", 'type'=>'live' ]; $notifications[] = [ 'msg'=>" Coming up Himalaya Prime News at 7:00", 'time'=>"18:55", 'type'=>'live' ]; $notifications[] = [ 'msg'=>"Coming up Prime Story at 7:30", 'time'=>"19:25", 'type'=>'live' ]; $notifications[] = [ 'msg'=>"Coming up Himalaya Fatafat at 8:00", 'time'=>"19:55", 'type'=>'live' ]; foreach($notifications as $notification): $time = date("H:i", strtotime('-345 minutes', strtotime($notification['time']))); $schedule->call(function() use ($notification){ //sendNotification('test notification 1'); ParseClient::initialize( 'ZBGNVDDcZJdilnPVkxTrXOe8U0ToWZcfWAqRTupN', 'bhtvPPoz8siyZO0RbS7sGYmvpusa8YubzxIi7Oa9', 'd269BnkUvTv83AvbqFnKoRVb9gHRmMQDZht4kpuc' ); $query = ParseInstallation::query(); $query->containedIn('channels', ['','global']); //$types = ['live','latest','featured','popular','news']; $not_data =[]; ParsePush::send(array( "where" => $query, "data" => array( "alert" => $notification['msg'], "nitv_b_typeId" => $notification['type'], "nitv_b_data"=>$not_data ) )); \Log::info(error_get_last ()); })->dailyAt($time); endforeach;*/ }
/** * @return mixed */ public function makeModel() { if (is_null($this->getModelClass())) { throw new \Exception("className property must be an instance of Illuminate\\Database\\Eloquent\\Model"); } $model = $this->app->make($this->getModelClass()); if (!$model instanceof Model) { throw new \Exception("Class {$this->model()} must be an instance of Illuminate\\Database\\Eloquent\\Model"); } return $this->setModel($model); }
/** * Resolve a transformer binding instance. * * @throws \RuntimeException * * @return object */ public function resolveTransformer() { if (is_string($this->resolver)) { return $this->container->make($this->resolver); } elseif (is_callable($this->resolver)) { return call_user_func($this->resolver, $this->container); } elseif (is_object($this->resolver)) { return $this->resolver; } throw new RuntimeException('Unable to resolve transformer binding.'); }
/** * Return a stream entry form. * * @param array $parameters * @return $this */ public function form(array $parameters = []) { if (!($builder = array_get($parameters, 'builder'))) { $builder = 'Anomaly\\SlackInviterExtension\\Invite\\Form\\InviteFormBuilder'; } /* @var FormBuilder $builder */ $builder = $this->container->make($builder); $this->hydrator->hydrate($builder, $parameters); $builder->make(); return $builder->getFormPresenter(); }
/** * Build the menu structure. * * @return mixed */ public function getItemProviders() { foreach ($this->modules->enabled() as $module) { $name = studly_case($module->getName()); $class = 'Modules\\' . $name . '\\MenuExtenders\\MenuExtender'; if (class_exists($class)) { $extender = $this->container->make($class); $this->extenders->put($module->getName(), ['content' => $extender->getContentItems(), 'static' => $extender->getStaticItems()]); } } return $this->extenders; }
/** * Resolve an instance of the given GenCrud class. * * @param $class * @return mixed */ public function resolve($class) { if (isset($this->container)) { $instance = $this->container->make($class); $instance->setContainer($this->container); } else { $instance = new $class(); } if (isset($this->command)) { $instance->setCommand($this->command); } return $instance; }
/** * Get the dependency for the given call parameter. * * @param \ReflectionParameter $param * @param array $parameters * @return mixed */ protected function resolveMethodArgument(ReflectionParameter $param, array &$parameters) { if ($this->parameterIsDefined($param, $parameters)) { return $this->extractParameter($param, $parameters); } if ($param->getClass()) { return $this->container->make($param->getClass()->name); } if ($param->isDefaultValueAvailable()) { return $param->getDefaultValue(); } return array_shift($parameters); }
/** * Set up the various view engines. * * @param Container $app */ public function boot(Container $app) { $app->afterResolving(function (Factory $factory, $app) { $factory->addExtension('php', 'php', function () { return new PhpEngine(); }); $factory->addExtension('blade.php', 'blade', function () use($app) { return new CompilerEngine($app->make(BladeCompiler::class)); }); $factory->addExtension('md', 'markdown', function () use($app) { return new CompilerEngine($app->make(Markdown::class)); }); }); $app->when(BladeCompiler::class)->needs('$cachePath')->give(vfsStream::setup('root/.blade')->url()); }
/** * Resolve an entity. * * @param string $id * * @return Entity */ protected function resolveEntity($id) { $class = $this->classes[$id]; if (!$this->classExists($class)) { throw new RuntimeException("Failed to resolve: the target class [{$class}] is not bound."); } /** * @var Entity $schema */ $entity = $this->container->make($class); $this->resolved[$id] = $entity; $entity->setId($id); $entity->setEntitiesRepository($this); return $entity; }
public function purge() { Audit::log(Auth::user()->id, trans('admin/audit/general.audit-log.category'), trans('admin/audit/general.audit-log.msg-purge')); $purge_retention = config('audit.purge_retention'); $purge_date = (new \DateTime())->modify("- {$purge_retention} day"); $auditsToDelete = $this->audit->pushCriteria(new AuditCreatedBefore($purge_date))->all(); foreach ($auditsToDelete as $audit) { // The AuditRepository located at $this->audit is changed to a instance of the // QueryBuilder when we run a query as done above. So we had to revert to some // Magic to get a handle of the model... // $this->audit->delete($audit->id); $this->app->make($this->audit->model())->destroy($audit->id); } return \Redirect::route('admin.audit.index'); }
/** * Build and return a ServiceInterface object. * * @param string $service * @param string $redirectUri * @param array $scopes * @return OAuth\ServiceInterface */ public function consumer($service, $redirectUri = null, $scopes = null) { // use scope from config if not provided if (is_null($scopes)) { $scopes = $this->app['config']->get('php-oauth::oauth.consumers.' . $service . '.scopes', []); } // Default redirect URI. $redirectUri = $redirectUri ?: $this->app['url']->current(); // Get the credentials. $credentials = array_only($this->app['config']->get('php-oauth::oauth.consumers.' . $service), ['client_id', 'client_secret']); // Generate class name. $class = 'OAuth\\Services\\' . ucfirst($service); // Create configured consumer object. return $this->app->make($class)->setScopes($scopes)->setRedirectUri($redirectUri)->setCredentials($credentials); }
/** * Set the throttle to use for rate limiting. * * @param string|\Dingo\Api\Contract\Http\RateLimit\Throttle * * @return void */ public function setThrottle($throttle) { if (is_string($throttle)) { $throttle = $this->container->make($throttle); } $this->throttle = $throttle; }
/** * Resolve the subscriber instance. * * @param mixed $subscriber * @return mixed */ protected function resolveSubscriber($subscriber) { if (is_string($subscriber)) { return $this->container->make($subscriber); } return $subscriber; }
/** * 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; }