本文整理匯總了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);
}
}
示例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);
}
示例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();
}
示例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;
}
示例6: up
public function up(Schema $schema, QueryBag $queries)
{
$sqls = $this->container->get('test_service')->getQueries();
foreach ($sqls as $sql) {
$queries->addQuery($sql);
}
}
示例7: getClient
public function getClient()
{
if ($this->client === null) {
$this->client = $this->container->get($this->clientServiceId);
}
return $this->client;
}
示例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);
}
}
示例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);
}
示例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')
);
}
示例11: setUpSymfonyKernel
/**
* @before
*
*/
protected function setUpSymfonyKernel()
{
$this->kernel = $this->createKernel();
$this->kernel->boot();
$this->container = $this->kernel->getContainer();
$this->logger = $this->container->get('logger');
}
示例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');
}
示例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');
}
示例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')
);
}
示例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;
}