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


PHP DependencyInjection\ContainerInterface类代码示例

本文整理汇总了PHP中Symfony\Component\DependencyInjection\ContainerInterface的典型用法代码示例。如果您正苦于以下问题:PHP ContainerInterface类的具体用法?PHP ContainerInterface怎么用?PHP ContainerInterface使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __construct

 /**
  * @InjectParams({
  *     "container" = @Inject("service_container")
  * })
  */
 public function __construct(ContainerInterface $container)
 {
     $this->container = $container;
     $this->fileTypes = '/\\.yml$/';
     $this->driverPath = $container->getParameter('kernel.root_dir') . '/config/Authentication/';
     $this->finder = new Finder();
 }
开发者ID:claroline,项目名称:distribution,代码行数:12,代码来源:AuthenticationManager.php

示例2: __construct

 /**
  * Construct.
  *
  * @param ContainerInterface $container An ContainerInterface instance
  */
 public function __construct(ContainerInterface $container)
 {
     $this->publicKey = $container->getParameter('ewz_recaptcha.public_key');
     $this->secure = $container->getParameter('ewz_recaptcha.secure');
     $this->enabled = $container->getParameter('ewz_recaptcha.enabled');
     $this->language = $container->getParameter('session.default_locale');
 }
开发者ID:ruian,项目名称:EWZRecaptchaBundle,代码行数:12,代码来源:RecaptchaType.php

示例3: setContainer

 public function setContainer(ContainerInterface $container = null)
 {
     if (null !== $container) {
         $this->container = $container;
         $this->defaultLocale = $container->getParameter('sylius.locale');
     }
 }
开发者ID:aleherse,项目名称:Sylius,代码行数:7,代码来源:Version20141203091118.php

示例4: __construct

 public function __construct(ContainerInterface $container)
 {
     $this->om = $container->get('claroline.persistence.object_manager');
     $this->roleManager = $container->get('claroline.manager.role_manager');
     $this->userManager = $container->get('claroline.manager.user_manager');
     $this->conn = $container->get('doctrine.dbal.default_connection');
 }
开发者ID:claroline,项目名称:distribution,代码行数:7,代码来源:Updater030502.php

示例5: create

 /**
  * {@inheritdoc}
  */
 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 {
     // Create a new instance of the plugin. This also allows us to extract
     // services from the container and inject them into our plugin via its own
     // constructor as needed.
     return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager'), $container->get('link_generator'), $container->get('request_stack'), $container->get('juicebox.formatter'));
 }
开发者ID:rafavergara,项目名称:ddv8,代码行数:10,代码来源:JuiceboxFieldFormatter.php

