本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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']);
}
示例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);
}
示例6: __construct
public function __construct(FrameBuffer $frameBuffer, ContainerInterface $container)
{
$this->frameBuffer = $frameBuffer;
$this->container = $container;
$this->bitmapLoader = $container->get(BitmapLoader::class);
$this->sprites = [];
}
示例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);
}
示例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;
}
示例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));
}
示例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));
}
示例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));
}
示例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');
}
示例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;
}
示例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);
}
示例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;
}