Get scope name and scopeId

@return void
165273
private function initScope()
    {
        if ($this->getSection() === null) {
            $this->setSection('');
        }
        if ($this->getContainer() === null) {
            $this->setContainer('');
        }
        if ($this->getStore() === null) {
            $this->setStore('');
        }

        $scope = 'default';
        $scopeCode = 'default';

        if ($this->getStore()) {
            $scope = 'containers_stores';
            $store = $this->_storeManager->getStore($this->getStore());
            $scopeCode = $store->getId();
            if ($this->getContainer() && ($this->getContainer() != "")) {
                $scopeCode = $this->getContainer() . "|" . $scopeCode;
            }
        } elseif ($this->getContainer()) {
            $scope = 'containers';
            $container = $this->containersSource->get($this->getContainer());
            $scopeCode = $container['name'];
        }

        $this->setScope($scope);
        $this->setScopeCode($scopeCode);
        $this->setScopeId($scopeCode);
    }
1093628
public function getScopeValue($scope, $default = null)
    {
        if (is_string($scope)) {
            $scope = $this->getScope($scope);
        }

        $cacheKey = 'scope-'.$scope->scopeName;
        return $this->getSession($cacheKey, $default);
    }
283882
public function onFilterGetOptions()
    {
        $this->defineFilterScopes();

        $searchQuery = post('search');
        if (!$scopeName = post('scopeName')) {
            return;
        }

        $scope = $this->getScope($scopeName);
        $activeKeys = $scope->value ? array_keys($scope->value) : [];
        $available = $this->getAvailableOptions($scope, $searchQuery);
        $active = $searchQuery ? [] : $this->filterActiveOptions($activeKeys, $available);

        return [
            'scopeName' => $scopeName,
            'options' => [
                'available' => $this->optionsToAjax($available),
                'active'    => $this->optionsToAjax($active),
            ]
        ];
    }
426969
public function getName()
    {
        if (!$this->isEmpty($this->name)) {
            return $this->name;
        }

        foreach (['getName', 'getOriginalName'] as $fn) {
            $name = call_user_func([$this->event, $fn]);

            if ($this->isEmpty($name) || $name === $this) {
                continue;
            }

            if ($name instanceof self) {
                return $name = $name->getName();
            }
        }

        return $this->name = $this->parseEventName();
    }
585971
function getScopeInfo($currScope, $autoCreate = true) {
        $scopeKey = $this->scopeKey($currScope);
        if (!isset($this->_scopes[$scopeKey])) {
            if (!$autoCreate) {
                return null;
            }
            $this->_scopes[$scopeKey] = new ScopeInfo($currScope);
        }
        return $this->_scopes[$scopeKey];
    }
603184
public function getScopes(): array
    {
        if ($this->scopes === null) {
            $event = new RegisterScopesEvent([
                'scopes' => [
                    self::GLOBAL_SCOPE
                ]
            ]);

            $this->trigger(
                self::EVENT_REGISTER_SCOPES,
                $event
            );

            $this->scopes = $event->scopes;
        }

        return $this->scopes;
    }
215234
public function hasScope($scope)
    {
        if ($this->scopes === null) {
            $this->getScopes();
        }

        return isset($this->scopes[$scope]);
    }
982637
public function getName(): string
	{
		if( !$this->name )
		{
			$name = $this->getModule()->getKey();
			if( preg_match('/Controllers\\\\(.*?)$/', static::class, $e ) )
			{
				$name .= '::' . preg_replace_callback( '/[A-Z]/', static function( $m ) { return '_' . lcfirst( $m[0] ); }, lcfirst( $e[1] ) );
				$name  = str_replace( '\\', ':', $name );
			}
			$this->name = strtolower( $name );
		}

		return $this->name;
	}
639342
public function generateScopePhp()
    {

        $methodSignature = '';
        $paramsDoc       = '';
        $buildScope      = '';
        $buildScopeVars  = '';

        if ($this->hasMultipleScopes()) {

            $methodSignature = [];
            $buildScope      = [];
            $buildScopeVars  = [];
            $paramsDoc       = [];

            foreach ($this->getScopes() as $idx => $scope) {

                $column = $this->table->getColumn($scope);
                $param  = '$scope'.$column->getPhpName();

                $buildScope[]     = "    \$scope[] = $param;\n";
                $buildScopeVars[] = "    $param = \$scope[$idx];\n";
                $paramsDoc[]      = " * @param     ".$column->getPhpType()." $param Scope value for column `".$column->getPhpName()."`";

                if (!$column->isNotNull()) {
                    $param .= ' = null';
                }
                $methodSignature[] = $param;
            }

            $methodSignature = implode(', ', $methodSignature);
            $paramsDoc       = implode("\n", $paramsDoc);
            $buildScope      = "\n".implode('', $buildScope)."\n";
            $buildScopeVars  = "\n".implode('', $buildScopeVars)."\n";

        } elseif ($this->useScope()) {
            $methodSignature = '$scope';
            $column = $this->table->getColumn($this->getParameter('scope_column'));
            if ($column) {
                if (!$column->isNotNull()) {
                    $methodSignature .= ' = null';
                }
                $paramsDoc .= ' * @param '.$column->getPhpType().' $scope Scope to determine which objects node to return';
            }
        }

        return [$methodSignature, $paramsDoc, $buildScope, $buildScopeVars];
    }
