当前位置: 首页>>代码示例>>PHP>>正文


PHP ContainerInterface::get方法代码示例

本文整理汇总了PHP中Interop\Container\ContainerInterface::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ContainerInterface::get方法的具体用法?PHP ContainerInterface::get怎么用?PHP ContainerInterface::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Interop\Container\ContainerInterface的用法示例。


在下文中一共展示了ContainerInterface::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: execute

 /**
  * Executa a ação.
  *
  * @return mixin
  */
 public function execute()
 {
     $oAuthServiceName = $this->params('oAuthService');
     $redirectAfterResponse = $this->params()->fromQuery('redirectAfterResponse');
     $scopes = $this->params()->fromQuery('scopes', []);
     $routeToRedirectAfterResponse = null;
     if (is_string($scopes)) {
         if (trim($scopes)) {
             $scopes = explode(',', $scopes);
         } else {
             $scopes = [];
         }
     }
     if (!$oAuthServiceName) {
         return $this->error('The query param "oAuthService" is required.');
     }
     if ($redirectAfterResponse) {
         if (is_string($redirectAfterResponse)) {
             $redirectAfterResponse = CryptQueryParam::decrypt_($redirectAfterResponse);
         }
         if ($redirectAfterResponse) {
             $routeToRedirectAfterResponse = new InternalRoute($redirectAfterResponse);
         }
     }
     AskForAuthorizationResponse::storeDateToUseAfterResponse($routeToRedirectAfterResponse, $oAuthServiceName, $scopes);
     /** @var OAuthServiceInterface $oAuthService */
     $oAuthService = $this->container->get('Sta\\OAuthConnect\\OAuthService\\' . $oAuthServiceName);
     $callbackUrl = $this->getController()->url()->fromRoute('sta/oAuthConnect/response', [], ['force_canonical' => true]);
     $authorizeRedirectUri = $oAuthService->getUrlToAskAuthorization($callbackUrl, $scopes);
     if (!$authorizeRedirectUri) {
         return $this->error('OAuth Service implementation class method ' . get_class($oAuthService) . '::getUrlToAskAuthorization() must return a valid URL.');
     }
     return $this->getController()->redirect()->toUrl($authorizeRedirectUri);
 }
开发者ID:stavarengo,项目名称:o-auth-connect,代码行数:39,代码来源:AskForAuthorization.php

示例2: __invoke

 /**
  * @param ContainerInterface $container
  * @return RpcServiceModelFactory
  * @throws ServiceNotCreatedException
  */
 public function __invoke(ContainerInterface $container)
 {
     if (!$container->has(ModulePathSpec::class) || !$container->has(ConfigResourceFactory::class) || !$container->has(ModuleModel::class) || !$container->has('SharedEventManager')) {
         throw new ServiceNotCreatedException(sprintf('%s is missing one or more dependencies from ZF\\Configuration', RpcServiceModelFactory::class));
     }
     return new RpcServiceModelFactory($container->get(ModulePathSpec::class), $container->get(ConfigResourceFactory::class), $container->get('SharedEventManager'), $container->get(ModuleModel::class));
 }
开发者ID:zfcampus,项目名称:zf-apigility-admin,代码行数:12,代码来源:RpcServiceModelFactoryFactory.php

