當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Container\ContainerInterface類代碼示例

本文整理匯總了PHP中Interop\Container\ContainerInterface的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerInterface類的具體用法?PHP ContainerInterface怎麽用?PHP ContainerInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ContainerInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __invoke

 /**
  * Create and return a NoRecordExists validator.
  *
  * @param ContainerInterface $container
  * @param string $requestedName
  * @param null|array $options
  * @return NoRecordExists
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     if (isset($options['adapter'])) {
         return new NoRecordExists(ArrayUtils::merge($options, ['adapter' => $container->get($options['adapter'])]));
     }
     return new NoRecordExists($options);
 }
開發者ID:zfcampus,項目名稱:zf-content-validation,代碼行數:15,代碼來源:NoRecordExistsFactory.php

示例2: __invoke

 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->get('config');
     $collectorConfig = ['service_name' => isset($config['hermes']['service_name']) ? $config['hermes']['service_name'] : '', 'api_key' => isset($config['kharon']['api_key']) ? $config['kharon']['api_key'] : null, 'kharon_dir' => isset($config['kharon']['agent_dir']) ? $config['kharon']['agent_dir'] : 'data/kharon'];
     $collectorConfig['kharon_dir'] .= '/hermes';
     return new Collector($collectorConfig);
 }
開發者ID:mt-olympus,項目名稱:kharon-hermes,代碼行數:7,代碼來源:CollectorFactory.php

示例3: __invoke

 /**
  * @param ContainerInterface $container
  *
  * @return PhpRenderer
  */
 public function __invoke(ContainerInterface $container)
 {
     $helper = $container->get(HelperPluginManager::class);
     $renderer = new PhpRenderer();
     $renderer->setHelperPluginManager($helper);
     return $renderer;
 }
開發者ID:oqq,項目名稱:ci-zend-form-twig-extension,代碼行數:12,代碼來源:ZendFormPhpRendererFactory.php

示例4: __invoke

 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     $debug = array_key_exists('debug', $config) ? (bool) $config['debug'] : false;
     $options = $config['session']['psr7'];
     return new SessionMiddleware(new Sha256(), $options['signature_key'], $options['verification_key'], SetCookie::create($options['cookie_name'])->withSecure($options['cookie_secure'])->withHttpOnly(true), new Parser(), $options['expiration_time']);
 }
開發者ID:jkhaled,項目名稱:xtreamwayz.com,代碼行數:7,代碼來源:SessionMiddlewareFactory.php

示例5: __invoke

 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $client = $container->get('NewRelic\\Client');
     $options = $container->get('NewRelic\\ModuleOptions');
     $logger = $container->get('NewRelic\\Logger');
     return new ErrorListener($client, $options, $logger);
 }
開發者ID:neeckeloo,項目名稱:newrelic,代碼行數:7,代碼來源:ErrorListenerFactory.php

示例6: __construct

 public function __construct(FrameBuffer $frameBuffer, ContainerInterface $container)
 {
     $this->frameBuffer = $frameBuffer;
     $this->container = $container;
     $this->bitmapLoader = $container->get(BitmapLoader::class);
     $this->sprites = [];
 }
開發者ID:hackheim,項目名稱:pixelpong,代碼行數:7,代碼來源:BaseGameLoop.php

示例7: __invoke

 /**
  * Create an object
  *
  * @param  ContainerInterface $container
  * @param  string $requestedName
  * @param  null|array $options
  * @return object|\Swift_Mailer
  * @throws ServiceNotFoundException if unable to resolve the service.
  * @throws ServiceNotCreatedException if an exception is raised when
  *     creating a service.
  * @throws ContainerException if any other error occurs
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null) : \Swift_Mailer
 {
     $mailConfig = $container->get('config')['mail'];
     $smtp = $mailConfig['smtp'];
     $transport = \Swift_SmtpTransport::newInstance($smtp['server'], $smtp['port'], $smtp['ssl'])->setUsername($smtp['username'])->setPassword($smtp['password']);
     return new \Swift_Mailer($transport);
 }
開發者ID:acelaya,項目名稱:alejandrocelaya.com,代碼行數:19,代碼來源:SwiftMailerFactory.php

示例8: __invoke

 /**
  * @param  ContainerInterface $container
  * @param  string $name
  * @param  null|array $options
  * @return DefaultRenderingStrategy
  */
 public function __invoke(ContainerInterface $container, $name, array $options = null)
 {
     $strategy = new DefaultRenderingStrategy($container->get(View::class));
     $config = $this->getConfig($container);
     $this->injectLayoutTemplate($strategy, $config);
     return $strategy;
 }
