public static function getConceptPropertyArray(\Concept $concept, $collapse = true) { $properties = $concept->getConceptPropertysRelatedByConceptIdJoinProfilePropertyRelatedBySkosPropertyId(); /** @var array $properties */ $properties = $properties ?: []; $array['@id'] = $concept->getUri(); $array['@type'] = 'Concept'; $array['api'] = 'http://api.metadataregistry.org/concepts/' . $concept->getId(); $array['inScheme'] = $concept->getVocabulary()->getUri(); $array['status'] = $concept->getStatus()->getDisplayName(); if ($properties) { foreach ($properties as $property) { if (!$property->getDeletedAt()) { /** @var \ProfileProperty $profile */ $profile = $property->getProfileProperty(); if ($profile->getHasLanguage()) { if ($profile->getIsSingleton()) { $array[$profile->getName()][$property->getLanguage()] = $property->getObject(); } else { $array[$profile->getName()][$property->getLanguage()][] = $property->getObject(); } } else { if ($profile->getIsSingleton()) { $array[$profile->getName()] = $property->getObject(); } else { $array[$profile->getName()][] = $property->getObject(); } } } } } if ($collapse) { $collapsedArray = []; foreach ($array as $key => $element) { if (is_array($element)) { foreach ($element as $index => $item) { if (is_array($item) && count($item) == 1) { $collapsedArray[$key][$index] = $item[0]; } else { $collapsedArray[$key][$index] = $item; } } } else { $collapsedArray[$key] = $element; } } return $collapsedArray; } return $array; }