. */ namespace SP\Adapters; use League\Fractal\Resource\Collection; use SP\Core\Acl\ActionsInterface; use SP\DataModel\CategoryData; use SP\Mvc\Controller\ItemTrait; use SP\Util\Link; /** * Class CategoryAdapter * * @package SP\Adapters */ final class CategoryAdapter extends AdapterBase { use ItemTrait; protected $availableIncludes = [ 'customFields' ]; /** * @throws \SP\Core\Exceptions\ConstraintException * @throws \SP\Core\Exceptions\QueryException * @throws \SP\Core\Exceptions\SPException * @throws \SP\Domain\Common\Services\ServiceException */ public function includeCustomFields(CategoryData $data): Collection { return $this->collection( $this->getCustomFieldsForItem(ActionsInterface::CATEGORY, $data->id), new CustomFieldAdapter($this->configData) ); } public function transform(CategoryData $data): array { return [ 'id' => $data->getId(), 'name' => $data->getName(), 'description' => $data->getDescription(), 'customFields' => null, 'links' => [ [ 'rel' => 'self', 'uri' => Link::getDeepLink( $data->getId(), ActionsInterface::CATEGORY_VIEW, $this->configData, true ) ] ], ]; } }