Get all session data and clean them.

@param   string $namespace Session namespace, default is `default`.

@return  array
@throws \RuntimeException

@since   2.0.4
552545
public function takeAll($namespace = 'default')
    {
        if ($this->state !== static::STATE_ACTIVE && $this->state !== static::STATE_EXPIRED) {
            if ($this->debug) {
                throw new \RuntimeException('Session is not active.');
            }

            return false;
        }

        $bag = $this->getBag($namespace);
        $all = $bag->all();

        $this->clean($namespace);

        return $all;
    }
613820
public function resolveMethod(string $namespace, string $method) : array
    {
        $class = $this->reflection->setClass($namespace)->getReflectionClass();

        if (!method_exists($namespace, $method)) {
            throw new \RuntimeException("Method $method doesn't exists in $namespace class");
        }
        $arguments = $class->getMethod($method)->getParameters();
        $methodArgs = $this->createMethodArgument($arguments);

        return array_filter($methodArgs);
    }
694477
protected function loadDataForPrefix($namespace, $prefix)
    {
        $this->failOnMissingNamespace($namespace);

        if (!isset($this->cachedData[$namespace])) {
            $this->cachedData[$namespace] = [];
        }

        if (!isset($this->cachedData[$namespace][$prefix])) {
            $this->cachedData[$namespace][$prefix] = [];
        }

        foreach ($this->addedData[$namespace] as $data) {

            if (isset($data[$prefix])) {
                $this->cachedData[$namespace][$prefix][] = $data[$prefix];
            }
        }

        return $this->cachedData[$namespace][$prefix];
    }
19624
public function policies($namespace = null)
    {
        if (is_null($namespace)) {
            $namespace = config('sleeping_owl.policies_namespace', '\\App\\Policies\\');
        }

        $policies = [];
        $preparedPolicies = collect($this->policies);

        foreach ($this->sections as $model => $section) {
            if ($preparedPolicies->has($section)) {
                $policies[$section] = $preparedPolicies->get($section);
                continue;
            }

            $policies[$section] = $namespace.class_basename($section).'SectionModelPolicy';
        }

        return $policies;
    }
391439
public function clearNamespace($namespace)
    {
        $paths = $this->getNamespaceDefaultPaths($namespace);
        foreach ($paths as $path) {
            if ($this->files->isDirectory($path)) {
                $this->files->deleteDirectory($path);
            }
        }
    }
982737
protected function filterByNamespace($namespace)
    {
        return function ($file) use ($namespace) {
            $content = file_get_contents($file);
            $tokens = token_get_all($content);

            $count = count($tokens);
            $token_namespace = null;

            for ($i = 0; $i < $count; ++$i) {
                $token = $tokens[$i];

                if (is_array($token) && $token[0] === T_NAMESPACE) {
                    $token_namespace .= '\\';
                    while (++$i < $count) {
                        if ($tokens[$i] === ';') {
                            $namespace = trim($namespace);
                            break;
                        }
                        $token_namespace .= is_array($tokens[$i]) ? trim($tokens[$i][1]) : '';
                    }

                    if ($token_namespace !== $namespace) {
                        return false;
                    }

                    break;
                }
            }

            if (!isset($token_namespace)) {
                return false;
            }
        };
    }
252826
public function getNamespace()
    {
        if (!isset($this->namespace)) {
            $reflectionClass = new \ReflectionClass($this->name);
            $this->namespace = $reflectionClass->getNamespaceName();
        }
        return $this->namespace;
    }
1089578
static function setCache($namespace)
    {
        $cacheData = [];
        $data = CommonConfigModel::getConfigByNamespace($namespace);
        foreach ($data as $key => $value) {
            $cacheData[$value['name']] = [
                'value'=>self::_getInfo($value['vtype'], $value['value']),
                'issystem'=>$value['issystem'],
                'desc'=>$value['desc']
            ];
        }
        $cacheName = 'config:'.$namespace;
        Cache::forever($cacheName, $cacheData);
        return $cacheData;
    }
305385
public function remove($name, $namespace = 'default')
    {
        if ($this->state !== static::STATE_ACTIVE && $this->state !== static::STATE_EXPIRED) {
            if ($this->debug) {
                throw new \RuntimeException('Session is not active.');
            }

            return false;
        }

        $this->getBag($namespace)->set($name, null);

        return $this;
    }
1156232
public function getFrom($namespace, $key = null, $default = null)
    {
        if (isset($_SESSION[$namespace])) {
            $oldNamespace = $this->namespace;
            $this->setNamespace($namespace);
            $result = $this->get($key, $default);
            $this->setNamespace($oldNamespace);

            return $result;
        }
        return $default;
    }
4950
public static function getNamespaceDefaultClass($namespace, $defaultNamespace) {
        if (strpos($namespace, $defaultNamespace) === 0) {
            $namespace = substr($namespace, strlen($defaultNamespace));
        }

        $defaults = self::$_config['defaults'];
        $controller = $defaults[str_replace('\\', '/', $namespace)];

        if (!$controller) {
            $controller = $defaults['*'] ? $defaults['*'] : 'Index';
        }

        return $controller;
    }
573668
private function setupNamespace($namespace)
	{
		if(!is_null($namespace)) {
			if(!isset($_SESSION[$namespace]) || !is_array($_SESSION[$namespace])) {
				$_SESSION[$namespace] = array();
			}
			$this->data = &$_SESSION[$namespace];
		} else {
			$this->data = &$_SESSION;
		}
	}
1169123
public static function namespaceAll(array $permissions, string $namespace) : array
    {
        InvalidArgumentException::verifyAllInstanceOf(__METHOD__, 'permissions', $permissions, IPermission::class);

        $namespacedPermissions = [];

        foreach ($permissions as $permission) {
            $permission = $permission->inNamespace($namespace);

            $namespacedPermissions[$permission->getName()] = $permission;
        }

        return $namespacedPermissions;
    }
1056887
static private function &sessionArray()
    {
        if ( self::$namespace !== null )
        {
            if ( !isset( $_SESSION[self::$namespace] ) )
                $_SESSION[self::$namespace] = array();
            return $_SESSION[self::$namespace];
        }
        return $_SESSION;
    }
767456
public function getSession(): ISession
    {
        if ($this->session === null) {
            if (!isset($this->implicit['session'])) {
                throw new \RuntimeException('The default session storage was not set');
            }
            $this->session = new Session($this->getCollector()->getSessionHandler($this->implicit['session']));
        }

        return $this->session;
    }
785034
public function getUserdata($key, $namespace)
    {
        $ret = $this->read($key, $namespace);

        list(,, $userdata) = $ret;
        return $userdata;
    }
516513
public function getBatchSerial($namespace) {
        if (empty($this->serials[$namespace])) {
            $batch = $this->getBatch($namespace);
            unset($batch['DefinitionRev']);
            $this->serials[$namespace] = md5(serialize($batch));
        }
        return $this->serials[$namespace];
    }