開發者ID:kuisatz,項目名稱:ustalarMerkezi,代碼行數:13,代碼來源:HttpDefaultRenderingStrategyFactory.php

示例9: __invoke

 public function __invoke(ContainerInterface $container)
 {
     if (!$container->has(Configuration::class) || !$container->has(EventManager::class) || !$container->has(Connection::class)) {
         throw new ContainerNotRegisteredException('Doctrine\\Common\\EventManager::class,
         Doctrine\\ORM\\Configuration::class and Doctrine\\DBAL\\Connection::class
         must be registered in the container');
     }
     $config = $container->has('config') ? $container->get('config') : [];
     $underscoreNamingStrategy = isset($config['doctrine']['orm']['underscore_naming_strategy']) ? $config['doctrine']['orm']['underscore_naming_strategy'] : false;
     /** @var Configuration $configuration */
     $configuration = $container->get(Configuration::class);
     $configuration->setProxyDir(isset($config['doctrine']['orm']['proxy_dir']) ? $config['doctrine']['orm']['proxy_dir'] : 'data/cache/EntityProxy');
     $configuration->setProxyNamespace(isset($config['doctrine']['orm']['proxy_namespace']) ? $config['doctrine']['orm']['proxy_namespace'] : 'EntityProxy');
     $configuration->setAutoGenerateProxyClasses(isset($config['doctrine']['orm']['auto_generate_proxy_classes']) ? $config['doctrine']['orm']['auto_generate_proxy_classes'] : false);
     // ORM mapping by Annotation
     AnnotationRegistry::registerFile('vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');
     $driver = new AnnotationDriver(new AnnotationReader(), ['data/cache/doctrine']);
     $configuration->setMetadataDriverImpl($driver);
     // Cache
     $cache = $container->get(Cache::class);
     $configuration->setQueryCacheImpl($cache);
     $configuration->setResultCacheImpl($cache);
     $configuration->setMetadataCacheImpl($cache);
     return EntityManager::create($container->get(Connection::class), $configuration, $container->get(EventManager::class));
 }
開發者ID:mobicms,項目名稱:expressive-doctrine,代碼行數:25,代碼來源:OrmFactory.php

示例10: __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

示例11: __invoke

 /**
  * @param ContainerInterface $container
  * @return ModuleVersioningModelFactory
  * @throws ServiceNotCreatedException
  */
 public function __invoke(ContainerInterface $container)
 {
     if (!$container->has(ConfigResourceFactory::class) || !$container->has(ModulePathSpec::class)) {
         throw new ServiceNotCreatedException(sprintf('%s is missing one or more dependencies from ZF\\Configuration', ModuleVersioningModelFactory::class));
     }
     return new ModuleVersioningModelFactory($container->get(ConfigResourceFactory::class), $container->get(ModulePathSpec::class));
 }
開發者ID:zfcampus,項目名稱:zf-apigility-admin,代碼行數:12,代碼來源:ModuleVersioningModelFactoryFactory.php

示例12: __construct

 /**
  * Constructor
  *
  * @param string $action Type of action to validate
  * @param ServerRequestInterface $request Request Http
  * @param ContainerInterface $container Dependency Injection
  */
 public function __construct($action, ServerRequestInterface $request, ContainerInterface $container)
 {
     $this->action = $action;
     $this->idUser = $request->getAttribute('id');
     $this->data = $request->getParsedBody();
     $this->entityManager = $container->get('EntityManager');
 }
開發者ID:danielspk,項目名稱:tornadohttpskeletonapplication,代碼行數:14,代碼來源:UserValidator.php

示例13: __invoke

 public function __invoke(ContainerInterface $ci)
 {
     $settings = $ci->get('settings');
     $view = new Twig($settings['twig']['view_path'], $settings['twig']['settings']);
     $view->addExtension(new TwigExtension($ci['router'], $ci['request']->getUri()));
     return $view;
 }
開發者ID:renatoaraujo,項目名稱:slim-skeleton,代碼行數:7,代碼來源:TwigViewService.php

示例14: __invoke

 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $entityManager = $container->get('doctrine.entitymanager.orm_default');
     $config = $container->get('Config')['svycka_social_user'];
     $options = ['social_user_entity' => $config['social_user_entity']];
     return new Doctrine($entityManager, $options);
 }
開發者ID:svycka,項目名稱:social-user,代碼行數:7,代碼來源:DoctrineStorageFactory.php

示例15: __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


注:本文中的Interop\Container\ContainerInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。