本文整理匯總了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();
}
示例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');
}
示例3: setContainer
public function setContainer(ContainerInterface $container = null)
{
if (null !== $container) {
$this->container = $container;
$this->defaultLocale = $container->getParameter('sylius.locale');
}
}
示例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');
}
示例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'));
}
示例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);
}
}
示例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);
}
示例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;
}
示例9: up
public function up(Schema $schema, QueryBag $queries)
{
$sqls = $this->container->get('test_service')->getQueries();
foreach ($sqls as $sql) {
$queries->addQuery($sql);
}
}
示例10: getClient
public function getClient()
{
if ($this->client === null) {
$this->client = $this->container->get($this->clientServiceId);
}
return $this->client;
}
示例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);
}
示例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());
}
}
示例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);
}
示例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);
}
}
示例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);
}