@param array|null $context

@throws InvalidValueDataException
@throws MissingAttributeException
@throws ContextException

@return string
358917
protected function getLabelValue(array $context = null)
    {
        $attributeAsLabel = $this->getFamily()->getAttributeAsLabel();
        if ($attributeAsLabel) {
            return (string) $this->getValueData($attributeAsLabel, $context);
        }

        return (string) $this->getIdentifier();
    }
486112
public function getLabel(array $context = null)
    {
        if ($this->getFamily()->hasAttribute('label')) {
            return $this->getValueData($this->getAttribute('label'), $context);
        }
        $label = null;
        try {
            $label = $this->getLabelValue($context);
        } catch (\Exception $e) {
        }
        if (null === $label && $this->getIdentifier()) {
            $label = "[{$this->getIdentifier()}]";
        }

        return $label;
    }
416160
public function context($context = NULL)
	{
		if ( ! func_num_args())
		{
			return $this->_context;
		}
		$this->_context = $context;
		return $this;
	}
394467
private function parseContext($context)
    {
        $debugBackTrace = debug_backtrace();
        if(!isset($context['trace']))
        {
            $context['trace'] = $this->getTrace($debugBackTrace);
        }
        if(!isset($context['errorFile']))
        {
            list($file, $line) = $this->getErrorFile($debugBackTrace);
            $context['errorFile'] = $file;
            $context['errorLine'] = $line;
        }
        return $context;
    }
987631
public function doSpecific(Context $context)
    {
        if(!isset($this->attributes['name'])) {
            //name is a required attribute for fig:attr.
            throw new RequiredAttributeException($this->name, $this->xmlLineNumber, 'name');
        }
        //flag attribute
        // Usage: <tag><fig:attr name="ng-app" flag="true" />  will render as flag <tag ng-app> at tag level, without a value.
        if(isset($this->attributes['flag']) && $this->evaluate($context, $this->attributes['flag'])) {
            $context->setParentRuntimeAttribute($this->attributes['name'], new Flag());
        } else {
            if ($this->hasAttribute('value')) {
                $value = $this->evaluate($context, $this->attributes['value']);
                if (is_string($value)) {
                    $value = htmlspecialchars($value);
                }
                $context->setParentRuntimeAttribute($this->attributes['name'],  $value);
            } else {
                $value = '';
                /**
                 * @var ViewElement
                 */
                $child = null;
                foreach ($this->children as $child) {
                    $renderChild = $child->render($context);
                    if ($renderChild === false) {
                        throw new \Exception();
                    }
                    $value .= $renderChild;
                }
                //An XML attribute should not span accross several lines.
                $value = trim(preg_replace("#[\n\r\t]+#", ' ', $value));
                $context->setParentRuntimeAttribute($this->attributes['name'], $value);
            }
        }
        // No more rendering of the inner contents. Job is done, move to next sibling by
        // returning (non-null) empty string
        return '';
    }
943516
private function getSegment( $context )
	{
		if ( is_string( $context ) )
		{
			if ( ! isset( $this->contexts[ $context ] ) ) return null;
			$context = $this->contexts[ $context ];
		}

		if ( isset( $context['segment'] ) ) return $context['segment'];
		if ( isset( $context['entity']['segment'] ) ) return $context['entity']['segment'];

		return null;
	}
741682
public function dataValue()
    {
        $result = null;
        if (is_array($this->value)) {
            $this->value = $this->arrayFilterEmptyRecursive($this->value);
            $result = (!empty($this->value)) ? Convert::array2json($this->value) : $result;
        } else {
            $result = parent::dataValue();
        }

        return $result;
    }
92046
protected function printContext(array $context)
    {
        $res = '';
        foreach ($context as $name => $val) {
            // bypass internal context
            if (substr($name, 0, 2) === '__') {
                continue;
            }

            // concat contexts
            $res .= " $name: " . strval($val);
        }
        return $res ?: '';
    }
1205527
public function render($context = [])
    {
        if ($this->getElement()->hasAttribute('value')) {
            $this->getElement()->getAttributes()->remove('value');
        }
        return parent::render($context);
    }
688248
public function getPrimarySubdescriptor($context = null)
    {
        $subdescriptor = [];
        foreach ($this->getSubdescriptor($context) as $subValue) {
            if (!empty($subValue)) {
                if (is_array($subValue) && isset($subValue['plain'])) {
                    $subdescriptor[] = $subValue['plain'];
                } elseif (is_array($subValue) && isset($subValue['rich'])) {
                    $subdescriptor[] = strip_tags($subValue['rich']);
                } elseif (is_string($subValue) || is_numeric($subValue)) {
                    $subdescriptor[] = strip_tags($subValue);
                }
            }
        }

        return isset($subdescriptor[0]) ? $subdescriptor[0] : null;
    }
67102
public function context($context = null)
    {
        if (is_null($context) || empty($context) || $context == "this") {
            $context = null;
        } else {
            $this->__contextAwareContext = $context;
        }
        return $this;
    }
688986
public static function validate_context($context) {
        global $CFG, $PAGE;

        if (empty($context)) {
            throw new invalid_parameter_exception('Context does not exist');
        }
        if (empty(self::$contextrestriction)) {
            self::$contextrestriction = context_system::instance();
        }
        $rcontext = self::$contextrestriction;

        if ($rcontext->contextlevel == $context->contextlevel) {
            if ($rcontext->id != $context->id) {
                throw new restricted_context_exception();
            }
        } else if ($rcontext->contextlevel > $context->contextlevel) {
            throw new restricted_context_exception();
        } else {
            $parents = $context->get_parent_context_ids();
            if (!in_array($rcontext->id, $parents)) {
                throw new restricted_context_exception();
            }
        }

        $PAGE->reset_theme_and_output();
        list($unused, $course, $cm) = get_context_info_array($context->id);
        require_login($course, false, $cm, false, true);
        $PAGE->set_context($context);
    }
439150
public function context($context, $value = null)
    {
        if (! is_array($context)) {
            $context = [$context => $value];
        }

        foreach ($context as $key => $value) {
            $this->context[$key] = $value;
        }

        return $this;
    }
844255
protected function getParser($context = null)
    {
        $parser = $this->getComponent('parser');

        $parser->registeredVars['context'] = $context;

        return $parser;
    }
178042
public function renderUserElementMap(array &$context)
	{
		$map = $this->renderer->getElementMap($context['user']['id'], Craft::$app->getSites()->getPrimarySite()->id);
		return $this->renderMap($map);
	}
1313961
public function getPage(array $context = []): int
    {
        $page = (int) $this->getParameterFromContext(
            $context,
            $this->options['page_parameter_name'],
            $this->options['page_default']
        );

        if (1 > $page) {
            throw new InvalidArgumentException('Page should not be less than 1');
        }

        return $page;
    }
854190
private function getMessageSectionsFromContext(array $context)
    {
        $messageSections = '';
        foreach ($this->contextToOutputSectionMap as $sectionContextName => $section) {
            if (isset($context[$sectionContextName])) {
                $messageSection = str_repeat(' ', $section['paddedLength']);
                if (isset($this->previousContext[$sectionContextName]) === false || $this->previousContext[$sectionContextName] != $context[$sectionContextName]) {
                    $messageSection = sprintf($section['format'], str_pad($context[$sectionContextName], $section['paddedLength'] - 2));
                }

                $messageSections .= $messageSection;
            }
        }

        return $messageSections;
    }