本文整理匯總了PHP中Symfony\Component\DependencyInjection\ContainerInterface::leaveScope方法的典型用法代碼示例。如果您正苦於以下問題:PHP ContainerInterface::leaveScope方法的具體用法?PHP ContainerInterface::leaveScope怎麽用?PHP ContainerInterface::leaveScope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\DependencyInjection\ContainerInterface
的用法示例。
在下文中一共展示了ContainerInterface::leaveScope方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: 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;
}
示例3: leaveScope
public function leaveScope()
{
if ($this->container->isScopeActive('scenario')) {
$this->container->leaveScope('scenario');
}
}
示例4: leaveScope
/**
* {@inheritdoc}
*/
public function leaveScope($name)
{
$this->container->leaveScope($name);
}
示例5: onKernelFinishRequest
/**
* Leaves the container scope when finishing the request.
*
* @param FinishRequestEvent $event The event object
*/
public function onKernelFinishRequest(FinishRequestEvent $event)
{
if (null !== ($scope = $this->getScopeFromEvent($event))) {
$this->container->leaveScope($scope);
}
}