/**
  * No index action, return 404 error page
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     $view = new \Zend\View\Model\ViewModel();
     $view->setTemplate('/error/404.phtml');
     $this->getResponse()->setStatusCode(\Zend\Http\Response::STATUS_CODE_404);
     return $view;
 }
 public function dispatchError(MvcEvent $e)
 {
     $sharedManager = $e->getApplication()->getEventManager()->getSharedManager();
     $sharedManager->attach('Zend\\Mvc\\Application', 'dispatch.error', function ($e) {
         if ($e->getParam('exception')) {
             ob_clean();
             //Limpar a tela de erros do php
             header('HTTP/1.1 400 Bad Request');
             $exception = $e->getParam('exception');
             $sm = $e->getApplication()->getServiceManager();
             $config = $sm->get('Config');
             $e->getApplication()->getServiceManager()->get('Controller\\Plugin\\Manager')->get('jsLog')->log($exception, 2);
             $viewModel = new \Zend\View\Model\ViewModel(['exception' => $exception]);
             if ($e->getRequest()->isXmlHttpRequest()) {
                 $viewModel->setTemplate($config['js_library']['error_ajax_exception']);
                 $e->getApplication()->getServiceManager()->get('ViewRenderer')->render($viewModel);
             } else {
                 $viewModel->setTemplate($config['js_library']['error_exception']);
                 echo $e->getApplication()->getServiceManager()->get('ViewRenderer')->render($viewModel);
             }
             /*
              * Com erros handler o codigo continua a ser executado,
              * entao o exit para e so mostra os erros
              */
             exit;
         }
     });
 }
Exemple #3
0
 /**
  * Return view model set up to output given form
  *
  * @param mixed $form Form to render
  * @return \Zend\View\Model\ViewModel
  */
 public function __invoke($form)
 {
     $view = new \Zend\View\Model\ViewModel();
     $view->setTemplate('plugin/PrintForm.php');
     $view->form = $form;
     return $view;
 }
 function renderInstanceFromConfig($instanceConfig)
 {
     $events = $this->calender->getEvents($instanceConfig['categoryId']);
     $view = new \Zend\View\Model\ViewModel(['instanceConfig' => $instanceConfig, 'events' => $events]);
     $view->setTemplate($this->template);
     return $view;
 }
 public function pageAction()
 {
     $this->init();
     //Get the params
     $arcId = $this->params('arc');
     $pageUrl = $this->params('pageUrl');
     //Get the current arc
     $arc = new \ATPComic\Model\Arc();
     $arc->loadByUrl($arcId);
     //Get the current page
     $page = new \ATPComic\Model\Page();
     $page->loadByUrl($pageUrl);
     //Make sure the page is active
     if (!$page->isActive) {
         $this->getResponse()->setStatusCode(404);
         return;
     }
     //Get the arc/page node
     $node = new \ATPComic\Model\Node($arc, $page);
     //Save the current page in the session
     $this->remember->currentComicPage = $node->id;
     $view = new \Zend\View\Model\ViewModel();
     $view->node = $node;
     //Create the page widget
     $comicPage = new \ATPComic\View\Widget\Page();
     $comicPage->node = $node;
     $view->addChild($comicPage, 'comicPage');
     return $view;
 }
 /**
  * @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);
 }
Exemple #7
0
 /**
  * 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;
 }
 public function indexAction()
 {
     $config = $this->getServiceLocator()->get('Config');
     $viewModel = new \Zend\View\Model\ViewModel();
     $viewModel->setVariables(['application' => $config['dragonjsonserver']['application'], 'serverurl' => $config['dragonjsonserver']['serverurl'], 'apiclient' => $config['dragonjsonserverapiclient']])->setTerminal(true);
     return $viewModel;
 }
Exemple #9
0
 public function editAction()
 {
     /**
      * @var \DDD\Service\Parking\Spot $parkingSpotService
      * @var \DDD\Service\Parking\General $parkingGeneralService
      */
     $parkingSpotService = $this->getServiceLocator()->get('service_parking_spot');
     $parkingGeneralService = $this->getServiceLocator()->get('service_parking_general');
     $spots = $parkingSpotService->getParkingSpots($this->parkingLotId);
     $parkingLot = $parkingGeneralService->getParkingById($this->parkingLotId);
     $selectedSpotId = $this->params()->fromRoute('spot_id', 0);
     $viewModel = new \Zend\View\Model\ViewModel();
     $form = new SpotForm($this->parkingLotId, 'parking-spot');
     if ($selectedSpotId) {
         $usages = $parkingSpotService->getUsages($selectedSpotId);
         $parkingSpotDao = $this->getServiceLocator()->get('dao_parking_spot');
         $selectedSpot = $parkingSpotDao->getParkingSpotById($selectedSpotId);
         if (!$selectedSpot) {
             Helper::setFlashMessage(['error' => 'Spot not found']);
             return $this->redirect()->toRoute('parking/spots', ['parking_lot_id' => $this->parkingLotId]);
         }
         $form->prepare();
         $form->populateValues(['id' => $selectedSpot->getId(), 'lot_id' => $selectedSpot->getLotId(), 'unit' => $selectedSpot->getUnit(), 'price' => $selectedSpot->getPrice(), 'permit_id' => $selectedSpot->getPermitId()]);
         $viewModel->setVariables(['usages' => $usages]);
     }
     $viewModel->setVariables(['parkingLotId' => $this->parkingLotId, 'spots' => $spots, 'spotCount' => count($spots), 'form' => $form, 'selectedSpotId' => $selectedSpotId, 'parkingLot' => $parkingLot]);
     return $viewModel;
 }
 public function indexAction()
 {
     $this->noCache();
     $view = new \Zend\View\Model\ViewModel();
     $field = new \ATPContact\Model\Field();
     $view->fields = $field->loadMultiple(array('orderBy' => 'sort_order ASC'));
     $view->addChild(new \ATPCore\View\Widget\FlashWidget($this->flashMessenger()), 'flash');
     return $view;
 }
