예제 #1
1
 protected function setChildViews(ViewModel $view_page)
 {
     $view_menu = new ViewModel();
     $view_menu->setTemplate('setting/common/menu');
     $view_page->addChild($view_menu, 'menu');
     return $view_page;
 }
 /**
  * @param $controllerName
  * @param $action
  * @param array $params
  * @return string|\Zend\Stdlib\ResponseInterface
  * @throws \Exception
  */
 public function runControllerAction($controllerName, $action, $params = array())
 {
     $this->event->getRouteMatch()->setParam('controller', $controllerName)->setParam('action', $action);
     foreach ($params as $key => $value) {
         $this->event->getRouteMatch()->setParam($key, $value);
     }
     $serviceManager = $this->event->getApplication()->getServiceManager();
     $controllerManager = $serviceManager->get('ControllerLoader');
     /** @var AbstractActionController $controller */
     $controller = $controllerManager->get($controllerName);
     $controller->setEvent($this->event);
     $result = $controller->dispatch($this->event->getRequest());
     if ($result instanceof Response) {
         return $result;
     }
     /** @var ViewManager $viewManager */
     $viewManager = $serviceManager->get('ViewManager');
     $renderingStrategy = $viewManager->getMvcRenderingStrategy();
     $this->event->setViewModel($result);
     /** @var ViewModel $result */
     if (!$result->terminate()) {
         $layout = new ViewModel();
         $layoutTemplate = $renderingStrategy->getLayoutTemplate();
         $layout->setTemplate($layoutTemplate);
         $layout->addChild($result);
         $this->event->setViewModel($layout);
     }
     $response = $renderingStrategy->render($this->event);
     return $response;
 }
 public function testInjectTagsHeader()
 {
     $tag = InjectTagsHeaderListener::OPTION_CACHE_TAGS;
     $event = new MvcEvent();
     $response = new Response();
     $event->setResponse($response);
     $layout = new ViewModel();
     $child1 = new ViewModel();
     $child1->setOption($tag, ['tag1', 'tag2']);
     $layout->addChild($child1);
     $child2 = new ViewModel();
     $child21 = new ViewModel();
     $child21->setOption($tag, ['tag3', null]);
     $child2->addChild($child21);
     $layout->addChild($child2);
     $child3 = new ViewModel();
     $child3->setOption('esi', ['ttl' => 120]);
     $child3->setOption($tag, 'tag4');
     $layout->addChild($child3);
     $event->setViewModel($layout);
     $this->listener->injectTagsHeader($event);
     $this->assertSame(['tag1', 'tag2', 'tag3'], $this->listener->getCacheTags());
     $headers = $response->getHeaders();
     $this->assertEquals('tag1,tag2,tag3', $headers->get(VarnishService::VARNISH_HEADER_TAGS)->getFieldValue());
 }
예제 #4
0
 public function indexAction()
 {
     $view = new ViewModel();
     $username = $this->params()->fromPost('username');
     $password = $this->params()->fromPost('password');
     if (empty($username) && empty($password)) {
         $session = new Container('user_session');
         $pattern = $session->offsetGet('session_status');
         if (!empty($pattern)) {
             $adminContent = new ViewModel(array('posts' => $this->formatTargetPosts($this->postService->findAllPosts('', 'php'), true)));
             $adminContent->setTemplate('template/content/adminContent.phtml');
             $view->addChild($adminContent, '_admin_content');
             return $view;
         } else {
             echo "<h1>Forbidden No Session stored!</h1>\r\n                    <button id=\"retry_1\" type=\"button\" class=\"btn btn-success\">To login Site</button>";
         }
     } else {
         $result = $this->postService->userMapping($username, $password);
         if ($result) {
             $this->sessionAction($username);
             $adminContent = new ViewModel(array('posts' => $this->formatTargetPosts($this->postService->findAllPosts('', 'php'), true)));
             //
             $adminContent->setTemplate('template/content/adminContent.phtml');
             $view->addChild($adminContent, '_admin_content');
             //        TODO: Implement Admin Content.
         } else {
             $error_message = new ViewModel(array());
             $error_message->setTemplate('template/error/error_admin_login.phtml');
             $view->addChild($error_message, '_error_message');
         }
         return $view;
     }
 }
