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


PHP ContainerInterface::isScopeActive方法代码示例

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


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

示例1: getLocale

 /**
  * @return string
  */
 public function getLocale()
 {
     if ($this->container !== null && $this->container->isScopeActive('request')) {
         return $this->container->get('request')->getLocale();
     }
     return $this->locale;
 }
开发者ID:rrehbeindoi,项目名称:TwigExtensionsBundle,代码行数:10,代码来源:AbstractLocaleAwareExtension.php

示例2: convert

 /**
  * {@inheritDoc}
  */
 public function convert(\ReflectionParameter $parameter, \ReflectionFunctionAbstract $method, $value, array $attributes = [])
 {
     if (!$this->container->isScopeActive('request') || !$this->container->has('request')) {
         throw new ConverterException('Could not convert Request parameter in not active "request" scope.');
     }
     return $this->container->get('request');
 }
开发者ID:Gtvar,项目名称:FivePercent-Converter,代码行数:10,代码来源:SymfonyRequestParameterConverter.php

示例3: __construct

 /**
  * Constructor
  * 
  * @param ContainerInterface $container
  */
 public function __construct($container)
 {
     $this->container = $container;
     if ($this->container->isScopeActive('request')) {
         $this->request = $this->container->get('request');
     }
 }
开发者ID:juanber84,项目名称:simplei18nbundle,代码行数:12,代码来源:Simplei18nExtension.php

示例4: getLocale

 public function getLocale()
 {
     if ($this->container->isScopeActive('request') && $this->container->has('request')) {
         return $this->container->get('request')->getSession()->getLang()->getLocale();
     }
     return $this->locale;
 }
开发者ID:badelas,项目名称:thelia,代码行数:7,代码来源:Translator.php

示例5: getGlobals

 /**
  * {@inheritDoc}
  */
 public function getGlobals()
 {
     if (!$this->container->isScopeActive('request')) {
         return array();
     }
     return array('require_js' => array('config' => $this->configurationBuilder->getConfiguration()));
 }
开发者ID:boskee,项目名称:HearsayRequireJSBundle,代码行数:10,代码来源:RequireJSExtension.php

示例6: onThreadCreate

 /**
  * Creates and persists a thread with the specified id.
  *
  * @param \FOS\CommentBundle\Event\ThreadEvent $event
  */
 public function onThreadCreate(ThreadEvent $event)
 {
     if (!$this->container->isScopeActive('request')) {
         return;
     }
     $thread = $event->getThread();
     $thread->setPermalink($this->container->get('request')->getUri());
 }
开发者ID:saberyounis,项目名称:Sonata-Project,代码行数:13,代码来源:ThreadPermalinkListener.php

示例7: getLocale

 /**
  * {@inheritdoc}
  */
 public function getLocale()
 {
     if ($this->container->isScopeActive('request')) {
         if ($request = $this->container->get('request', ContainerInterface::NULL_ON_INVALID_REFERENCE)) {
             return $request->getLocale();
         }
     }
     return $this->defaultLocale;
 }
开发者ID:elfen,项目名称:SonataIntlBundle,代码行数:12,代码来源:RequestDetector.php

示例8: getRequest

 /**
  * @return null|Request
  */
 private function getRequest()
 {
     if ($this->container->has('request_stack')) {
         return $this->container->get('request_stack')->getCurrentRequest();
     }
     if ($this->container->isScopeActive('request')) {
         return $this->container->get('request');
     }
     return;
 }
开发者ID:TomasVotruba,项目名称:SonataPageBundle,代码行数:13,代码来源:CmsManagerSelector.php

示例9: getLocale

 /**
  * Get the locale, either from the parent or from the container if available
  * or the default locale if one is set.
  *
  * @param array $parameters the request parameters
  *
  * @return string
  */
 protected function getLocale($parameters)
 {
     $locale = parent::getLocale($parameters);
     if ($locale) {
         return $locale;
     }
     if (is_null($this->container) || !$this->container->isScopeActive('request') || !($request = $this->container->get('request'))) {
         return $this->defaultLocale;
     }
     return $request->getLocale();
 }
开发者ID:symfony-cmf,项目名称:routing-extra-bundle,代码行数:19,代码来源:ContentAwareGenerator.php

示例10: postUpdate

 public function postUpdate(LifecycleEventArgs $arg)
 {
     if (!$this->container->isScopeActive('request')) {
         return;
     }
     if (!$this->container->get('security.context')->getToken()->isAuthenticated()) {
         return;
     }
     if ($arg->getDocument() instanceof Document\Article) {
         if ($arg->getDocument()->wereTranslationsModified()) {
             $this->notifyModification($arg->getDocument(), $arg->getDocumentManager());
         }
     }
 }
开发者ID:Cohros,项目名称:KnowledgeBase,代码行数:14,代码来源:UserActionListener.php

