Gets the identifiers from the context.

@param  array|object $context
@return array
@throws Exception\RuntimeException
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;
    }
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;
    }
862616
public static function end(ContextInterface $context): array
    {
        $isOk = $context->getStates()->getState(static::STATE_HAS_BEEN_CALLED, false);

        return $isOk === true ? BlockReplies::createEndSuccessReply() :
            BlockReplies::createEndErrorReply($context, ErrorCodes::REQUIRED, Messages::REQUIRED, []);
    }
934925
public function get_contexts() : array {
        $contexts = [];
        foreach ($this->contextids as $contextid) {
            // It is possible that this context has been deleted and we now have subsequent calls being made with this
            // contextlist. Exceptions here will stop the further processing of this component and that is why we are
            // doing a try catch.
            try {
                $contexts[] = \context::instance_by_id($contextid);
            } catch (\Exception $e) {
                // Remove this context.
                unset($this->contextids[$this->iteratorposition]);
            }
        }

        return $contexts;
    }
1363696
protected function _actionGetcandidates(AnCommandContext $context)
    {
        if ($context->request->getFormat() != 'html') {
            $data = $context->data;
            $canditates = $this->getItem()->getAdminCanditates();
            $canditates->keyword($this->value)->limit(10);
            $people = array();

            foreach ($canditates as $person) {
                $people[] = array(
                  'id' => $person->id,
                  'value' => $person->name, );
            }

            $this->getView()->set($people);

            return $people;
        }
    }
855441
protected function identifiersToArray(): array
    {
        $data = [];

        foreach ($this->getIdentifiers() as $identifier)
        {
            $data[] = $identifier->toArray();
        }

        return $data;
    }
807733
public static function helpers($context) {
        $ret = '';
        foreach ($context['helpers'] as $name => $func) {
            if (!isset($context['usedCount']['helpers'][$name])) {
                continue;
            }
            if ((is_object($func) && ($func instanceof \Closure)) || ($context['flags']['exhlp'] == 0)) {
                $ret .= ("            '$name' => " . static::closure($context, $func) . ",\n");
                continue;
            }
            $ret .= "            '$name' => '$func',\n";
        }

        return "array($ret)";
    }
1161554
protected function getFoundIdentifiers($match)
    {
        return $this->objectManager
                    ->getClassMetadata($this->objectRepository->getClassName())
                    ->getIdentifierValues($match);
    }
792347
protected function getPaths(ContextInterface $context)
    {
        if ($this->pathProvider instanceof ContextAwareInterface) {
            $this->pathProvider->setContext($context);
        }

        return $this->pathProvider->getPaths([]);
    }
41638
protected static function reqGetResourceRelationships(ContextInterface $context): array
    {
        assert(static::reqHasResourceRelationships($context));

        $value = $context->getRequest()->get(RequestProperties::REQ_RESOURCE_RELATIONSHIPS);

        assert(is_array($value));

        return $value;
    }
558285
public static function getContext()
    {
        $coID = Coroutine::getuid();
        if(!isset(static::$context[$coID]))
        {
            throw new \RuntimeException('get context failed, current context is not found');
        }
        return static::$context[$coID];
    }
394814
public static function runtime($context) {
        $class = new \ReflectionClass($context['runtime']);
        $ret = '';
        $methods = static::getClassMethods($context, $class);

        $exports = array_keys($context['usedCount']['runtime']);

        while (true) {
            if (array_sum(array_map(function ($name) use (&$exports, $methods) {
                $n = 0;
                foreach ($methods[$name][1] as $child => $count) {
                    if (!in_array($child, $exports)) {
                       $exports[] = $child;
                       $n++;
                    }
                }
                return $n;
            }, $exports)) == 0) {
                break;
            }
        }

        foreach ($exports as $export) {
            $ret .= ($methods[$export][0] . "\n");
        }

        return $ret;
    }
449400
protected function getIdentifierSource(array $contextProperties)
    {
        ksort($contextProperties);
        $identifierSource = $this->contextImplementation;
        foreach ($contextProperties as $propertyName => $propertyValue) {
            if ($propertyName === 'dimensions') {
                $stringParts = [];
                foreach ($propertyValue as $dimensionName => $dimensionValues) {
                    $stringParts[] = $dimensionName . '=' . implode(',', $dimensionValues);
                }
                $stringValue = implode('&', $stringParts);
            } elseif ($propertyName === 'targetDimensions') {
                $stringParts = [];
                foreach ($propertyValue as $dimensionName => $dimensionValue) {
                    $stringParts[] = $dimensionName . '=' . $dimensionValue;
                }
                $stringValue = implode('&', $stringParts);
            } else {
                $stringValue = $propertyValue instanceof \DateTimeInterface ? $propertyValue->getTimestamp() : (string)$propertyValue;
            }
            $identifierSource .= ':' . $stringValue;
        }

        return $identifierSource;
    }
873341
public function getSource($context = null)
    {
        $class = static::class;
        return Text::underscore(($pos = strrpos($class, '\\')) === false ? $class : substr($class, $pos + 1));
    }
596016
final public function getIdentifiers()
    {
        // Lower-case all identifiers to make it easier to find duplicate identifiers
        $identifiers = array_map('strtolower', $this->identifiers);

        if (! $this->validatedIdentifiers) {
            foreach ($identifiers as $identifier) {
                $this->validateIdentifier($identifier);
            }

            if (sizeof(array_unique($identifiers)) != sizeof($identifiers)) {
                throw new \DomainException('Error: Identifier duplicate found');
            }

            $this->validatedIdentifiers = true;
        }

        return $identifiers;
    }
1210721
protected static function reqGetResourceIdentity(ContextInterface $context): ?string
    {
        assert(static::reqHasResourceIdentity($context));

        $value = $context->getRequest()->get(RequestProperties::REQ_RESOURCE_IDENTITY);

        assert($value === null || is_string($value));

        return $value;
    }
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;
    }