php Symfony-Component-DependencyInjection-ContainerInterface类(方法)实例源码

下面列出了php Symfony-Component-DependencyInjection-ContainerInterface 类(方法)源码代码实例,从而了解它的用法。

作者:clarolin    项目:distributio   
/**
  * @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();
 }

作者:ruia    项目:EWZRecaptchaBundl   
/**
  * 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');
 }

作者:alehers    项目:Syliu   
public function setContainer(ContainerInterface $container = null)
 {
     if (null !== $container) {
         $this->container = $container;
         $this->defaultLocale = $container->getParameter('sylius.locale');
     }
 }

作者:clarolin    项目:distributio   
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');
 }

作者:rafavergar    项目:ddv   
/**
  * {@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'));
 }

作者:dongilber    项目:mauti   
/**
  * {@inheritdoc}
  */
 public function setContainer(ContainerInterface $container = null)
 {
     $this->container = $container;
     $this->prefix = $container->getParameter('mautic.db_table_prefix');
     $this->platform = $this->connection->getDatabasePlatform()->getName();
     $this->factory = $container->get('mautic.factory');
 }

作者:dasklne    项目:kret   
function it_deletes_participant(ContainerInterface $container, ParticipantRepository $participantRepository, ParticipantInterface $participant)
 {
     $container->get('kreta_project.repository.participant')->shouldBeCalled()->willReturn($participantRepository);
     $participantRepository->findOneBy(['project' => 'project-id', 'user' => 'user-id'], false)->shouldBeCalled()->willReturn($participant);
     $participantRepository->remove($participant)->shouldBeCalled();
     $this->deleteParticipantsAction('project-id', 'user-id');
 }

作者:jrezig    项目:portfoli   
public function __construct($translationMap, $requestStack, ContainerInterface $container)
 {
     $this->requestStack = $requestStack;
     $this->session = $container->get('session');
     $this->container = $container;
     $this->translationMap = $translationMap["front_map"];
 }

作者:geoffreytra    项目:zy   
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);
     }
 }

作者:CG7    项目:ezpublish-kerne   
/**
  * @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);
 }

作者:eric19    项目:turbulent-wooki   
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;
 }

作者:Maksol    项目:platfor   
public function up(Schema $schema, QueryBag $queries)
 {
     $sqls = $this->container->get('test_service')->getQueries();
     foreach ($sqls as $sql) {
         $queries->addQuery($sql);
     }
 }

作者:skr    项目:bunny-bundl   
public function getClient()
 {
     if ($this->client === null) {
         $this->client = $this->container->get($this->clientServiceId);
     }
     return $this->client;
 }

作者:amin198    项目:Beha   
/**
  * {@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);
 }

作者:binaryfr3a    项目:sfitix   
/**
  * @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());
     }
 }

作者:boske    项目:BeSimpleSoapBundl   
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);
 }

作者:dongilber    项目:mauti   
/**
  * @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);
     }
 }

作者:ismailbaski    项目:HWIOAuthBundl   
/**
  * 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);
 }

作者:dongilber    项目:mauti   
/**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $factory = $this->container->get('mautic.factory');
     $repo = $factory->getModel('page.page')->getRepository();
     $pages = CsvHelper::csv_to_array(__DIR__ . '/fakepagedata.csv');
     foreach ($pages as $count => $rows) {
         $page = new Page();
         $key = $count + 1;
         foreach ($rows as $col => $val) {
             if ($val != 'NULL') {
                 $setter = 'set' . ucfirst($col);
                 if (in_array($col, ['translationParent', 'variantParent'])) {
                     $page->{$setter}($this->getReference('page-' . $val));
                 } elseif (in_array($col, ['dateAdded', 'variantStartDate'])) {
                     $page->{$setter}(new \DateTime($val));
                 } elseif (in_array($col, ['content', 'variantSettings'])) {
                     $val = unserialize(stripslashes($val));
                     $page->{$setter}($val);
                 } else {
                     $page->{$setter}($val);
                 }
             }
         }
         $page->setCategory($this->getReference('page-cat-1'));
         $repo->saveEntity($page);
         $this->setReference('page-' . $key, $page);
     }
 }

作者:CarnegieLearningWe    项目:ldap-orm-bundl   
/**
  * @before
  *
  */
 protected function setUpSymfonyKernel()
 {
     $this->kernel = $this->createKernel();
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     $this->logger = $this->container->get('logger');
 }


问题


面经


文章

微信
公众号

扫码关注公众号