Exemple #11
0
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Apartment\General $apartmentGeneralService
      * @var \DDD\Service\Apartment\Main $apartmentMainService
      * @var \DDD\Service\Apartment\OTADistribution $apartmentOTAService
      * @var $taskService \DDD\Service\Task
      * @var $bookingTicketService \DDD\Service\Booking\BookingTicket
      */
     $apartmentGeneralService = $this->getServiceLocator()->get('service_apartment_general');
     $apartmentMainService = $this->getServiceLocator()->get('service_apartment_main');
     $apartmentOTAService = $this->getServiceLocator()->get('service_apartment_ota_distribution');
     $taskService = $this->getServiceLocator()->get('service_task');
     $bookingTicketService = $this->getServiceLocator()->get('service_booking_booking_ticket');
     $apartmentTasks = $taskService->getFrontierTasksOnApartment($this->apartmentId);
     $apartmentOTAList = $apartmentOTAService->getOTAList($this->apartmentId);
     $building = $apartmentMainService->getApartmentBuilding($this->apartmentId);
     $apartels = $apartmentMainService->getApartmentApartels($this->apartmentId);
     $bookingDao = new Booking($this->getServiceLocator(), 'ArrayObject');
     $mediaDao = new Media($this->getServiceLocator(), 'ArrayObject');
     $dateDisabled = $currentReservation = $nextReservation = false;
     $apartmentDates = $apartmentMainService->getApartmentDates($this->apartmentId);
     $generalInfo = $apartmentGeneralService->getApartmentGeneral($this->apartmentId);
     if ($this->apartmentStatus == Objects::PRODUCT_STATUS_DISABLED) {
         $dateDisabled = $apartmentDates['disable_date'];
     } else {
         $currentReservation = $bookingDao->getCurrentReservationByAcc($this->apartmentId, date('Y-m-d'));
         $resId = $currentReservation['id'];
         $pin = $currentReservation['pin'];
         $current = true;
         if (!$currentReservation) {
             $nextReservation = $bookingDao->getNextReservationByAcc($this->apartmentId, date('Y-m-d'));
             $resId = $nextReservation['id'];
             $pin = $nextReservation['pin'];
             $current = false;
         }
         if ($resId && $pin) {
             $lockDatas = $bookingTicketService->getLockByReservation($resId, $pin, [LockService::USAGE_APARTMENT_TYPE]);
             foreach ($lockDatas as $key => $lockData) {
                 switch ($key) {
                     case LockService::USAGE_APARTMENT_TYPE:
                         if ($current) {
                             $currentReservation['pin'] = $lockData['code'];
                         } else {
                             $nextReservation['pin'] = $lockData['code'];
                         }
                         break;
                 }
             }
         }
     }
     $img = $mediaDao->getFirstImage($this->apartmentId)['img1'];
     $viewModel = new \Zend\View\Model\ViewModel();
     $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'currentReservation' => $currentReservation, 'nextReservation' => $nextReservation, 'dateCreated' => $apartmentDates['create_date'], 'dateDisabled' => $dateDisabled, 'img' => str_replace('orig', 445, $img), 'OTAList' => $apartmentOTAList, 'building' => $building, 'apartels' => $apartels, 'apartment' => $generalInfo, 'apartmentTasks' => $apartmentTasks]);
     $viewModel->setTemplate('apartment/main/index');
     return $viewModel;
 }
 /** Thêm phần view cho layout */
 public function index05Action()
 {
     echo '<h3 style="color:red; font-weight:bold;">' . __METHOD__ . '</h3>';
     /** get layout obj */
     $layout = $this->layout();
     /** gắn header vào layout */
     $header = new \Zend\View\Model\ViewModel(array('headerContent' => 'asazbauxgasjbdhaxuyzas'));
     $header->setTemplate('mvc\\view-manager\\header');
     $layout->addChild($header, 'header');
 }