예제 #5
0
 public function __invoke($dataView, $layout)
 {
     $dashboard = new ViewModel();
     $dashboard->setTemplate('dashboard/view');
     $sidebar = new ViewModel();
     $sidebar->setTemplate('dashboard/sidebar');
     $dashboard->addChild($sidebar, 'sidebar');
     $dashboard->addChild($dataView, 'data');
     $layout->addChild($dashboard, 'content');
     return $dashboard;
 }
예제 #6
0
파일: View.php 프로젝트: mtymek/blast-view
 /**
  * Render the provided model.
  *
  * @param ModelInterface $model
  * @return string
  */
 public function render(ModelInterface $model)
 {
     if ($this->layout && !$model->terminate()) {
         $this->layout->addChild($model);
         $model = $this->layout;
     }
     // hack, force ZendView to return its output instead of triggering an event
     // see: http://mateusztymek.pl/blog/using-standalone-zend-view
     $model->setOption('has_parent', true);
     return $this->zendView->render($model);
 }
예제 #7
0
 public function articleAction()
 {
     $id = $this->params()->fromQuery('id');
     $view = new ViewModel();
     $sidebarView = new ViewModel(array('newposts' => $this->formatTargetPosts($this->postService->findAllPosts(0), false)));
     $sidebarView->setTemplate('template/sidebar/sidebar_post.phtml');
     $view->addChild($sidebarView, '_sidebarView');
     $article = new ViewModel(array('article' => $this->postService->findPost($id)));
     $article->setTemplate('template/content/article.phtml');
     $view->addChild($article, '_article');
     return $view;
 }
 public function serviceAction()
 {
     $serviceName = strtolower($this->params()->fromRoute('service'));
     $format = strtolower($this->params()->fromRoute('format'));
     $runChecks = $this->params()->fromQuery('run', true);
     if (in_array($format, array(self::XML, self::RICH))) {
         throw new Exception\UnexpectedValueException(sprintf('Format "%s" is currently not supported', $format));
     }
     try {
         $service = new Model\Service($serviceName);
     } catch (Model\Exception\BadModelCallException $e) {
         return $this->notFoundAction();
     }
     $this->_setNewRelic($service);
     $content = $this->_getContentView($service, $format, $runChecks);
     if ($format === self::JSON) {
         $data = $content->getVariables();
         unset($data->service);
         $view = new ViewModel\JsonModel($data);
         Json\Json::$useBuiltinEncoderDecoder = true;
     } else {
         $view = new ViewModel\ViewModel();
         $view->addChild($content, 'content');
         $view->service = $service;
         $view->format = $format;
     }
     return $view;
 }
예제 #9
0
 public function indexAction()
 {
     $sm = $this->getServiceLocator();
     $userService = $sm->get('Stjornvisi\\Service\\User');
     $conferenceService = $sm->get('Stjornvisi\\Service\\Conference');
     /** @var $conferenceService \Stjornvisi\Service\Conference */
     $authService = new AuthenticationService();
     //CONFERENCE FOUND
     //  an conference with this ID was found
     if (($conference = $conferenceService->get($this->params()->fromRoute('id', 0), $authService->hasIdentity() ? $authService->getIdentity()->id : null)) != false) {
         $groupIds = array_map(function ($i) {
             return $i->id;
         }, $conference->groups);
         //TODO don't use $_POST
         //TODO send registration mail
         if ($this->request->isPost()) {
             $conferenceService->registerUser($conference->id, $this->params()->fromPost('email', ''), 1, $this->params()->fromPost('name', ''));
             $this->getEventManager()->trigger('notify', $this, array('action' => 'Stjornvisi\\Notify\\Attend', 'data' => (object) array('conference_id' => $conference->id, 'type' => 1, 'recipients' => (object) array('id' => null, 'name' => $this->params()->fromPost('name', ''), 'email' => $this->params()->fromPost('email', '')))));
             return new ViewModel(array('logged_in' => $authService->hasIdentity(), 'register_message' => true, 'conference' => $conference, 'related' => $conferenceService->getRelated($groupIds), 'attendees' => $userService->getByConference($conference->id), 'access' => $userService->getTypeByGroup($authService->hasIdentity() ? $authService->getIdentity()->id : null, $groupIds)));
         } else {
             $conferenceView = new ViewModel(array('conference' => $conference, 'register_message' => false, 'logged_in' => $authService->hasIdentity(), 'access' => $userService->getTypeByGroup($authService->hasIdentity() ? $authService->getIdentity()->id : null, $groupIds), 'attendees' => $userService->getByConference($conference->id)));
             $conferenceView->setTemplate('stjornvisi/conference/partials/index-conference');
             $asideView = new ViewModel(array('access' => $userService->getTypeByGroup($authService->hasIdentity() ? $authService->getIdentity()->id : null, $groupIds), 'conference' => $conference, 'related' => null));
             $asideView->setTemplate('stjornvisi/conference/partials/index-aside');
             $mainView = new ViewModel();
             $mainView->addChild($conferenceView, 'conference')->addChild($asideView, 'aside');
             return $mainView;
         }
         //NOT FOUND
         //  todo 404
     } else {
         var_dump('404');
     }
 }
