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


PHP ContainerInterface::get方法代碼示例

本文整理匯總了PHP中Symfony\Component\DependencyInjection\ContainerInterface::get方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerInterface::get方法的具體用法?PHP ContainerInterface::get怎麽用?PHP ContainerInterface::get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\DependencyInjection\ContainerInterface的用法示例。


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

示例1: up

 /**
  * @param Schema $schema
  */
 public function up(Schema $schema)
 {
     $jobInstanceRepo = $this->container->get('pim_import_export.repository.job_instance');
     $channelRepo = $this->container->get('pim_catalog.repository.channel');
     $entityManager = $this->container->get('doctrine.orm.entity_manager');
     $validator = $this->container->get('validator');
     $jobInstances = $jobInstanceRepo->findBy(['type' => 'export']);
     foreach ($jobInstances as $jobInstance) {
         $parameters = $jobInstance->getRawParameters();
         // Only product exports have a parameter named 'channel'
         if (isset($parameters['channel'])) {
             $channel = $channelRepo->findOneByIdentifier($parameters['channel']);
             if (null === $channel) {
                 continue;
             }
             $locales = $channel->getLocales();
             $localeCodes = [];
             foreach ($locales as $locale) {
                 $localeCodes[] = $locale->getCode();
             }
             $parameters['filters'] = ['data' => [['field' => 'enabled', 'operator' => '=', 'value' => true], ['field' => 'categories.code', 'operator' => 'IN CHILDREN', 'value' => [$channel->getCategory()->getCode()]], ['field' => 'completeness', 'operator' => '>=', 'value' => 100]], 'structure' => ['scope' => $channel->getCode(), 'locales' => $localeCodes]];
             unset($parameters['channel']);
             $jobInstance->setRawParameters($parameters);
             $errors = $validator->validate($jobInstance);
             if (count($errors) === 0) {
                 $entityManager->persist($jobInstance);
                 $entityManager->flush();
             }
         }
     }
 }
開發者ID:a2xchip,項目名稱:pim-community-dev,代碼行數:34,代碼來源:Version_1_6_20160726103445_update_product_export_parameters.php

示例2: 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

示例3: 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

示例4: load

 /**
  * Load the fixture jobs in database
  *
  * @return null
  */
 public function load()
 {
     $rawJobs = array();
     $fileLocator = $this->container->get('file_locator');
     foreach ($this->jobsFilePaths as $jobsFilePath) {
         $realPath = $fileLocator->locate('@' . $jobsFilePath);
         $this->reader->setFilePath($realPath);
         // read the jobs list
         while ($rawJob = $this->reader->read()) {
             $rawJobs[] = $rawJob;
         }
         // sort the jobs by order
         usort($rawJobs, function ($item1, $item2) {
             if ($item1['order'] === $item2['order']) {
                 return 0;
             }
             return $item1['order'] < $item2['order'] ? -1 : 1;
         });
     }
     // store the jobs
     foreach ($rawJobs as $rawJob) {
         unset($rawJob['order']);
         $job = $this->processor->process($rawJob);
         $config = $job->getRawConfiguration();
         $config['filePath'] = sprintf('%s/%s', $this->installerDataPath, $config['filePath']);
         $job->setRawConfiguration($config);
         $this->em->persist($job);
     }
     $this->em->flush();
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:35,代碼來源:FixtureJobLoader.php

示例5: 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

示例6: 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

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

示例8: load

 /**
  * @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);
     }
 }
開發者ID:dongilbert,項目名稱:mautic,代碼行數:31,代碼來源:LoadPageData.php

示例9: 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

示例10: create

 /**
  * {@inheritdoc}
  */
 public static function create(ContainerInterface $container) {
   return new static(
     $container->get('module_handler'),
     $container->get('composer_manager.package_manager'),
     $container->get('string_translation')
   );
 }
開發者ID:nwdrupal,項目名稱:nwdrupalwebsite,代碼行數:10,代碼來源:PackageController.php

示例11: setUpSymfonyKernel

 /**
  * @before
  *
  */
 protected function setUpSymfonyKernel()
 {
     $this->kernel = $this->createKernel();
     $this->kernel->boot();
     $this->container = $this->kernel->getContainer();
     $this->logger = $this->container->get('logger');
 }
開發者ID:CarnegieLearningWeb,項目名稱:ldap-orm-bundle,代碼行數:11,代碼來源:SymfonyKernel.php

示例12: __construct

 /**
  * @param ContainerInterface $container
  */
 public function __construct(ContainerInterface $container)
 {
     $this->container = $container;
     $this->requestStack = $container->get('request_stack');
     $this->request = $this->getCurrentRequest();
     $this->dispatcher = $container->get('event_dispatcher');
 }
開發者ID:vigourouxjulien,項目名稱:thelia,代碼行數:10,代碼來源:CartPostage.php

示例13: initRepositories

 protected function initRepositories()
 {
     $doctrine = $this->container->get('doctrine');
     $this->countryRepository = $doctrine->getManagerForClass('OroAddressBundle:Country')->getRepository('OroAddressBundle:Country');
     $this->regionRepository = $doctrine->getManagerForClass('OroAddressBundle:Region')->getRepository('OroAddressBundle:Region');
     $this->addressTypeRepository = $doctrine->getManagerForClass('OroAddressBundle:AddressType')->getRepository('OroAddressBundle:AddressType');
 }
開發者ID:adam-paterson,項目名稱:orocommerce,代碼行數:7,代碼來源:AbstractLoadAddressDemoData.php

示例14: createInstance

 /**
  * {@inheritdoc}
  */
 public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
   return new static(
     $entity_type,
     $container->get('entity.manager')->getStorage($entity_type->id()),
     $container->get('scheduled_updates.update_utils')
   );
 }
開發者ID:joebachana,項目名稱:usatne,代碼行數:10,代碼來源:ScheduledUpdateListBuilder.php

示例15: matchItem

 /**
  * Checks whether an item is current.
  *
  * If the voter is not able to determine a result,
  * it should return null to let other voters do the job.
  *
  * @param \Knp\Menu\ItemInterface $item The item
  *
  * @return boolean|null
  */
 public function matchItem(ItemInterface $item)
 {
     if ($item->getUri() === $this->container->get('request')->getRequestUri()) {
         return true;
     }
     return false;
 }
開發者ID:rmzamora,項目名稱:bootstrap-bundle,代碼行數:17,代碼來源:RequestVoter.php


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