/** * @param MvcEvent $event * * @return parent::onDispatch */ public function onDispatch(MvcEvent $event) { $request = $event->getRequest(); $remoteAddr = $request->getServer('REMOTE_ADDR'); // check IP address is allowed $application = $event->getApplication(); $config = $application->getConfig(); $autoDeployConfig = $config['auto_deploy']; $allowedIpAddresses = $autoDeployConfig['ipAddresses']; // error if ip is not allowed if (!in_array($remoteAddr, $allowedIpAddresses, true)) { $baseModel = new \Zend\View\Model\ViewModel(); $baseModel->setTemplate('layout/output'); $model = new \Zend\View\Model\ViewModel(); $model->setTemplate('error/403'); $baseModel->addChild($model); $baseModel->setTerminal(true); $event->setViewModel($baseModel); $response = $event->getResponse(); $response->setStatusCode(403); $response->sendHeaders(); $event->setResponse($response); exit; } return parent::onDispatch($event); }
/** * Apartment Welcome Note Page * * @return \Zend\View\Model\ViewModel */ public function indexAction() { /** * @var \DDD\Service\Apartment\General $apartmentGeneralService * @var \DDD\Service\Task $taskService * @var \DDD\Dao\Textline\Apartment $texLineApartmentDao */ $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general'); $taskService = $this->getServiceLocator()->get('service_task'); $textLineApartmentDao = $this->getServiceLocator()->get('dao_textline_apartment'); $apartmentTasks = $taskService->getFrontierTasksOnApartment($this->apartmentId); // get apartment usage information $apartmentUsage = $textLineApartmentDao->getApartmentUsageByApartmentId($this->apartmentId); // get building usage information $apartmentBuildingUsage = $textLineApartmentDao->getApartmentBuildingUsageByApartmentId($this->apartmentId); // get building facilities information $apartmentBuildingFacility = $textLineApartmentDao->getApartmentBuildingFacilityByApartmentId($this->apartmentId); // get building policy information $apartmentBuildingPolicy = $textLineApartmentDao->getApartmentBuildingPolicyByApartmentId($this->apartmentId); // get apartment information $generalInfo = $apartmentGeneralService->getApartmentGeneral($this->apartmentId); $viewModel = new \Zend\View\Model\ViewModel(); $viewModel->setTerminal(true); $viewModel->setVariables(['apartment' => $generalInfo, 'apartmentTasks' => $apartmentTasks, 'apartmentUsage' => $apartmentUsage, 'apartmentBuildingUsage' => $apartmentBuildingUsage, 'apartmentBuildingFacility' => $apartmentBuildingFacility, 'apartmentBuildingPolicy' => $apartmentBuildingPolicy]); return $viewModel; }
/** * Index page action * * @return \Zend\View\Model\ViewModel */ public function indexAction() { $view = new \Zend\View\Model\ViewModel(); $view->setTerminal(true); return $view; }
/** * @param string $type * @return string */ function generateTemplate($type = 'html') { $entity = $this->getEntity(); $config = $this->getConfig(); $view = new \Zend\View\Renderer\PhpRenderer(); $view->setResolver($this->pathStack); if (strlen($entity->getTemplate()) > 0) { $templatePath = 'email/'; if (strpos($entity->getTemplate(), '/') === false) { $templatePath .= $entity->getTemplate(); } else { $templatePath = $entity->getTemplate(); } } else { $templatePath = 'email/default'; } if ($type == 'html') { $content = $entity->getHtml(); } else { $content = $entity->getText(); } $viewModel = new \Zend\View\Model\ViewModel(array_merge(array('content' => $content), $entity->getVars())); $viewModel->setTemplate($templatePath); $layout = new \Zend\View\Model\ViewModel(array('content' => $view->render($viewModel), 'site_name' => $config['site_name'])); $layout->setTerminal(true); $layout->setTemplate('layout/' . $type); return $view->render($layout); }
public function Index07Action() { $viewModel = new \Zend\View\Model\ViewModel(); $viewModel->setTerminal(true); return $viewModel; }