예제 #10
0
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Cubilis\Connection $cubilisConnectionService
      * @var General $apartmentGeneralService
      */
     $cubilisConnectionService = $this->getServiceLocator()->get('service_cubilis_connection');
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $cubilisDetails = $apartmentGeneralService->getCubilisDetailsAsArray($this->apartmentId);
     $form = new CubilisConnection($this->url()->fromRoute('apartment/channel-connection/save', ['apartment_id' => $this->apartmentId]));
     $form->prepare();
     $form->populateValues($cubilisDetails);
     $formTemplate = 'form-templates/cubilis-connection';
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form]);
     $viewModelForm->setTemplate($formTemplate);
     $rates = $apartmentGeneralService->getRoomRates($this->apartmentId);
     $rateConnections = $cubilisConnectionService->getCubilisTypes($this->apartmentId, $rates);
     $urlLinkRates = $this->url()->fromRoute('apartment/channel-connection/link', ['apartment_id' => $this->apartmentId]);
     $apartmentOTAService = $this->getServiceLocator()->get('service_apartment_ota_distribution');
     $apartmentOTAList = $apartmentOTAService->getOTAList($this->apartmentId);
     $partnerList = $apartmentOTAService->getPartnerList();
     $hasApartmentConnectionRole = false;
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     if ($auth->hasRole(Roles::ROLE_APARTMENT_CONNECTION)) {
         $hasApartmentConnectionRole = true;
     }
     $viewModel = new ViewModel();
     $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'rateConnections' => $rateConnections, 'rates' => $rates, 'urlLinkRates' => $urlLinkRates, 'cubilisDetails' => $cubilisDetails, 'apartmentOTAList' => $apartmentOTAList, 'partnerList' => $partnerList, 'OTAStatus' => Objects::getOTADistributionStatusList(), 'isCubilisConnecter' => $hasApartmentConnectionRole]);
     // child view to render form
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('apartment/channel-connection/index');
     return $viewModel;
 }
예제 #11
0
 protected function setChildViews(ViewModel $view_page)
 {
     $view_menu = new ViewModel(array('RouteName' => $this->getEvent()->getRouteMatch()->getMatchedRouteName()));
     $view_menu->setTemplate('merchant/common/menu');
     $view_page->addChild($view_menu, 'menu');
     return $view_page;
 }
