* {organization} * * * @package Opentalent\OtTemplating\ViewHelpers */ class GetByIdViewHelper extends AbstractViewHelper { use TemplateVariableViewHelperTrait; /** * >> Required to prevent typo3 to escape the html output * @var boolean */ protected $escapeOutput = false; /** * @var \Opentalent\OtTemplating\Domain\Repository\OrganizationRepository * */ protected $organizationRepository; public function initializeArguments() { $this->registerArgument( 'as', 'string', 'Name of the returned array', true ); $this->registerArgument( 'organizationId', 'integer', 'Id of the organization', true ); } /** * @return string * @throws \Exception */ public function render() { $as = $this->arguments['as']; $organizationId = $this->arguments['organizationId']; $organization = $this->organizationRepository->findById($organizationId); $variables = [$as => $organization]; return $this->renderChildrenWithVariables($variables); } /** * @param \Opentalent\OtTemplating\Domain\Repository\OrganizationRepository $organizationRepository */ public function injectOrganizationRepository(OrganizationRepository $organizationRepository) { $this->organizationRepository = $organizationRepository; } }