@param ElementVersion $elementVersion

@return array
555150
private function queryStructures(ElementVersion $elementVersion)
    {
        $qb = $this->connection->createQueryBuilder();
        $qb
            ->select(
                [
                    'es.id',
                    'es.data_id',
                    'es.parent_id',
                    'es.parent_ds_id',
                    'es.type',
                    'es.sort',
                    'es.ds_id',
                    'es.name',
                ]
            )
            ->from('element_structure', 'es')
            ->where($qb->expr()->eq('es.element_version_id', $elementVersion->getId()))
            ->orderBy('sort', 'ASC');

        $result = $this->connection->fetchAll($qb->getSQL());

        $data = [];
        foreach ($result as $row) {
            $data[$row['parent_ds_id']][] = $row;
        }

        return $data;
    }
1201408
private function getImageCandidates(Element $node): array {
        $images = $node->find('img');
        $filteredImages = $this->filterBadNames($images);
        $goodImages = $this->findImagesThatPassByteSizeTest($filteredImages);

        return $goodImages;
    }
855972
public function createHashValuesByElementVersion(ElementVersion $elementVersion, $language)
    {
        $elementStructure = $this->elementService->findElementStructure($elementVersion, $language);

        $eid = $elementVersion->getElement()->getEid();
        $elementtypeId = $elementVersion->getElement()->getElementtypeId();
        $elementtypeVersion = $elementVersion->getElementtypeVersion();

        // TODO: meta resolver
        $meta = []; //$this->_db->fetchCol($selectMeta);
        sort($meta);

        $rii = new \RecursiveIteratorIterator($elementStructure->getIterator(), \RecursiveIteratorIterator::SELF_FIRST);
        $content = [];
        foreach ($elementStructure->getValues() as $valueIndex => $value) {
            $key = sprintf('%s__%s__%s', $elementStructure->getDsId(), $elementStructure->getSort(), $value->getDsId());
            $content[$key] = $value->getValue();
        }
        foreach ($rii as $structureIndex => $structure) {
            foreach ($structure->getValues() as $valueIndex => $value) {
                $key = sprintf('%s__%s__%s', $structure->getDsId(), $structure->getSort(), $value->getDsId());
                $content[$key] = $value->getValue();
            }
        }

        $values = [
            'eid' => $eid,
            'elementtypeId' => $elementtypeId,
            'elementtypeVersion' => $elementtypeVersion,
            'meta' => $meta,
            'content' => $content,
        ];

        return $values;
    }
1176668
public function getAllVersions()
    {
        $versions = array();

        foreach ($this->getEntities() as $entity) {
            if ($entity->getVersion()) {
                $versions[$entity->getVersion()] = $entity->getVersion();
            } else {
                $versions['0.0'] = _t('DocumentationManifest.MASTER', 'Master');
            }
        }

        asort($versions);

        return $versions;
    }
1324216
public function getFlippedMetaDataSchemaForVersion(string $metaDataVersion): array
    {
        if (false === array_key_exists($metaDataVersion, $this->metaDataSchemata)) {
            throw new UnsupportedMetaDataVersionException("Metadata version $metaDataVersion is not supported");
        }

        return $this->arrayFlipRecursive($this->metaDataSchemata[$metaDataVersion]);
    }
890304
private function parseArrayToFieldEntities(array $items, $elementType)
    {
        $entities = [];
        foreach ($items as $item) {
            $entities[] = $this->parseArrayToFieldEntity($item, $elementType);
        }

        return $entities;
    }
1366217
private static function deserializeAlternateVerificationKeys($xmlElement)
    {
        $result = [];

        foreach ($xmlElement->children() as $child) {
            $result[] = self::deserializeTokenVerificationKey($child);
        }

        return $result;
    }
1178668
public function getVersion(string $id, int $version = 1): array
    {
        $this->setFile($id);
        $id = Check::name(pathinfo($id, PATHINFO_FILENAME));
        try {
            $fileName = str_replace("{$id}.json", "version/{$id}#{$version}.json", $this->file);
            if (file_exists($fileName))
                return array_merge(["id" => $id], json_decode(file_get_contents($fileName), true));
        } catch (\Exception $e) {
            return [];
        }
        return [];
    }
1170324
protected function getAllVersions($identifier)
    {
        $portableElements = $this->get($identifier);

        // No portable element found
        if ($portableElements == '') {
            throw new PortableElementNotFoundException(
                $this->getModel()->getId() . ' with identifier "' . $identifier . '" not found.'
            );
        }

        return $portableElements;
    }
