* {organization} * * * @package Opentalent\OtTemplating\ViewHelpers */ class GetChildrenViewHelper extends AbstractViewHelper implements LoggerAwareInterface { use LoggerAwareTrait; use TemplateVariableViewHelperTrait; /** * >> Required to prevent typo3 to escape the html output * @var boolean */ protected $escapeOutput = false; /** * @var OrganizationRepository * */ protected $organizationRepository; /** * -- This method is expected by Fluid -- * Declares the viewhelper's parameters */ public function initializeArguments() { $this->registerArgument( 'as', 'string', 'Name of the returned array', true ); $this->registerArgument( 'organizationId', 'integer', 'Id of the organization', true ); $this->registerArgument( 'page', 'integer', 'Page number', false, 1 ); } /** * -- This method is expected by Fluid -- * Renders the content as html * * @return string */ public function render() { $as = $this->arguments['as']; $organizationId = $this->arguments['organizationId']; $page = $this->arguments['page']; $searchParams = []; if($_REQUEST['search-loc']) { $searchParams['where'] = $_REQUEST['search-loc']; } try { $organizations = $this->organizationRepository->findChildrenById( $organizationId, $searchParams, $page ); } catch (ApiRequestException $e) { $this->logger->error(sprintf('API Error: %s', $e->getMessage())); $organizations = []; } $variables = [ $as => $organizations ]; return $this->renderChildrenWithVariables($variables); } /** * @param OrganizationRepository $organizationRepository */ public function injectOrganizationRepository(OrganizationRepository $organizationRepository) { $this->organizationRepository = $organizationRepository; } }