@inheritdoc

@param $context

@return string|null

@throws Exception\InvalidContextException
171293
public function buildContextKey($context)
    {
        $className = $context;
        if (is_object($context)) {
            $className = get_class($context);
        }

        if (!is_string($className)) {
            $errMsg = sprintf(
                'Context of type %s is invalid; Context not string.',
                (is_object($context) ? get_class($context) : gettype($context))
            );
            throw new Exception\InvalidContextException($errMsg);
        }

        $contextKey = null;
        $moduleOptionsPluginManager = $this->getModuleOptionsPluginManager();
        if ($moduleOptionsPluginManager->hasModuleNameByClassName($className)) {
            $contextKey = $moduleOptionsPluginManager->getNormalizeModuleNameByClassName($className);
        }

        return $contextKey;
    }
787899
protected function _getHandler(Context $context)
  {
    $conditions = $this->_generateRoutes();
    if(is_iterable($conditions))
    {
      return $this->_traverseConditions($context, $conditions);
    }
    else if($conditions instanceof Handler || is_callable($conditions) || is_string($conditions))
    {
      return $conditions;
    }

    return null;
  }
694395
protected function getConnection($context)
    {
        $connectionName = null;

        if (!empty($context['options']['db_connection_name'])) {
            $connectionName = $context['options']['db_connection_name'];
        }

        return $this->doctrine->getConnection($connectionName);
    }
205713
private function getPath(string $context = null)
    {
        if (!$this->path) {
            $reflection = new \ReflectionClass($context ?: $this);
            $filename = $reflection->getFileName();
            $this->path = pathinfo($filename);
        }

        return $this->path;
    }
269445
public function setContext($context = 'development')
    {

        switch ($context) {
            case 'production':
                break;

            case 'development':
                error_reporting(-1);              // Report all type of errors
                ini_set('display_errors', 1);     // Display all errors
                ini_set('output_buffering', 0);   // Do not buffer output

                set_exception_handler(function ($exception) {
                    echo "Anax: Uncaught exception: <p>" .
                        $exception->getMessage() . "</p><pre>" .
                        $exception->getTraceAsString() . "</pre>";
                });
                break;

            case 'debug':
                break;

            default:
                throw new \Exception('Unknown context.');
                break;
        }

        $this->context = $context;
        return $this;
    }
307431
protected function getContextAlias($context=null)
    {
        $contextAlias = $this->labeller->uri_to_alias((empty($context)) ? $this->defaultContext : $context);
        return (empty($contextAlias)) ? $this->getConfigInstance()->getDefaultContextAlias() : $contextAlias;
    }
67102
public function context($context = null)
    {
        if (is_null($context) || empty($context) || $context == "this") {
            $context = null;
        } else {
            $this->__contextAwareContext = $context;
        }
        return $this;
    }
1070605
public static function get_available_in_context($contexts) {
        $params = self::validate_parameters(self::get_available_in_context_parameters(), array('contexts' => $contexts));
        $filters = $warnings = array();

        foreach ($params['contexts'] as $contextinfo) {
            try {
                $context = self::get_context_from_params($contextinfo);
                self::validate_context($context);
                $contextinfo['contextid'] = $context->id;
            } catch (Exception $e) {
                $warnings[] = array(
                    'item' => 'context',
                    'itemid' => $context['instanceid'],
                    'warningcode' => $e->getCode(),
                    'message' => $e->getMessage(),
                );
                continue;
            }
            $contextfilters = filter_get_available_in_context($context);

            foreach ($contextfilters as $filter) {
                $filters[] = array_merge($contextinfo, (array) $filter);
            }
        }

        return array(
            'filters' => $filters,
            'warnings' => $warnings,
        );
    }
1119933
public function context($context = null)
    {
        if (is_null($context)) {
            return $this->context;
        }

        $this->context = $context;

        return $this;
    }
511719
protected function getExpectedIdentifiers($context = null)
    {
        if ($context === null) {
            throw new Exception\RuntimeException(
                'Expected context to be an array but is null'
            );
        }

        $className = $this->objectRepository->getClassName();

        if ($context instanceof $className) {
            return $this->objectManager
                        ->getClassMetadata($this->objectRepository->getClassName())
                        ->getIdentifierValues($context);
        }

        $result = [];
        foreach ($this->getIdentifiers() as $identifierField) {
            if (! array_key_exists($identifierField, $context)) {
                throw new Exception\RuntimeException(\sprintf('Expected context to contain %s', $identifierField));
            }

            $result[$identifierField] = $context[$identifierField];
        }
        return $result;
    }
1157430
public function get_contextvisibility($context) {
        global $USER;

        if ($context->contextlevel == CONTEXT_COURSE) {
            return $this->_options['enablecourseinstances'];
        }

        if ($context->contextlevel == CONTEXT_USER) {
            return $this->_options['enableuserinstances'];
        }

        //the context is SITE
        return true;
    }
393654
public function render($context)
    {
        if (count($this->class) > 0) {
            foreach ($this->class as $class) {
                $this->getRow()->addClass($class);
            }
        }
        return $context;
    }
1197232
protected function getDefaultParametersFromContext($context = null)
    {
        if (count($this->defaultParameters['contexts'])) {
            //If context is not given, just take the default one
            if ($context === null) {
                $context = $this->defaultParameters['default']['context'];
            }

            //If context is in declared contexts, we use it
            if (array_key_exists($context, $this->defaultParameters['contexts'])) {
                return $this->defaultParameters['contexts'][$context];
            }
        }

        //else we return the default configuration
        return $this->defaultParameters['default'];
    }
1257069
protected function prepareContextStack($context = null)
    {
        $stack = new Mustache_Context();

        $helpers = $this->mustache->getHelpers();
        if (!$helpers->isEmpty()) {
            $stack->push($helpers);
        }

        if (!empty($context)) {
            $stack->push($context);
        }

        return $stack;
    }
867059
private function getViewContext(array $context, ?string $viewContext = null): string
    {
        return $viewContext ?? $context['view_context'] ?? ViewInterface::CONTEXT_DEFAULT;
    }
811477
protected function getAdapter($context) {
    return $this->context === $context || $context === NULL ? $this : new static($this->entityMeta, $context);
  }
956570
public function getRequestHandle(RequestContext $context)
    {
        $curlHandle = curl_init();

        $defaults = $this->getDefaultSettings($context);

        $defaults += $this->getCurlTimeoutSettings($context);

        $defaults += $this->getCurlSslSettings();

        $defaults += $this->getProxySettings($context);

        curl_setopt_array(
            $curlHandle, //@codeCoverageIgnore
            $context->getCurlOptions() + $defaults + $this->getRequestDataAndMethodOptions($context)
        );

        return $curlHandle;
    }