213018
protected function _getAvailableVersions($path, $version)
    {
        if (!is_dir($path)) {
            throw new Zend_Loader_Exception('Invalid ZF path provided');
        }

        $path       = rtrim($path, '/');
        $path       = rtrim($path, '\\');
        $versionLen = strlen($version);
        $versions   = array();
        $dirs       = glob("$path/*", GLOB_ONLYDIR);
        foreach ((array) $dirs as $dir) {
            $dirName = substr($dir, strlen($path) + 1);
            if (!preg_match('/^(?:ZendFramework-)?(\d+\.\d+\.\d+((a|b|pl|pr|p|rc)\d+)?)(?:-minimal)?$/i', $dirName, $matches)) {
                continue;
            }

            $matchedVersion = $matches[1];

            if (('latest' == $version)
                || ((strlen($matchedVersion) >= $versionLen)
                    && (0 === strpos($matchedVersion, $version)))
            ) {
                $versions[$matchedVersion] = $dir . '/library';
            }
        }

        uksort($versions, 'version_compare');
        return $versions;
    }
498408
public static function toComponents(Version $version)
    {
        return array(
            Parser::MAJOR => $version->getMajor(),
            Parser::MINOR => $version->getMinor(),
            Parser::PATCH => $version->getPatch(),
            Parser::PRE_RELEASE => $version->getPreRelease(),
            Parser::BUILD => $version->getBuild()
        );
    }
1097193
private function arrayFlipRecursive(array $metaDataVersion): array
    {
        $transposedArray = [];

        foreach ($metaDataVersion as $key => $item) {
            if (is_numeric($key) && \is_string($item)) {
                $transposedArray[$this->convertKeyToLowerCase($item)] = $key;
            } elseif (\is_string($key) && \is_array($item)) {
                $transposedArray[$this->convertKeyToLowerCase($key)] = $this->arrayFlipRecursive($item);
            }
        }

        return $transposedArray;
    }
706013
def _get_xml_version(element):
    """"""
    if "versions" in element.attrib:
        result = [ int(v) for v in re.split(",\s*", element.attrib["versions"]) ]
    else:
        result = [ 1 ]

    return result
344420
private function getContainer(string $namespace, int $version) : array
    {
        return [
             'swagger' => '2.0',
             'info' => [
               'title' => $namespace,
               'version' => $version . '.0',
             ],
             'host' => self::request()->getUri()->getHost(),
             'basePath' => '/Json/' . $namespace . '/v' . $version,
             'schemes' => [
                 self::request()->getUri()->getScheme(),
             ],
             'consumes' => [
                 'application/json',
             ],
             'produces' => [
               'application/json',
               'application/problem+json',
             ],
             'paths' => [],
             'securityDefinitions' => [
               'AuthApiKey' => [
                   'type' => 'apiKey',
                   'name' => 'APIKEY',
                   'in' => 'header',
               ],
               'AuthPassword' => [
                   'type' => 'basic',
               ],
             ],
             'definitions' => ['ApiException' => [
                   'required' => [
                     'status',
                     'message',
                   ],
                   'properties' => [
                     'status' => [
                       'type' => 'integer',
                     ],
                     'message' => [
                       'type' => 'string',
                     ],
                     'type' => [
                       'type' => 'string',
                     ],
                     'stack_trace' => [
                       'type' => 'array', 'items' => [
                         'type' => 'string',
                       ],
                     ],
                     'code' => [
                       'type' => 'integer',
                     ],
                     'detail' => [
                       'type' => 'string',
                     ],
                   ],
                 ],
             ],
           ];
    }
1284566
public function sortPackageVersionEntities($packageVersions, $descending = false)
    {
        $keys = [];
        foreach ($packageVersions as $pv) {
            $keys[$pv->getVersion()] = $pv;
        }
        $sortedKeys = $this->sortPackageVersions(array_keys($keys), $descending);
        $result = [];
        foreach ($sortedKeys as $sortedKey) {
            $result[] = $keys[$sortedKey];
        }

        return $result;
    }
1175013
public static function getStaticItems( string $locale = 'en_US', string $version = null ) : array
	{
		$url = self::getStaticDataFileUrl(self::STATIC_ITEMS, null, $locale, $version);
		return self::loadStaticData($url);
	}
288394
public function findElementtypeByType($type)
    {
        $elementtypes = [];
        foreach ($this->elementtypeManager->findAll() as $elementtype) {
            if ($elementtype->getType() === $type) {
                $elementtypes[] = $elementtype;
            }
        }

        return $elementtypes;
    }