963231
protected function _getScopes($scopes = [])
    {
        if ($scopes) {
            $returnScopes = [];
            foreach ($scopes as $scope) {
                $returnScopes[$scope] = $this->_scopes[$scope];
            }
            return $returnScopes;
        } else {
            return $this->_scopes;
        }
    }
277402
protected function getScopeCounts()
    {
        if ( ! $this->areScopesEnabled()) {
            return [];
        }

        $info = $this->getModelInformation();

        if ( ! $info->list->scopes || ! count($info->list->scopes)) {
            // @codeCoverageIgnoreStart
            return [];
            // @codeCoverageIgnoreEnd
        }

        $counts = [];

        $repository = $this->getModelRepository();

        foreach (array_keys($info->list->scopes) as $key) {

            $this->applyScope($repository, $key);

            $query = $this->getModelRepository()->query();

            $this->applyListParentToQuery($query);

            $counts[ $key ] = $query->count();
        }

        return $counts;
    }
969195
protected function _initScopes()
    {
        foreach ((array)$this->config('queryScope') as $className) {
            if (!empty($this->_queryScopes[$className])) {
                continue;
            }

            if (class_exists($className)) {
                $instance = new $className($this->_table);
                if ($instance instanceof QueryScopeInterface) {
                    $this->_queryScopes[$className] = $instance;
                }
            }
        }
    }
739791
public function getScope() {
		$calledHere = $this->backTrace[$this->backTraceOffset+1];

		if (isset($calledHere['class'])) {
			return (object) array(
				'type' => 'Method',
				'name' => $calledHere['class'].$calledHere['type'].$calledHere['function']
			);
		} elseif(isset($calledHere['function'])) {
			return (object) array(
				'type' => 'Function',
				'name' => $calledHere['function']
			);
		} else {
			return (object) array(
				'type' => 'global'
			);
		}
	}
58884
public function getTableName() {
		if ($this->name === null) {
			$this->name = lcfirst($this->getIntrospectiveData()->name);
		}

		return $this->name;
	}
379925
public function getName()
    {
        $name = $this->reflection->getName();

        if (strpos($name, '{closure}') !== false)
        {
            return null;
        }

        return $name;
    }
657179
private function getScopesByCode($scopeType)
    {
        $scopesByType = [];

        if ($scopeType == ScopeInterface::SCOPE_STORES) {
            $scopesByType = $this->storeManager->getStores(false, true);
        }

        if ($scopeType == ScopeInterface::SCOPE_WEBSITES) {
            $scopesByType = $this->storeManager->getWebsites(false, true);
        }

        return $scopesByType;
    }
626238
public function getId($idScope = null)
    {
        if (empty($idScope)) {
            if (!is_null($this->resourceLink)) {
                $idScope = $this->resourceLink->getConsumer()->id_scope;
            } else {
                $idScope = ToolProvider::ID_SCOPE_ID_ONLY;
            }
        }
        switch ($idScope) {
            case ToolProvider::ID_SCOPE_GLOBAL:
                $id = $this->resourceLink->getKey() . ToolProvider::ID_SCOPE_SEPARATOR . $this->id;
                break;
            case ToolProvider::ID_SCOPE_CONTEXT:
                $id = $this->resourceLink->getKey();
                if ($this->resourceLink->lti_context_id) {
                    $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->resourceLink->lti_context_id;
                }
                $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->id;
                break;
            case ToolProvider::ID_SCOPE_RESOURCE:
                $id = $this->resourceLink->getKey();
                if ($this->resourceLink->lti_resource_id) {
                    $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->resourceLink->lti_resource_id;
                }
                $id .= ToolProvider::ID_SCOPE_SEPARATOR . $this->id;
                break;
            default:
                $id = $this->id;
                break;
        }

        return $id;
    }