本文整理匯總了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;
}
示例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;
}
示例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);
}
}
示例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');
}
示例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()));
}
示例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');
}
}
示例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;
}
示例8: enterScope
public function enterScope()
{
if (!$this->container->isScopeActive('scenario')) {
$this->container->enterScope('scenario');
}
}
示例9: enterScope
/**
* {@inheritdoc}
*/
public function enterScope($name)
{
$this->container->enterScope($name);
}
示例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);
}
}