. */ namespace SP\Domain\Account\Out; use League\Fractal\Resource\Collection; use SP\Core\Acl\ActionsInterface; use SP\DataModel\Dto\AccountDetailsResponse; use SP\Domain\Common\Out\AdapterBase; use SP\Domain\CustomField\CustomFieldServiceInterface; use SP\Domain\CustomField\Out\CustomFieldAdapter; use SP\Mvc\Controller\ItemTrait; use SP\Mvc\View\Components\SelectItemAdapter; use SP\Util\Link; /** * Class AccountAdapter * * @package SP\Adapters */ final class AccountAdapter extends AdapterBase implements AccountAdapterInterface { 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( AccountDetailsResponse $data, CustomFieldServiceInterface $customFieldService ): Collection { return $this->collection( $this->getCustomFieldsForItem(ActionsInterface::ACCOUNT, $data->getId(), $customFieldService), new CustomFieldAdapter($this->configData) ); } public function transform(AccountDetailsResponse $data): array { $account = $data->getAccountVData(); return [ 'id' => (int)$account->getId(), 'name' => $account->getName(), 'clientId' => $account->getClientId(), 'clientName' => $account->getClientName(), 'categoryId' => $account->getCategoryId(), 'categoryName' => $account->getCategoryName(), 'userId' => $account->getUserId(), 'userName' => $account->getUserName(), 'userLogin' => $account->getUserLogin(), 'userGroupId' => $account->getUserGroupId(), 'userGroupName' => $account->getUserGroupName(), 'userEditId' => $account->getUserEditId(), 'userEditName' => $account->getUserEditName(), 'userEditLogin' => $account->getUserEditLogin(), 'login' => $account->getLogin(), 'url' => $account->getUrl(), 'notes' => $account->getNotes(), 'otherUserEdit' => $account->getOtherUserEdit(), 'otherUserGroupEdit' => $account->getOtherUserGroupEdit(), 'dateAdd' => $account->getDateAdd(), 'dateEdit' => $account->getDateEdit(), 'countView' => $account->getCountView(), 'countDecrypt' => $account->getCountDecrypt(), 'isPrivate' => $account->getIsPrivate(), 'isPrivateGroup' => $account->getIsPrivateGroup(), 'passDate' => $account->getPassDate(), 'passDateChange' => $account->getPassDateChange(), 'parentId' => $account->getParentId(), 'publicLinkHash' => $account->getPublicLinkHash(), 'tags' => SelectItemAdapter::factory($data->getTags())->getItemsFromModel(), 'users' => SelectItemAdapter::factory($data->getUsers())->getItemsFromModel(), 'userGroups' => SelectItemAdapter::factory($data->getUserGroups())->getItemsFromModel(), 'customFields' => null, 'links' => [ [ 'rel' => 'self', 'uri' => Link::getDeepLink( $account->getId(), ActionsInterface::ACCOUNT_VIEW, $this->configData, true ) ] ], ]; } }