示例3: __invoke

 /**
  * Create and return a DocumentationModel instance.
  *
  * @param ContainerInterface $container
  * @param string $requestedName
  * @param null|array $options
  * @return DocumentationModel
  * @throws ServiceNotCreatedException
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     if (!$container->has(ConfigResourceFactory::class)) {
         throw new ServiceNotCreatedException(sprintf('%s requires that the %s service be present; service not found', DocumentationModel::class, ConfigResourceFactory::class));
     }
     return new DocumentationModel($container->get(ConfigResourceFactory::class), $container->get(ModuleUtils::class));
 }
开发者ID:zfcampus,项目名称:zf-apigility-admin,代码行数:16,代码来源:DocumentationModelFactory.php

示例4: __invoke

 /**
  * @param ContainerInterface $container
  * @returns ZendViewRenderer
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     $config = isset($config['templates']) ? $config['templates'] : [];
     // Configuration
     $resolver = new Resolver\AggregateResolver();
     $resolver->attach(new Resolver\TemplateMapResolver(isset($config['map']) ? $config['map'] : []), 100);
     // Create the renderer
     $renderer = new PhpRenderer();
     $renderer->setResolver($resolver);
     $manager = $container->has(HelperPluginManager::class) ? $container->get(HelperPluginManager::class) : new HelperPluginManager();
     // Inject helpers
     $this->injectHelpers($renderer, $manager);
     // Initialize renderer for HelperPluginManager
     $manager->setRenderer($renderer);
     // Inject renderer
     $view = new ZendViewRenderer($renderer, isset($config['layout']) ? $config['layout'] : null);
     // Add template paths
     $allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : [];
     foreach ($allPaths as $namespace => $paths) {
         $namespace = is_numeric($namespace) ? null : $namespace;
         foreach ((array) $paths as $path) {
             $view->addPath($path, $namespace);
         }
     }
     return $view;
 }
开发者ID:fabiocarneiro,项目名称:zend-expressive-zendviewrenderer,代码行数:31,代码来源:ZendViewRendererFactory.php

示例5: __invoke

 /**
  * @inheritDoc
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('config');
     $config = isset($config['asset_manager']) ? $config['asset_manager'] : array();
     $resolver = new AggregateResolver();
     if (empty($config['resolvers'])) {
         return $resolver;
     }
     foreach ($config['resolvers'] as $resolverService => $priority) {
         $resolverService = $container->get($resolverService);
         if (!$resolverService instanceof ResolverInterface) {
             throw new Exception\RuntimeException('Service does not implement the required interface ResolverInterface.');
         }
         if ($resolverService instanceof AggregateResolverAwareInterface) {
             $resolverService->setAggregateResolver($resolver);
         }
         if ($resolverService instanceof MimeResolverAwareInterface) {
             $resolverService->setMimeResolver($container->get(MimeResolver::class));
         }
         if ($resolverService instanceof AssetFilterManagerAwareInterface) {
             $resolverService->setAssetFilterManager($container->get(AssetFilterManager::class));
         }
         $resolver->attach($resolverService, $priority);
     }
     return $resolver;
 }
开发者ID:rwoverdijk,项目名称:assetmanager,代码行数:29,代码来源:AggregateResolverServiceFactory.php

示例6: __invoke

 /**
  * Create service
  *
  * @param ContainerInterface $container
  * @return mixed
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->get('config');
     $cacheEnabled = isset($config['view']['cache']) ? (bool) $config['view']['cache'] : false;
     $layout = isset($config['view']['layout']) && is_string($config['view']['layout']) ? $config['view']['layout'] : 'CargoUI/view/layout/layout.phtml';
     return new Main($layout, $cacheEnabled, $container->get(RiotCompiler::class));
 }
开发者ID:josecelano,项目名称:php-ddd-cargo-sample,代码行数:13,代码来源:MainFactory.php

示例7: __invoke

 public function __invoke(ContainerInterface $container)
 {
     $config = $container->get('config');
     $expressive_redirect_handler_config = isset($config['expressive-redirect-handler']) ? $config['expressive-redirect-handler'] : [];
     $router = $container->get(RouterInterface::class);
     return new RedirectHandlerAction($expressive_redirect_handler_config, $router);
 }
开发者ID:samsonasik,项目名称:ExpressiveRedirectHandler,代码行数:7,代码来源:RedirectHandlerActionFactory.php

示例8: __invoke

 /**
  * Create and return an instance of the Middleware.
  *
  * @param  Interop\Container\ContainerInterface $container
  * @param  string $requestedName
  * @param  array $options
  * @return MiddlewareInterface
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $rqlParser = new Rest\Rql\RqlParser();
     $responseEncoder = new Rest\ResponseEncoder();
     $resourceName = $requestedName;
     //is there config for this resource?
     $config = $container->get('config');
     if (isset($config['resource'][$resourceName]['storeMiddleware'])) {
         $storeMiddlewareServiceName = $config['resource'][$resourceName]['storeMiddleware'];
         $storeMiddleware = $container->get($storeMiddlewareServiceName);
         return new restActionPipe($rqlParser, $storeMiddleware, $responseEncoder);
     }
     //is there table with same name?
     $db = $container->has('db') ? $container->get('db') : null;
     if (isset($db)) {
         $dbMetadata = new Zend\Db\Metadata\Metadata($db);
         $tableNames = $dbMetadata->getTableNames();
         if (isset($tableNames[$resourceName])) {
             $tableGateway = new TableGateway($resourceName, $db);
             $dataStore = new DbTable($tableGateway);
             $storeMiddleware = new StoreMiddleware($dataStore);
             return new Rest\RestActionPipe($rqlParser, $storeMiddleware, $responseEncoder);
         }
     }
     throw new DataStoresException('Can\'t make RestActionPipe' . ' for resource: ' . $resourceName);
 }
开发者ID:avz-cmf,项目名称:zaboy-middleware,代码行数:34,代码来源:RestActionPipeFactory.php

示例9: tearDown

 /**
  * Tears down the fixture, for example, closes a network connection.
  * This method is called after a test is executed.
  */
 protected function tearDown()
 {
     $adapter = $this->container->get('db');
     $tableManagerMysql = new TableManagerMysql($adapter);
     $tableManagerMysql->deleteTable($this->object->getStore()->getTable());
     $tableManagerMysql->deleteTable($this->object->getQueue()->getStore()->getTable());
 }