예제 #12
0
파일: General.php 프로젝트: arbi/MyCode
 /**
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Apartment\General $apartmentGeneralService
      */
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $form = $this->getForm();
     $form->prepare();
     $generalInfo = false;
     if ($this->apartmentId) {
         $generalInfo = $apartmentGeneralService->getApartmentGeneral($this->apartmentId);
         $form->populateValues(['id' => $this->apartmentId, 'apartment_name' => $generalInfo['name'], 'status' => $generalInfo['status'], 'room_count' => $generalInfo['room_count'], 'square_meters' => $generalInfo['square_meters'], 'max_capacity' => $generalInfo['max_capacity'], 'bedrooms' => $generalInfo['bedroom_count'], 'bathrooms' => $generalInfo['bathroom_count'], 'chekin_time' => date('H:i', strtotime($generalInfo['check_in'])), 'chekout_time' => date('H:i', strtotime($generalInfo['check_out'])), 'general_description_textline' => $generalInfo['general_descr'], 'general_description' => $generalInfo['general_description']]);
     } else {
         // Pre-filled default values when adding apartment
         $form->populateValues(['chekin_time' => '15:00', 'chekout_time' => '11:00']);
     }
     // passing form and map to the view
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form, 'date_created' => isset($generalInfo['create_date']) ? $generalInfo['create_date'] : '', 'apartmentStatus' => $this->apartmentStatus]);
     $viewModelForm->setTemplate('form-templates/general');
     $viewModel = new ViewModel();
     $viewModel->setVariables(['apartment' => $generalInfo, 'apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus]);
     // child view to render form
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('apartment/general/index');
     return $viewModel;
 }
예제 #13
0
 public function indexAction()
 {
     $data = $this->params()->fromPost();
     $vm = new ViewModel(array('postForm' => $this->postForm, 'data' => $data));
     $vm->setTemplate('market/post/index.phtml');
     if ($this->getRequest()->isPost()) {
         $this->postForm->setData($data);
         if ($this->postForm->isValid()) {
             if (isset($data['cityCode'])) {
                 $data['cityCode'] = $this->worldCityAreaCodesTable->getCodeById($data['cityCode']);
             }
             if ($this->listingsTable->addPosting($data)) {
                 $this->flashMessenger()->addMessage("Dados postados com sucesso.");
             } else {
                 $this->flashMessenger()->addMessage("Houve um problema ao inserir os dados do formulário.");
             }
             return $this->redirect()->toRoute('home');
         } else {
             $invalidView = new ViewModel();
             $invalidView->setTemplate('market/post/invalid.phtml');
             $invalidView->addChild($vm, 'main');
             return $invalidView;
         }
     }
     return $vm;
 }
예제 #14
0
 public function indexAction()
 {
     $this->_mainParam["data"]["id"] = $this->params("id");
     $display = $this->params("display", "list");
     $viewModel = new ViewModel();
     //view chính
     $bookView = new ViewModel();
     //view -hiện danh sách book
     $bookView->setTemplate('shop/category/' . $display);
     //CATEGORY INFO
     $categoryItem = $this->getTable()->getItem($this->_mainParam["data"]);
     if (empty($categoryItem)) {
         $this->redirect()->toRoute("shopRoute/default", array("controller" => "notice", "action" => "no-data"));
     }
     //BREADCRUMB
     $listBreadcumb = $this->getTable()->listItem($categoryItem, array("task" => "list-breadcrumb"));
     //LISTBOOK BY CATEGORY
     $catIDs = $this->getTable()->listItem($categoryItem, array("task" => "list-id-category"));
     $this->_mainParam["catIDs"] = $catIDs;
     $bookTable = $this->getServiceLocator()->get("shopBookTable");
     $listBook = $bookTable->listItem($this->_mainParam, array("task" => "list-book-by-category"));
     $totalItem = $bookTable->countItem($catIDs, array("task" => "count-book"));
     $viewModel->addChild($bookView, "list_book_category");
     $bookView->setVariables(array("listBook" => $listBook));
     $viewModel->setVariables(array("categoryItem" => $categoryItem, "listBreadcumb" => $listBreadcumb, "paginator" => \ZendVN\Paginator\Paginator::createPagination($totalItem, $this->_configPaginator), "displayType" => $display, "paramSetting" => $this->_mainParam));
     return $viewModel;
 }
예제 #15
0
 public function listAction()
 {
     $grid = $this->seoGrid;
     $grid->execute();
     $view = new ViewModel();
     $view->addChild($grid->getResponse(), 'grid');
     $view->setVariable('addSeoForm', $this->seoForm);
     return $view;
 }
예제 #16
0
 public function indexAction()
 {
     $permission = [];
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     if ($auth->hasRole(Roles::ROLE_CONTENT_EDITOR_PRODUCT)) {
         $permission[] = 3;
     }
     if ($auth->hasRole(Roles::ROLE_CONTENT_EDITOR_TEXTLINE)) {
         $permission[] = 1;
     }
     if ($auth->hasRole(Roles::ROLE_CONTENT_EDITOR_LOCATION)) {
         $permission[] = 2;
     }
     if (empty($permission)) {
         return $this->redirect()->toRoute('backoffice/default', ['controller' => 'home']);
     }
     $router = $this->getEvent()->getRouter();
     $ajaxSourceUrl = $router->assemble(['controller' => 'translation', 'action' => 'get-translation-json'], ['name' => 'backoffice/default']);
     /**
      * @var \DDD\Service\Translation
      */
     $service = $this->getTranslationService();
     $pageTypesList = $service->getUniversalPages();
     sort($permission);
     $form = new SearchTranslationForm('search-translation', $pageTypesList, $permission);
     $viewStatstics = 'no';
     $viewStatsticsLang = '';
     $viewStatsticsType = '';
     $params = $this->params()->fromRoute('id', '');
     if ($params != '') {
         $param = explode('-', $params);
         $translationType = isset($param[0]) && $param[0] != '' ? (int) $param[0] : '';
         $translationStatus = isset($param[1]) && $param[1] != '' ? $param[1] : '';
         $translationLang = isset($param[2]) && $param[2] != '' ? $param[2] : '';
         if ($translationType != '') {
             $category = $form->get('category');
             $category->setValue($translationType);
         }
         if ($translationStatus != '') {
             $status = $form->get('status');
             $status->setValue($translationStatus);
         }
         $viewStatstics = 'yes';
         $viewStatsticsLang = $translationLang;
         $viewStatsticsType = $translationType;
     }
     $formTemplate = 'form-templates/search-translation';
     //Source code
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form]);
     $viewModelForm->setTemplate($formTemplate);
     $viewModel = new ViewModel(['ajaxSourceUrl' => $ajaxSourceUrl, 'viewStatstics' => $viewStatstics, 'viewStatsticsLang' => $viewStatsticsLang, 'viewStatsticsType' => $viewStatsticsType, 'permission' => in_array(1, $permission) ? 1 : 2, 'hasCreatorRole' => $auth->hasRole(Roles::ROLE_UNIVERSAL_TEXTLINE_CREATOR)]);
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('backoffice/translation/index');
     return $viewModel;
 }
 function multipleViewModelsAction()
 {
     // Alternative layout
     $layoutViewModel = $this->layout();
     $layoutViewModel->setTemplate('layout/another');
     $sidebar = new ViewModel();
     $sidebar->setTemplate('layout/footer_one');
     $layoutViewModel->addChild($sidebar, 'footer');
     // set up action view model and associated child view models
     $result = new ViewModel();
     $result->setTemplate('application/view/another-action');
     $comments = new ViewModel();
     $comments->setTemplate('application/view/child-comments');
     $result->addChild($comments, 'child_comments');
     $comments = new ViewModel();
     $comments->setTemplate('application/view/another-child');
     $result->addChild($comments, 'another_child');
     return $result;
 }