示例11: notify

 /**
  * @param Notification $notification
  * @return void
  */
 public function notify(Notification $notification)
 {
     if (!$this->container->isScopeActive('request')) {
         $this->container->enterScope('request');
         $this->container->set('request', new Request(), 'request');
     }
     $ticket = $this->loadTicket($notification);
     $changeList = $this->postProcessChangesList($notification);
     foreach ($this->watchersService->getWatchers($ticket) as $watcher) {
         $userType = $watcher->getUserType();
         $user = User::fromString($userType);
         $isOroUser = $user->isOroUser();
         if ($isOroUser) {
             $loadedUser = $this->oroUserManager->findUserBy(['id' => $user->getId()]);
         } else {
             $loadedUser = $this->diamanteUserRepository->get($user->getId());
         }
         if (!$isOroUser && $notification->isTagUpdated()) {
             continue;
         }
         $message = $this->message($notification, $ticket, $isOroUser, $loadedUser->getEmail(), $changeList);
         $this->mailer->send($message);
         $reference = new MessageReference($message->getId(), $ticket, $this->configManager->get(self::EMAIL_NOTIFIER_CONFIG_PATH));
         $this->messageReferenceRepository->store($reference);
     }
 }
开发者ID:jalopezsuarez,项目名称:diamantedesk-application,代码行数:30,代码来源:EmailNotifier.php

示例12: isolateEnvironment

 /**
  * {@inheritdoc}
  */
 public function isolateEnvironment(Environment $uninitializedEnvironment, $testSubject = null)
 {
     if (!$uninitializedEnvironment instanceof UninitializedContextServiceEnvironment) {
         throw new EnvironmentIsolationException(sprintf('ContextServiceEnvironmentHandler does not support isolation of `%s` environment.', get_class($uninitializedEnvironment)), $uninitializedEnvironment);
     }
     if (!$this->container->isScopeActive('scenario')) {
         $this->container->enterScope('scenario');
     }
     $environment = new InitializedContextEnvironment($uninitializedEnvironment->getSuite());
     foreach ($uninitializedEnvironment->getContextsServicesIds() as $serviceId) {
         /** @var Context $context */
         $context = $this->container->get($serviceId);
         $environment->registerContext($context);
     }
     return $environment;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:19,代码来源:ContextServiceEnvironmentHandler.php

示例13: match

 /**
  * Tries to match a URL with a set of routes.
  *
  * Returns false if no route matches the URL.
  *
  * @param string $url URL to be parsed
  *
  * @return array|false An array of parameters or false if no route matches
  */
 public function match($url)
 {
     $params = $this->getMatcher()->match($url);
     if (false === $params) {
         throw new ResourceNotFoundException();
     }
     // No request. What append ?
     $currentLocale = null;
     if ($this->container->isScopeActive('request')) {
         $currentLocale = $this->localeResolver->resolveLocale($this->container->get('request'));
     }
     // Clean the route name
     if (false !== ($pos = strpos($params['_route'], I18nLoader::ROUTING_PREFIX))) {
         $params['_route'] = substr($params['_route'], $pos + strlen(I18nLoader::ROUTING_PREFIX));
     }
     // Retrieve all authorized locales for the given route
     $routeLocales = array();
     if (isset($params['_locale'])) {
         $routeLocales = array($params['_locale']);
     } elseif (isset($params['_locales'])) {
         $routeLocales = $params['_locales'];
         unset($params['_locales']);
     }
     if (0 === count($routeLocales) || in_array($currentLocale, $routeLocales)) {
         $params['_locale'] = $currentLocale;
         return $params;
     }
     throw new ResourceNotFoundException();
 }
开发者ID:AntoineLemaire,项目名称:BlablacarI18nRoutingBundle,代码行数:38,代码来源:Router.php

示例14: __construct

 /**
  * @param string $path
  */
 public function __construct(RackspaceContainer $container, ContainerInterface $serviceContainer)
 {
     $this->container = $container;
     if ($serviceContainer->hasScope('request') && $serviceContainer->isScopeActive('request') && $serviceContainer->has('request')) {
         $this->request = $serviceContainer->get('request');
     }
 }
开发者ID:geoffreytran,项目名称:zym,代码行数:10,代码来源:RackspaceCloudfiles.php

示例15: __construct

 /**
  * @param ContainerInterface $container
  * @param EntityManager $em
  */
 public function __construct(ContainerInterface $container, EntityManager $em)
 {
     if ($container->isScopeActive('request')) {
         $this->em = $em;
         $this->siteRequest = $container->get('sudoux.cms.site');
         $this->site = $this->siteRequest->getSite();
         $this->container = $container;
     }
 }
开发者ID:eric19h,项目名称:turbulent-wookie,代码行数:13,代码来源:NotificationExtension.php


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