开发者ID:avz-cmf,项目名称:zaboy-async,代码行数:11,代码来源:ClientTest.php

示例10: __invoke

 /**
  * @param ContainerInterface $container
  * @return TeacherAction
  */
 public function __invoke(ContainerInterface $container)
 {
     $router = $container->get(RouterInterface::class);
     $userService = $container->get(TeacherService::class);
     $studentWebService = $container->get('StudentWebService');
     return new TeacherAction($router, $userService, $studentWebService);
 }
开发者ID:lazhacks,项目名称:h2-teacher-service,代码行数:11,代码来源:TeacherActionFactory.php

示例11: __invoke

 /**
  * __invoke
  *
  * @param ContainerInterface $container
  *
  * @return AxosoftLoggerPsr
  */
 public function __invoke($container)
 {
     $configRoot = $container->get('Config');
     $loggerOptions = $configRoot['Reliv\\RcmAxosoft']['errorLogger'];
     $api = $container->get('Reliv\\AxosoftApi\\Service\\AxosoftApi');
     return new AxosoftLoggerPsr($api, $loggerOptions);
 }
开发者ID:reliv,项目名称:rcm-axosoft,代码行数:14,代码来源:AxosoftLoggerPsrFactory.php

示例12: testFactoryWithTemplate

 public function testFactoryWithTemplate()
 {
     $factory = new PageFactory();
     $this->container->has(TemplateRendererInterface::class)->willReturn(true);
     $this->container->get(TemplateRendererInterface::class)->willReturn($this->prophesize(TemplateRendererInterface::class));
     $this->assertTrue($factory instanceof PageFactory);
 }
开发者ID:codingmatters,项目名称:kernel,代码行数:7,代码来源:PageFactoryTest.php

