* @package taoQtiItem * * @deprecated Use oat\taoItems\model\CategoryService instead */ class ItemCategoriesService extends ConfigurableService { const SERVICE_ID = 'taoQtiItem/ItemCategories'; /** * Get the categories link to the list of items in parameter. * Theses categories come from a configurable list of properties. * The category label is also set in a configurable list * @param \core_kernel_classes_Resource[] $items * @return array of categories for specified items * ['itemUri' => ['CATEGORY1', 'CATEGORY2']] */ public function getCategories(array $items) { $categories = []; $lookupProperties = $this->getOption('properties'); if (!empty($lookupProperties)) { foreach ($items as $item) { $itemCategories = []; if ($item instanceof \core_kernel_classes_Resource) { $properties = $item->getPropertiesValues(array_keys($lookupProperties)); foreach ($properties as $property => $propertyValues) { foreach ($propertyValues as $value) { $propertyValue = ($value instanceof \core_kernel_classes_Resource) ? $value->getUri() : (string)$value; if (isset($lookupProperties[$property][$propertyValue])) { $itemCategories[] = $lookupProperties[$property][$propertyValue]; } } } $categories[$item->getUri()] = $itemCategories; } } } return $categories; } }