leaveScope() public method

Leaves the current scope, and re-enters the parent scope
public leaveScope ( string $name ) : void
$name string
return void
 /**
  * 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;
 }
 /**
  * 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;
 }
 public function leaveScope()
 {
     if ($this->container->isScopeActive('scenario')) {
         $this->container->leaveScope('scenario');
     }
 }
Beispiel #4
0
 /**
  * {@inheritdoc}
  */
 public function leaveScope($name)
 {
     $this->container->leaveScope($name);
 }
 /**
  * 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);
     }
 }