. */ namespace SP\Modules\Web\Controllers\Account; use Exception; use SP\Core\Events\Event; use SP\Domain\Account\Dtos\AccountEnrichedDto; use SP\Domain\Core\Acl\AclActionsInterface; use SP\Modules\Web\Util\ErrorUtil; use function SP\__; use function SP\processException; /** * ViewController */ final class ViewController extends AccountViewBase { /** * View action * * @param int $id Account's ID */ public function viewAction(int $id): void { try { $this->accountHelper->initializeFor(AclActionsInterface::ACCOUNT_VIEW); $accountEnrichedDto = $this->accountService->withTags( $this->accountService->withUserGroups( $this->accountService->withUsers( new AccountEnrichedDto($this->accountService->getByIdEnriched($id)) ) ) ); $this->accountHelper->setIsView(true); $this->accountHelper->setViewForAccount($accountEnrichedDto); $this->view->addTemplate('account'); $this->view->assign( 'title', [ 'class' => 'titleNormal', 'name' => __('Account Details'), 'icon' => $this->icons->view()->getIcon(), ] ); $this->accountService->incrementViewCounter($id); $this->eventDispatcher->notify('show.account', new Event($this)); if ($this->isAjax === false) { $this->upgradeView(); } $this->view(); } catch (Exception $e) { processException($e); $this->eventDispatcher->notify('exception', new Event($e)); if ($this->isAjax === false) { $this->upgradeView(); } ErrorUtil::showExceptionInView($this->view, $e, 'account'); } } }