當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。