예제 #18
0
 public function indexAction()
 {
     /**
      * @var Booking\BookingManagement $bookingManagementService
      */
     $bookingManagementService = $this->getServiceLocator()->get('service_booking_management');
     $searchFormResources = $bookingManagementService->prepareSearchFormResources();
     $form = new SearchReservationForm('search-reservation', $searchFormResources);
     $doSearchOnLoad = 0;
     if ($apartmentId = $this->params()->fromRoute('apartment')) {
         $form->get('product_id')->setValue($apartmentId);
         $apartmentFullAddressDomain = $this->getServiceLocator()->get('service_accommodations')->getAppartmentFullAddressByID($apartmentId);
         $apartmentFullAddress = $apartmentFullAddressDomain->getFullAddress();
         $form->get('product')->setValue($apartmentFullAddress);
         $doSearchOnLoad = 1;
     }
     if ($email = $this->params()->fromRoute('email')) {
         $form->get('guest_email')->setValue($email);
         if ($status = $this->params()->fromRoute('status')) {
             $form->get('status')->setValue(1);
         } else {
             $form->get('status')->setValue(Constants::NOT_BOOKED_STATUS);
         }
         $doSearchOnLoad = 1;
     }
     if ($groupId = $this->params()->fromQuery('group')) {
         /**
          * @var \DDD\Dao\ApartmentGroup\ApartmentGroup $apartmentGroupDao
          */
         $apartmentGroupDao = $this->getServiceLocator()->get('dao_apartment_group_apartment_group');
         $apartmentGroupData = $apartmentGroupDao->getRowById($groupId);
         if ($apartmentGroupData) {
             $form->get('group_id')->setValue($groupId);
             $form->get('group')->setValue($apartmentGroupData->getName());
             $doSearchOnLoad = 1;
         }
     }
     $queryParams = $this->params()->fromQuery();
     if (count($queryParams)) {
         $form = $this->fillSearchFormByParameters($form, $queryParams);
     }
     $isDevTest = false;
     $auth = $this->getServiceLocator()->get('library_backoffice_auth');
     if ($auth->hasRole(Roles::ROLE_DEVELOPMENT_TESTING)) {
         $isDevTest = true;
     }
     //Source code
     $viewModelForm = new ViewModel();
     $viewModelForm->setVariables(['form' => $form, 'isDevTest' => $isDevTest]);
     $viewModelForm->setTemplate('form-templates/search-reservation');
     $viewModel = new ViewModel(['doSearchOnLoad' => $doSearchOnLoad]);
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('backoffice/booking/index');
     return $viewModel;
 }