示例13: __invoke

 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     /* @var $aclCache \Zend\Cache\Storage\StorageInterface */
     $aclCache = $container->get('AclCache');
     $acl = $aclCache->getItem('Acl');
     if (!$acl) {
         /* @var $userApi UserApiInterface */
         $userApi = $container->get(UserApiInterface::SERVICE_NAME);
         $acl = new Acl();
         $resources = $userApi->getPermissions();
         foreach ($resources as $resource) {
             $acl->addResource($resource);
         }
         $roles = $userApi->getRolesAndParent();
         foreach ($roles as $role => $parents) {
             $this->addRoleToAcl($role, $roles, $acl);
         }
         $rolePermissions = $userApi->getRolePermissions();
         foreach ($rolePermissions as $role => $permissions) {
             $acl->allow($role, $permissions);
         }
         $deniedRolePermissions = $userApi->getDeniedRolePermissions();
         foreach ($deniedRolePermissions as $role => $permissions) {
             $acl->deny($role, $permissions);
         }
         $aclCache->setItem('Acl', $acl);
     }
     return $acl;
 }
开发者ID:zend-bricks,项目名称:bricks-user,代码行数:29,代码来源:AclFactory.php

示例14: __invoke

 /**
  * @param ContainerInterface $container
  * @return TwigRenderer
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     $debug = array_key_exists('debug', $config) ? (bool) $config['debug'] : false;
     $config = isset($config['templates']) ? $config['templates'] : [];
     $cacheDir = isset($config['cache_dir']) ? $config['cache_dir'] : false;
     // Create the engine instance
     $loader = new TwigLoader();
     $environment = new TwigEnvironment($loader, ['cache' => $debug ? false : $cacheDir, 'debug' => $debug, 'strict_variables' => $debug, 'auto_reload' => $debug]);
     // Add extensions
     if ($container->has(RouterInterface::class)) {
         $environment->addExtension(new TwigExtension($container->get(RouterInterface::class), isset($config['assets_url']) ? $config['assets_url'] : '', isset($config['assets_version']) ? $config['assets_version'] : ''));
     }
     if ($debug) {
         $environment->addExtension(new TwigExtensionDebug());
     }
     // Inject environment
     $twig = new TwigRenderer($environment, isset($config['extension']) ? $config['extension'] : 'html.twig');
     // Add template paths
     $allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : [];
     foreach ($allPaths as $namespace => $paths) {
         $namespace = is_numeric($namespace) ? null : $namespace;
         foreach ((array) $paths as $path) {
             $twig->addPath($path, $namespace);
         }
     }
     return $twig;
 }
开发者ID:akrabat,项目名称:zend-expressive-twigrenderer,代码行数:32,代码来源:TwigRendererFactory.php

示例15: __invoke

 /**
  * @param ContainerInterface $container
  * @return EventStore
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->get('config');
     if (!isset($config['prooph'])) {
         throw ConfigurationException::configurationError('Missing prooph config key in application config');
     }
     if (!isset($config['prooph']['event_store'])) {
         throw ConfigurationException::configurationError('Missing key event_store in prooph configuration');
     }
     $config = $config['prooph']['event_store'];
     if (!isset($config['adapter']['type'])) {
         throw ConfigurationException::configurationError(sprintf('Event store adapter is missing in configuration'));
     }
     $adapter = $container->get($config['adapter']['type']);
     if (!isset($config['event_emitter'])) {
         $eventEmitter = new ProophActionEventEmitter();
     } else {
         $eventEmitter = $container->get($config['event_emitter']);
     }
     $eventStore = new EventStore($adapter, $eventEmitter);
     $plugins = isset($config['plugins']) ? $config['plugins'] : [];
     foreach ($plugins as $pluginAlias) {
         $plugin = $container->get($pluginAlias);
         if (!$plugin instanceof Plugin) {
             throw ConfigurationException::configurationError(sprintf('Plugin %s does not implement the Plugin interface', $pluginAlias));
         }
         $plugin->setUp($eventStore);
     }
     return $eventStore;
 }
开发者ID:ad3n,项目名称:event-store,代码行数:34,代码来源:EventStoreFactory.php


注:本文中的Interop\Container\ContainerInterface::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。