Exemple #13
0
 public function checkAuth(MvcEvent $e)
 {
     /* @var $container ContainerInterface */
     $container = $e->getApplication()->getServiceManager();
     /* @var $navigationViewhelper \Zend\View\Helper\Navigation */
     $navigationViewhelper = $container->get('ViewHelperManager')->get('navigation');
     $acl = $navigationViewhelper->getAcl();
     $role = $navigationViewhelper->getRole();
     if (!$acl->isAllowed($role, $e->getRouteMatch()->getMatchedRouteName())) {
         $e->getApplication()->getEventManager()->attach(MvcEvent::EVENT_DISPATCH, function (MvcEvent $e) {
             $e->stopPropagation();
             $response = $e->getResponse();
             $response->setStatusCode(403);
             $viewModel = new \Zend\View\Model\ViewModel();
             $viewModel->setTemplate('error/403');
             $e->getViewModel()->addChild($viewModel);
         }, 2);
     }
 }
     return $this->textContent;
 }
 public function getHtmlMarkup()
 {
     if (!$this->htmlMarkup) {
         // View renderer
         $renderer = $this->getServiceLocator()->get('Zend\\View\\Renderer\\RendererInterface');
         // Email content
         $viewContent = new \Zend\View\Model\ViewModel($this->getModel());
         // The config key has the same name as the Subject Constant
         $viewContent->setTemplate('ckpt_signup');
         // set in module.config.php
         $content = $renderer->render($viewContent);
         // Email layout
         $viewLayout = new \Zend\View\Model\ViewModel(array('content' => $content));
         $viewLayout->setTemplate('layout_ckpt');
         // set in module.config.php
         $htmlMarkup = $renderer->render($viewLayout);
         $this->htmlMarkup = $htmlMarkup;
     }
 public function categoryAction()
 {
     $this->init();
     $catUrl = $this->params('id');
     $category = new \ATPCms\Model\Category();
     $category->loadByUrl($catUrl);
     if (!$category->id) {
         $this->getResponse()->setStatusCode(404);
         return;
     }
     //Create the view
     $view = new \Zend\View\Model\ViewModel();
     $view->category = $category;
     //Create post list widget
     $posts = new \ATPCms\View\Widget\MostRecentPost();
     $posts->category = $category;
     $posts->postCount = 0;
     $view->addChild($posts, 'posts');
     return $view;
 }
Exemple #16
0
 /**
  * @param \Zend\Mvc\MvcEvent $e
  */
 public function onBootstrap(MvcEvent $e)
 {
     date_default_timezone_set('Europe/Madrid');
     $sm = $e->getApplication()->getServiceManager();
     $eventManager = $e->getApplication()->getEventManager();
     $moduleRouteListener = new ModuleRouteListener();
     $moduleRouteListener->attach($eventManager);
     $app = $e->getTarget();
     /* $app->getEventManager()->attach('finish', array($this, 'compressOutput'), 100); */
     try {
         $dbInstance = $sm->get('Zend\\Db\\Adapter\\Adapter');
         $dbInstance->getDriver()->getConnection()->connect();
     } catch (\Exception $ex) {
         $viewModel = $e->getViewModel();
         $viewModel->setTemplate('layout/layout');
         $content = new \Zend\View\Model\ViewModel();
         $content->setTemplate('error/dbconnection');
         $viewModel->setVariable('content', $sm->get('ViewRenderer')->render($content));
         exit($sm->get('ViewRenderer')->render($viewModel));
     }
 }
Exemple #17
0
 /**
  * 分页方法
  * $dql 查询dql语句
  * $maxlist 每页显示条数
  * $pageNumberOld 当前页数
  * */
 public function fenye($dql, $maxlist, $pageNumberOld)
 {
     $firstResult = 0;
     if ($pageNumberOld == null) {
         $pageNumberOld = 1;
     }
     if ($pageNumberOld == 1) {
         $firstResult = 0;
     } else {
         $pageNumberNew = $pageNumberOld * $maxlist;
         $firstResult = $pageNumberNew - $maxlist;
     }
     $entityManager = $this->getEntityManager();
     $query = $entityManager->createQuery($dql)->setFirstResult($firstResult)->setMaxResults($maxlist);
     $paginator = new Paginator($query, $fetchJoinCollection = true);
     $countNumber = count($paginator);
     $bugs = $query->getArrayResult();
     $paginator = new \Zend\Paginator\Paginator(new \Zend\Paginator\Adapter\null($countNumber));
     $paginator->setCurrentPageNumber($pageNumberOld)->setItemCountPerPage($maxlist);
     $vm = new \Zend\View\Model\ViewModel();
     $vm->setVariables(array('paginator' => $paginator, 'bugs' => $bugs));
     return $vm;
 }
Exemple #18
0
 public function indexAction()
 {
     /**
      * @var \DDD\Service\Apartment\Location $apartmentLocationService
      */
     $apartmentLocationService = $this->getServiceLocator()->get('service_apartment_location');
     /* @var $location \DDD\Domain\Apartment\Location\Location */
     $location = $apartmentLocationService->getApartmentLocation($this->apartmentId);
     $preparedData = $this->prepareFormContent($location->getCountryID(), $location->getProvinceID(), $location->getBuildingID());
     $preparedData['countryId'] = $location->getCountryID();
     $form = new LocationForm('apartment_location', $preparedData);
     // Google map configuration
     $config = array('sensor' => 'true', 'div_id' => 'map', 'div_class' => '', 'zoom' => 10, 'width' => "", 'height' => "300px", 'lat' => $location->getX_pos(), 'lon' => $location->getY_pos());
     $map = $this->getServiceLocator()->get('GMaps\\Service\\GoogleMapDragableMarker');
     //getting the google map object using service manager
     $map->initialize($config);
     //loading the config
     $mapHTML = $map->generate();
     //generating the html map content
     $form->populateValues(['longitude' => $location->getY_pos(), 'latitude' => $location->getX_pos(), 'location_description' => $location->getDescriptionText(), 'directions' => $location->getDirectionsText(), 'description_textline' => $location->getDescriptionTextlineID(), 'directions_textline' => $location->getDirectionsTextlineID(), 'country_id' => $location->getCountryID(), 'province_id' => $location->getProvinceID(), 'city_id' => $location->getCityID(), 'building' => $location->getBuildingID(), 'building_section' => $location->getBuildingSectionId(), 'address' => $location->getAddress(), 'postal_code' => $location->getPostalCode(), 'block' => $location->getBlock(), 'floor' => $location->getFloor(), 'unit_number' => $location->getUnitNumber()]);
     // set form type and template
     $formTemplate = 'form-templates/location';
     // passing form and map to the view
     $viewModelForm = new \Zend\View\Model\ViewModel();
     $viewModelForm->setVariables(['form' => $form, 'mapHTML' => $mapHTML, 'apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'countryId' => $location->getCountryID(), 'building' => $location->getBuilding(), 'buildingSectionsShow' => isset($preparedData['buildingSectionOptions']) && $preparedData['buildingSectionOptions'] > 1 ? true : false]);
     //Country Currency List
     $locationService = $this->getServiceLocator()->get('service_location');
     $listCountryWithCurrecny = $locationService->getCountriesWithCurrecny();
     $viewModelForm->setTemplate($formTemplate);
     $viewModel = new \Zend\View\Model\ViewModel();
     $viewModel->setVariables(['apartmentId' => $this->apartmentId, 'apartmentStatus' => $this->apartmentStatus, 'listCountryWithCurrecny' => $listCountryWithCurrecny]);
     // child view to render form
     $viewModel->addChild($viewModelForm, 'formOutput');
     $viewModel->setTemplate('apartment/location/index');
     return $viewModel;
 }
 /**
  * Attempt to change current authenticated AuthAccess email identity if available
  * @param string $sAuthAccessEmailIdentity
  * @throws \InvalidArgumentException
  * @return \BoilerAppAccessControl\Service\AuthAccessService
  */
 public function changeAuthenticatedAuthAccessEmailIdentity($sAuthAccessEmailIdentity)
 {
     if (!is_string($sAuthAccessEmailIdentity)) {
         throw new \InvalidArgumentException('AuthAccess email identity expects string, "' . gettype($sAuthAccessEmailIdentity) . '" given');
     }
     if (!filter_var($sAuthAccessEmailIdentity, FILTER_VALIDATE_EMAIL)) {
         throw new \InvalidArgumentException('AuthAccess email identity expects valid email, "' . $sAuthAccessEmailIdentity . '" given');
     }
     $oAuthAccessRepository = $this->getServiceLocator()->get('BoilerAppAccessControl\\Repository\\AuthAccessRepository');
     if (!$oAuthAccessRepository->isEmailIdentityAvailable($sAuthAccessEmailIdentity)) {
         throw new \InvalidArgumentException('AuthAccess email identity "' . $sAuthAccessEmailIdentity . '" is not available');
     }
     //Update AuthAcces public key
     $oAuthAccess = $this->getServiceLocator()->get('AccessControlService')->getAuthenticatedAuthAccess();
     $oAuthAccessRepository->update($oAuthAccess->setAuthAccessPublicKey($this->getServiceLocator()->get('Encryptor')->create($sPublicKey = $this->getServiceLocator()->get('AccessControlService')->generateAuthAccessPublicKey())));
     //Create email view body
     $oView = new \Zend\View\Model\ViewModel(array('auth_access_email_identity' => $sAuthAccessEmailIdentity, 'auth_access_public_key' => $sPublicKey));
     //Retrieve Messenger service
     $oMessengerService = $this->getServiceLocator()->get('MessengerService');
     //Send email confirmation to user
     $oMessage = new \BoilerAppMessenger\Message\Message();
     $oMessengerService->sendMessage($oMessage->setFrom($oMessengerService->getSystemUser())->setTo($oAuthAccess->getAuthAccessUser())->setSubject($this->getServiceLocator()->get('translator')->translate('confirm_change_email'))->setBody($oView->setTemplate('mail/auth-access/confirm-change-email-identity')), \BoilerAppMessenger\Media\Mail\MailMessageRenderer::MEDIA);
     return $this;
 }
 /**
  * @param HttpRequest $request
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function build(HttpRequest $request, SmartServiceResult $result, $action)
 {
     $viewModel = null;
     if ($request->isXmlHttpRequest()) {
         $viewModel = new JsonModel();
         $viewModel->setTerminal(true);
     } else {
         $viewModel = new \Zend\View\Model\ViewModel();
         $viewModel->setVariable('entity', $result->getEntity());
         $viewModel->setVariable('form', $result->getForm());
         $viewModel->setVariable('list', $result->getList());
         $viewModel->setTemplate(sprintf($this->getTemplate(), $action));
     }
     return $viewModel;
 }
Exemple #21
0
<?php

/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require './vendor/autoload.php';
$vm = new \Zend\View\Model\ViewModel();
$vm->setVariables(array('nom' => 'tintin'));
$vm->setTemplate('liste');
$rendu = new \Zend\View\Renderer\PhpRenderer();
echo $rendu->render($vm);
<?php

require './vendor/autoload.php';
$vm = new \Zend\View\Model\ViewModel(array('nom' => 'tintin'));
$vm->setVariables(array('title' => 'tintin', 'description' => 'bande dessinée', 'link' => 'http://manews.fr'));
$vm->setTemplate('liste');
$resol = new Zend\View\Resolver\TemplateMapResolver(array('liste' => __DIR__ . '/liste.phtml'));
$rendu = new \Zend\View\Renderer\FeedRenderer();
$rendu->setResolver($resol);
echo $rendu->render($vm);
<?php

require './vendor/autoload.php';
$vm = new \Zend\View\Model\ViewModel(array('nom' => 'tintin'));
$vm->setTemplate('liste');
$v = new Zend\View\View();
$v->addRenderingStrategy(function () {
    $resol = new \Zend\View\Resolver\TemplateMapResolver(array('liste' => __DIR__ . '/liste.phtml'));
    $rendu = new \Zend\View\Renderer\PhpRenderer();
    $rendu->setResolver($resol);
    return $rendu;
});
$v->addResponseStrategy(function ($p) {
    $params = $p->getParams();
    $reponse = $params['response'];
    $rendu = $params['result'];
    $reponse->setContent($rendu);
});
$r = new \Zend\Console\Response();
$v->setResponse($r);
try {
    $v->render($vm);
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}
echo $v->getResponse()->getContent();
 /**
  * Set layout script
  *
  * @param \Contentinum\Options\PageOptions $pageOptions            
  * @param Zend\View\Model\ViewModel $layout            
  */
 protected function layoutFile($pageOptions, $layout)
 {
     $layout->setTemplate($pageOptions->getLayout());
 }
 /**
  * Index page action
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     $view = new \Zend\View\Model\ViewModel();
     $view->setTerminal(true);
     return $view;
 }
 /**
  * @param string $sAuthAccessIdentity
  * @throws \InvalidArgumentException
  * @return \BoilerAppAccessControl\Service\RegistrationService
  */
 public function resendConfirmationEmail($sAuthAccessIdentity)
 {
     if (empty($sAuthAccessIdentity) || !is_string($sAuthAccessIdentity)) {
         throw new \InvalidArgumentException(sprintf('AuthAccess identity expects a not empty string, "%s" given', is_scalar($sAuthAccessIdentity) ? $sAuthAccessIdentity : gettype($sAuthAccessIdentity)));
     }
     $oAccessControlService = $this->getServiceLocator()->get('AccessControlService');
     if (!($oAuthAccess = $oAccessControlService->getAuthAccessFromIdentity($sAuthAccessIdentity))) {
         throw new \LogicException(sprintf('AuthAccess with identity "%s" does not exist', $sAuthAccessIdentity));
     }
     //Reset public key
     $oAuthAccess->setAuthAccessPublicKey($this->getServiceLocator()->get('Encryptor')->create($sPublicKey = $oAccessControlService->generateAuthAccessPublicKey()));
     $this->getServiceLocator()->get('BoilerAppAccessControl\\Repository\\AuthAccessRepository')->update($oAuthAccess);
     //Create email view body
     $oView = new \Zend\View\Model\ViewModel(array('auth_access_public_key' => $sPublicKey, 'auth_access_email_identity' => $oAuthAccess->getAuthAccessEmailIdentity()));
     //Retrieve Messenger service
     $oMessengerService = $this->getServiceLocator()->get('MessengerService');
     //Send email confirmation to user
     $oMessage = new \BoilerAppMessenger\Message\Message();
     $oMessengerService->sendMessage($oMessage->setFrom($oMessengerService->getSystemUser())->setTo($oAuthAccess->getAuthAccessUser())->setSubject($this->getServiceLocator()->get('translator')->translate('register'))->setBody($oView->setTemplate('mail/registration/confirm-email')), \BoilerAppMessenger\Media\Mail\MailMessageRenderer::MEDIA);
     return $this;
 }
Exemple #27
0
 /**
  * Rendering params wrap to ajax communication
  *
  * @return string
  */
 public function renderParamsWrap()
 {
     $view = new \Zend\View\Model\ViewModel();
     $view->setTemplate('default-params');
     $view->setVariable('column', $this->getTable()->getParamAdapter()->getColumn());
     $view->setVariable('itemCountPerPage', $this->getTable()->getParamAdapter()->getItemCountPerPage());
     $view->setVariable('order', $this->getTable()->getParamAdapter()->getOrder());
     $view->setVariable('page', $this->getTable()->getParamAdapter()->getPage());
     $view->setVariable('quickSearch', $this->getTable()->getParamAdapter()->getQuickSearch());
     $view->setVariable('rowAction', $this->getTable()->getOptions()->getRowAction());
     return $this->getRenderer()->render($view);
 }
Exemple #28
0
<?php

require "./vendor/autoload.php";
$vm = new \Zend\View\Model\ViewModel(array('nom' => 'tintin', 'title' => 'tintin', 'description' => 'bande dessinée', 'link' => 'http://manewa.fr'));
$vm->setTemplate('testTintin');
$resolv = new \Zend\View\Resolver\TemplateMapResolver(array('testTintin' => __DIR__ . '/tintin.phtml'));
$rendu = new \Zend\View\Renderer\JsonRenderer();
$rendu->setResolver($resolv);
echo $rendu->render($vm);
<?php

require_once './autoloader.php';
use Zend\Mail\Message;
use Zend\Mail\Transport;
use Zend\Di\Di;
use Zend\Di\Config as DiConfig;
$diConfig = array('instance' => array('Zend\\Mail\\Transport\\FileOptions' => array('parameters' => array('path' => __DIR__)), 'Zend\\Mail\\Transport\\File' => array('injections' => array('Zend\\Mail\\Transport\\FileOptions')), 'Zend\\Mail\\Transport\\SmtpOptions' => array('parameters' => array('name' => 'sendgrid', 'host' => 'smtp.sendgrid.net', 'port' => 25, 'connectionClass' => 'login', 'connectionConfig' => array('username' => '*****@*****.**', 'password' => 'password'))), 'Zend\\Mail\\Message' => array('parameters' => array('headers' => 'Zend\\Mail\\Headers', 'Zend\\Mail\\Message::setTo:emailOrAddressList' => '*****@*****.**', 'Zend\\Mail\\Message::setTo:name' => 'EvaEngine', 'Zend\\Mail\\Message::setFrom:emailOrAddressList' => '*****@*****.**', 'Zend\\Mail\\Message::setFrom:name' => 'EvaEngine', 'setBody' => 'Zend\\View\\Renderer\\PhpRenderer::render')), 'Zend\\Mail\\Transport\\Smtp' => array('injections' => array('Zend\\Mail\\Transport\\SmtpOptions'))));
$di = new Di();
$di->configure(new DiConfig($diConfig));
$transport = $di->get('Zend\\Mail\\Transport\\Smtp');
$transport = $di->get('Zend\\Mail\\Transport\\Sendmail');
$transport = $di->get('Zend\\Mail\\Transport\\File');
$message = $di->get('Zend\\Mail\\Message');
$view = new Zend\View\Renderer\PhpRenderer();
$resolver = new Zend\View\Resolver\TemplatePathStack();
$resolver->setPaths(array('mailTemplate' => __DIR__));
$view->setResolver($resolver);
$viewModel = new Zend\View\Model\ViewModel();
$viewModel->setTemplate('mail/template')->setVariables(array('user' => 'AlloVince'));
$message->setSubject("Zend Mail with Template")->setBody($view->render($viewModel));
$transport->send($message);
Exemple #30
0
 /**
  * @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);
 }