예제 #19
0
 public function viewAction()
 {
     $pim = $this->getServiceLocator()->get('PostIdentityMap');
     $postId = $this->getEvent()->getRouteMatch()->getParam('postId');
     //        $pdm->getPostById($postId);
     $viewObj = new ViewModel(array('title' => 'Main Content', 'content' => 'Actual content'));
     $widgetObj = new ViewModel();
     $widgetObj->setTemplate('post/widget');
     $viewObj->addChild($widgetObj, 'widget');
     return $viewObj;
 }
예제 #20
0
 public function indexAction()
 {
     $calendarViewModel = $this->forward()->dispatch('Calendar\\Controller\\Calendar', ['action' => 'index']);
     $calendarViewModel->setCaptureTo('calendar');
     $dateStart = $calendarViewModel->getVariable('dateStart');
     $dateNow = $calendarViewModel->getVariable('dateNow');
     $user = $calendarViewModel->getVariable('user');
     $this->redirectBack()->setOrigin('frontend');
     $viewModel = new ViewModel(array('dateStart' => $dateStart, 'dateNow' => $dateNow, 'user' => $user));
     $viewModel->addChild($calendarViewModel);
     return $viewModel;
 }
예제 #21
0
 /**
  * @return $this
  * @throws NotifyException
  */
 public function send()
 {
     //VIEW
     //	create and configure view
     $child = new ViewModel(array('user' => $this->params->recipients, 'password' => $this->params->password));
     $child->setTemplate('script');
     $layout = new ViewModel();
     $layout->setTemplate('layout');
     $layout->addChild($child, 'content');
     $phpRenderer = new PhpRenderer();
     $phpRenderer->setCanRenderTrees(true);
     $resolver = new Resolver\TemplateMapResolver();
     $resolver->setMap(array('layout' => __DIR__ . '/../../../view/layout/email.phtml', 'script' => __DIR__ . '/../../../view/email/lost-password.phtml'));
     $phpRenderer->setResolver($resolver);
     foreach ($layout as $child) {
         $child->setOption('has_parent', true);
         $result = $phpRenderer->render($child);
         $child->setOption('has_parent', null);
         $capture = $child->captureTo();
         if (!empty($capture)) {
             $layout->setVariable($capture, $result);
         }
     }
     $result = new Mail();
     $result->name = $this->params->recipients->name;
     $result->email = $this->params->recipients->email;
     $result->subject = "Nýtt lykilorð";
     $result->body = $phpRenderer->render($layout);
     $result->type = 'Password';
     $result->test = true;
     //MAIL
     //	now we want to send this to the user/quest via e-mail
     //	so we try to connect to Queue and send a message
     //	to mail_queue
     try {
         $connection = $this->queueFactory->createConnection();
         $channel = $connection->channel();
         $channel->queue_declare('mail_queue', false, true, false, false);
         $msg = new AMQPMessage($result->serialize(), ['delivery_mode' => 2]);
         $this->logger->info($this->params->recipients->name . " is requesting new password");
         $channel->basic_publish($msg, '', 'mail_queue');
     } catch (\Exception $e) {
         throw new NotifyException($e->getMessage(), 0, $e);
     } finally {
         if (isset($channel) && $channel) {
             $channel->close();
         }
         if (isset($connection) && $connection) {
             $connection->close();
         }
     }
     return $this;
 }
예제 #22
0
 public function onBootstrap(MvcEvent $e)
 {
     // You may not need to do this if you're doing it elsewhere in your
     // application
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     //subnav
     $subNavView = new ViewModel();
     $subNavView->setTemplate('Blvd/View/Helper/Subnav');
     $subNavView->addChild($subNavView, 'subNav');
 }
예제 #23
0
 public function viewAction()
 {
     $this->layout()->setTemplate('layout/new_layout');
     $view = new ViewModel();
     $view->setTemplate('mod2/test_template2');
     $view->setVariables(array('var1' => 12, 'var2' => 34, 'var3' => 56));
     $sideblockView = new ViewModel();
     $sideblockView->setTemplate('mod2/test_template1');
     $sideblockView->setVariables(array('banner1' => 'foto_1', 'banner2' => 'foto_2', 'banner3' => 'foto_3'));
     $view->addChild($sideblockView, 'sideblock');
     return $view;
 }
 /**
  * List of all records
  */
 public function indexAction()
 {
     $grid = $this->createGrid();
     $grid->render();
     $response = $grid->getResponse();
     if ($grid->isHtmlInitReponse()) {
         $view = new ViewModel();
         $view->addChild($response, 'grid');
         return $view;
     } else {
         return $response;
     }
 }
