. */ namespace SP\Modules\Web\Controllers\Account; use Exception; use SP\Core\Acl\ActionsInterface; use SP\Core\Application; use SP\Core\Events\Event; use SP\Core\UI\ThemeIcons; use SP\Domain\Account\AccountServiceInterface; use SP\Modules\Web\Controllers\Helpers\Account\AccountHelper; use SP\Mvc\Controller\WebControllerHelper; use SP\Util\ErrorUtil; final class ViewController extends AccountControllerBase { private \SP\Domain\Account\AccountServiceInterface $accountService; private AccountHelper $accountHelper; private ThemeIcons $icons; public function __construct( Application $application, WebControllerHelper $webControllerHelper, AccountServiceInterface $accountService, AccountHelper $accountHelper ) { parent::__construct( $application, $webControllerHelper ); $this->accountService = $accountService; $this->accountHelper = $accountHelper; $this->icons = $this->theme->getIcons(); } /** * View action * * @param int $id Account's ID */ public function viewAction(int $id): void { try { $this->view->addTemplate('account'); $accountDetailsResponse = $this->accountService->getById($id); $this->accountService ->withUsersById($accountDetailsResponse) ->withUserGroupsById($accountDetailsResponse) ->withTagsById($accountDetailsResponse); $this->accountHelper->setIsView(true); $this->accountHelper->setViewForAccount($accountDetailsResponse, ActionsInterface::ACCOUNT_VIEW); $this->view->assign( 'title', [ 'class' => 'titleNormal', 'name' => __('Account Details'), 'icon' => $this->icons->getIconView()->getIcon(), ] ); $this->accountService->incrementViewCounter($id); $this->eventDispatcher->notifyEvent('show.account', new Event($this)); if ($this->isAjax === false) { $this->upgradeView(); } $this->view(); } catch (Exception $e) { processException($e); $this->eventDispatcher->notifyEvent('exception', new Event($e)); if ($this->isAjax === false && !$this->view->isUpgraded()) { $this->upgradeView(); } ErrorUtil::showExceptionInView($this->view, $e, 'account'); } } }