当前位置: 首页>>代码示例>>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;未经允许,请勿转载。