예제 #25
0
 public function testCanMergeChildModelsWithoutCaptureToValues()
 {
     $this->renderer->setMergeUnnamedChildren(true);
     $root = new ViewModel(array('foo' => 'bar'));
     $child1 = new ViewModel(array('foo' => 'baz'));
     $child2 = new ViewModel(array('foo' => 'bar'));
     $child1->setCaptureTo(false);
     $child2->setCaptureTo('child2');
     $root->addChild($child1)->addChild($child2);
     $expected = array('foo' => 'baz', 'child2' => array('foo' => 'bar'));
     $test = $this->renderer->render($root);
     $this->assertEquals(json_encode($expected), $test);
 }
 /**
  * List of all records
  */
 public function indexAction()
 {
     // prepare the datagrid
     $this->datagrid->render();
     // get the datagrid ready to be shown in the template view
     $response = $this->datagrid->getResponse();
     if ($this->datagrid->isHtmlInitReponse()) {
         $view = new ViewModel();
         $view->addChild($response, 'grid');
         return $view;
     } else {
         return $response;
     }
 }
예제 #27
0
 /**
  * Wraps result view model in sporktools model layout model. 
  * 
  * @param MvcEvent $event
  */
 public function injectLayout(MvcEvent $event)
 {
     $result = $event->getResult();
     if (!$result instanceof ViewModel) {
         return;
     }
     if ($result->terminate()) {
         return;
     }
     $event->getApplication()->getServiceManager()->get('viewHelperManager')->get('headLink')->appendStylesheet('/sporktools/style');
     $layout = new ViewModel();
     $layout->setTemplate('spork-tools/layout');
     $layout->addChild($result);
     $event->setResult($layout);
 }
예제 #28
0
 public function indexAction()
 {
     $view = new ViewModel(array('posts' => $this->postService->postMapper));
     $layout = $this->layout();
     $headerView = new ViewModel(array('message' => 'header'));
     $headerView->setTemplate('template/header/header.phtml');
     $sidebarView = new ViewModel(array('allposts' => $this->formatTargetPosts($this->postService->findAllPosts(0))));
     $sidebarView->setTemplate('template/sidebar/sidebar.phtml');
     $layout->addChild($headerView, '_headerView');
     $view->addChild($sidebarView, '_sidebarView');
     //        $this->emailService->postEmail("this is a Post");
     $this->emailService->sendTweet("this is a Tweet");
     //        $this->emialService->getEventManager()->attach('testEmail', function ($e) use ($log) {});
     return $view;
 }
예제 #29
0
 /**
  * Controls the admin dashboard page.
  *
  * @return ViewModel
  */
 public function indexAction()
 {
     /* @var \Core\EventManager\EventManager $events
      * @var AdminControllerEvent $event */
     $events = $this->serviceLocator->get('Core/AdminController/Events');
     $event = $events->getEvent(AdminControllerEvent::EVENT_DASHBOARD, $this);
     $events->trigger($event);
     $model = new ViewModel();
     $widgets = [];
     foreach ($event->getViewModels() as $name => $child) {
         $model->addChild($child, $name);
         $widgets[] = $name;
     }
     $model->setVariable('widgets', $widgets);
     return $model;
 }
 public function __invoke(MvcEvent $event)
 {
     $model = $event->getResult();
     if (!$model instanceof ViewModel) {
         return;
     }
     if (strpos($model->getTemplate(), 'error') === false) {
         return;
     }
     $result = $event->getResult();
     $error = $event->getError();
     $layout = new ViewModel();
     $layout->setTemplate('layout/layout');
     $content = new ViewModel();
     if ($error == 'error-exception') {
         $content->setVariable('reason', 'The site seems to be experiencing problems, please try again later');
         $content->setTemplate('error/knc-exception');
     } else {
         $content->setVariable('reason', 'The site cannot find the url in the address bar');
         $content->setTemplate('error/knc-error');
     }
     $layout->addChild($content);
     $layout->setTerminal(true);
     $event->setViewModel($layout);
     $event->setResult($layout);
     return false;
 }