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


PHP ContainerInterface::enterScope方法代碼示例

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


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

示例1: getReflectionMethod

 /**
  * Returns the ReflectionMethod for the given controller string.
  *
  * @param string $controller
  * @return \ReflectionMethod|null
  */
 public function getReflectionMethod($controller)
 {
     if (false === strpos($controller, '::') && 2 === substr_count($controller, ':')) {
         $controller = $this->controllerNameParser->parse($controller);
     }
     if (preg_match('#(.+)::([\\w]+)#', $controller, $matches)) {
         $class = $matches[1];
         $method = $matches[2];
     } elseif (preg_match('#(.+):([\\w]+)#', $controller, $matches)) {
         $controller = $matches[1];
         $method = $matches[2];
         if ($this->container->has($controller)) {
             $this->container->enterScope('request');
             $this->container->set('request', new Request(), 'request');
             $class = ClassUtils::getRealClass(get_class($this->container->get($controller)));
             $this->container->leaveScope('request');
         }
     }
     if (isset($class) && isset($method)) {
         try {
             return new \ReflectionMethod($class, $method);
         } catch (\ReflectionException $e) {
         }
     }
     return null;
 }
開發者ID:eliberty,項目名稱:api-bundle,代碼行數:32,代碼來源:DocumentationHelper.php

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

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

示例4: getTemplating

 /**
  * Retrieves templating service
  *
  * @return \Symfony\Bundle\FrameworkBundle\Templating\DelegatingEngine
  */
 public function getTemplating()
 {
     if (defined('IN_MAUTIC_CONSOLE')) {
         //enter the request scope in order to be use the templating.helper.assets service
         $this->container->enterScope('request');
         $this->container->set('request', new Request(), 'request');
     }
     return $this->container->get('templating');
 }
開發者ID:Jandersolutions,項目名稱:mautic,代碼行數:14,代碼來源:MauticFactory.php

示例5: execute

 /**
  * {@inheritDoc}
  *
  * @param InputInterface  $input  input
  * @param OutputInterface $output output
  *
  * @return void
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     /**
      * somehow as the swagger spec generation digs deep in the utils/router stuff,
      * somewhere Request is needed.. so we need to enter the request scope
      * manually.. maybe there is another possibility for this?
      */
     $this->container->enterScope('request');
     $this->container->set('request', new Request(), 'request');
     $this->filesystem->dumpFile($this->rootDir . '/../web/swagger.json', json_encode($this->apidoc->getSwaggerSpec()));
 }
開發者ID:alebon,項目名稱:graviton,代碼行數:19,代碼來源:SwaggerGenerateCommand.php

示例6: enterRequestScope

 /**
  * Enter request scope if it is not active yet...
  *
  * @param string $lang
  */
 protected function enterRequestScope($lang)
 {
     if (!$this->container->isScopeActive('request')) {
         $this->container->enterScope('request');
         $request = new Request();
         $request->setLocale($lang);
         $major = Kernel::MAJOR_VERSION;
         $minor = Kernel::MINOR_VERSION;
         if ((int) $major > 2 || (int) $major == 2 && (int) $minor >= 4) {
             $requestStack = $this->container->get('request_stack');
             $requestStack->push($request);
         }
         $this->container->set('request', $request, 'request');
     }
 }
開發者ID:evgemar,項目名稱:KunstmaanBundlesCMS,代碼行數:20,代碼來源:NodePagesConfiguration.php

示例7: getReflectionMethod

 /**
  * Returns the ReflectionMethod for the given controller string.
  *
  * @param string $controller
  * @return \ReflectionMethod|null
  */
 public function getReflectionMethod($controller)
 {
     if (preg_match('#(.+)::([\\w]+)#', $controller, $matches)) {
         $class = $matches[1];
         $method = $matches[2];
     } elseif (preg_match('#(.+):([\\w]+)#', $controller, $matches)) {
         $controller = $matches[1];
         $method = $matches[2];
         if ($this->container->has($controller)) {
             $this->container->enterScope('request');
             $this->container->set('request', new Request(), 'request');
             $class = get_class($this->container->get($controller));
             $this->container->leaveScope('request');
         }
     }
     if (isset($class) && isset($method)) {
         try {
             return new \ReflectionMethod($class, $method);
         } catch (\ReflectionException $e) {
         }
     }
     return null;
 }
開發者ID:ashutosh-srijan,項目名稱:findit_akeneo,代碼行數:29,代碼來源:ApiDocExtractor.php

示例8: enterScope

 public function enterScope()
 {
     if (!$this->container->isScopeActive('scenario')) {
         $this->container->enterScope('scenario');
     }
 }
開發者ID:ReissClothing,項目名稱:Sylius,代碼行數:6,代碼來源:ScopeManipulator.php

示例9: enterScope

 /**
  * {@inheritdoc}
  */
 public function enterScope($name)
 {
     $this->container->enterScope($name);
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:7,代碼來源:ContainerProxy.php

示例10: onKernelRequest

 /**
  * Enters the container scope when a route has been found.
  *
  * @param GetResponseEvent $event The event object
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (null !== ($scope = $this->getScopeFromEvent($event))) {
         $this->container->enterScope($scope);
     }
 }
開發者ID:bytehead,項目名稱:core-bundle,代碼行數:11,代碼來源:ContainerScopeListener.php


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