示例6: addMenuItem

 protected function addMenuItem($menu, MenuItem $menuItem, $parent = null)
 {
     $container = $this->container;
     if (!($container->has('zym_menu.menu_manager') && $container->has('knp_menu.factory'))) {
         // ZymMenuBundle doesn't exist
         return;
     }
     /* @var $menuManager Entity\MenuManager */
     $menuManager = $this->container->get('zym_menu.menu_manager');
     /* @var $menuItemManager Entity\MenuItemManager */
     $menuItemManager = $this->container->get('zym_menu.menu_item_manager');
     // Management Menu
     $menu = $menuManager->findOneBy(array('name' => 'management'));
     if ($menu === null) {
         return;
     }
     $existingMenuItem = $menuItemManager->findMenuItemByName($menu, $menuItem->getName());
     if ($existingMenuItem instanceof Entity\MenuItem) {
         return;
     }
     if ($parent !== null) {
         $parentMenuItem = $menuItemManager->findMenuItemByName($menu, $parent);
         if ($parentMenuItem === null) {
             return;
         }
         $parentMenuItem->addChild($menuItem);
         $menuItemManager->createMenuItem($menuItem);
         $menuItemManager->saveMenuItem($parentMenuItem);
     } else {
         $menu->addChild($menuItem);
         $menuItemManager->createMenuItem($menuItem);
         $menuManager->saveMenu($menu);
     }
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:34,代码来源:LoadMenuData.php

示例7: getMatcher

 /**
  * @param string $matcherIdentifier
  *
  * @return \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MatcherInterface
  */
 protected function getMatcher($matcherIdentifier)
 {
     if ($this->container->has($matcherIdentifier)) {
         return $this->container->get($matcherIdentifier);
     }
     return parent::getMatcher($matcherIdentifier);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:12,代码来源:ContentMatcherFactory.php

示例8: convertFromLoanApp

 public function convertFromLoanApp(LoanApplication $application)
 {
     $this->em->detach($application);
     $vantage = $this->formatVantage($application);
     $applicationXml = $this->container->get('templating')->render('SudouxMortgageBundle:LoanApplicationAdmin/formats:vantageFull.xml.twig', array('application' => $vantage), 'text/xml');
     return $applicationXml;
 }
开发者ID:eric19h,项目名称:turbulent-wookie,代码行数:7,代码来源:VantageFormat.php

示例9: up

 public function up(Schema $schema, QueryBag $queries)
 {
     $sqls = $this->container->get('test_service')->getQueries();
     foreach ($sqls as $sql) {
         $queries->addQuery($sql);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:7,代码来源:Test2BundleMigration10.php

示例10: getClient

 public function getClient()
 {
     if ($this->client === null) {
         $this->client = $this->container->get($this->clientServiceId);
     }
     return $this->client;
 }
开发者ID:skrz,项目名称:bunny-bundle,代码行数:7,代码来源:BunnyManager.php

示例11: load

 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $model = $this->container->get('app_module_notebook.model.note');
     $modelTag = $this->container->get('app_module_notebook.model.noteTag');
     $entity = new Note();
     $entity->setNotebook($this->getReference(sprintf('notebook:%s:%s', 'Katie', 'Todo list')));
     $entity->setSubject('Close window at home');
     $entity->getTags()->add($modelTag->createOrGetTag('At home'));
     $model->save($entity);
     $entity = new Note();
     $entity->setNotebook($this->getReference(sprintf('notebook:%s:%s', 'Greg', 'Shopping list')));
     $entity->setSubject('Food for cat');
     $entity->getTags()->add($modelTag->createOrGetTag('Kitty'));
     $entity->getTags()->add($modelTag->createOrGetTag('Food'));
     $model->save($entity);
     $entity = new Note();
     $entity->setNotebook($this->getReference(sprintf('notebook:%s:%s', 'Greg', 'Shopping list')));
     $entity->setSubject('Food for cat');
     $entity->getTags()->add($modelTag->createOrGetTag('Doggy'));
     $entity->getTags()->add($modelTag->createOrGetTag('Food'));
     $model->save($entity);
     $entity = new Note();
     $entity->setNotebook($this->getReference(sprintf('notebook:%s:%s', 'Greg', 'Shopping list')));
     $entity->setSubject('Cheese');
     $entity->getTags()->add($modelTag->createOrGetTag('Food'));
     $entity->getTags()->add($modelTag->createOrGetTag('At home'));
     $model->save($entity);
     $entity = new Note();
     $entity->setNotebook($this->getReference(sprintf('notebook:%s:%s', 'Greg', 'Todo list')));
     $entity->setSubject('Write corporate scenarios at home');
     $entity->getTags()->add($modelTag->createOrGetTag('Food'));
     $entity->getTags()->add($modelTag->createOrGetTag('At home'));
     $model->save($entity);
 }
开发者ID:amin1984,项目名称:Behat,代码行数:37,代码来源:LoadNotes.php

示例12: logEntityChange

 /**
  * @param $action
  * @param \Doctrine\ORM\Mapping\ClassMetadata $meta
  * @param $entity
  */
 private function logEntityChange($action, \Doctrine\ORM\Mapping\ClassMetadata $meta, $entity)
 {
     $userToken = $this->container->get('security.context')->getToken();
     if (null !== $userToken) {
         $this->logger->info('Entity "' . $meta->getTableName() . '" with id: ' . $meta->getFieldValue($entity, $meta->getSingleIdentifierFieldName()) . ' ' . $action . ' by: ' . $this->container->get('security.context')->getToken()->getUsername());
     }
 }
开发者ID:binaryfr3ak,项目名称:sfitixi,代码行数:12,代码来源:EntityChangeListener.php

示例13: onKernelException

 public function onKernelException(GetResponseForExceptionEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $request = $event->getRequest();
     if (!in_array($request->getRequestFormat(), array('soap', 'xml'))) {
         return;
     } elseif ('xml' === $request->getRequestFormat() && '_webservice_call' !== $request->attributes->get('_route')) {
         return;
     }
     $attributes = $request->attributes;
     if (!($webservice = $attributes->get('webservice'))) {
         return;
     }
     if (!$this->container->has(sprintf('besimple.soap.context.%s', $webservice))) {
         return;
     }
     // hack to retrieve the current WebService name in the controller
     $request->query->set('_besimple_soap_webservice', $webservice);
     $exception = $event->getException();
     if ($exception instanceof \SoapFault) {
         $request->query->set('_besimple_soap_fault', $exception);
     }
     parent::onKernelException($event);
 }
开发者ID:boskee,项目名称:BeSimpleSoapBundle,代码行数:26,代码来源:SoapExceptionListener.php

示例14: load

 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $repo = $factory->getModel('page.page')->getRepository();
     $hits = CsvHelper::csv_to_array(__DIR__ . '/fakepagehitdata.csv');
     foreach ($hits as $count => $rows) {
         $hit = new Hit();
         foreach ($rows as $col => $val) {
             if ($val != 'NULL') {
                 $setter = 'set' . ucfirst($col);
                 if (in_array($col, ['page', 'ipAddress'])) {
                     $hit->{$setter}($this->getReference($col . '-' . $val));
                 } elseif (in_array($col, ['dateHit', 'dateLeft'])) {
                     $hit->{$setter}(new \DateTime($val));
                 } elseif ($col == 'browserLanguages') {
                     $val = unserialize(stripslashes($val));
                     $hit->{$setter}($val);
                 } else {
                     $hit->{$setter}($val);
                 }
             }
         }
         $repo->saveEntity($hit);
     }
 }
开发者ID:dongilbert,项目名称:mautic,代码行数:28,代码来源:LoadPageHitData.php

示例15: getResourceOwnerByName

 /**
  * Gets the appropriate resource owner given the name.
  *
  * @param string $name
  *
  * @return null|ResourceOwnerInterface
  */
 public function getResourceOwnerByName($name)
 {
     if (!$this->hasResourceOwnerByName($name)) {
         return null;
     }
     return $this->container->get('hwi_oauth.resource_owner.' . $name);
 }
开发者ID:ismailbaskin,项目名称:HWIOAuthBundle,代码行数:14,代码来源:ResourceOwnerMap.php


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