public function prepareViewModel(Datagrid $grid)
 {
     parent::prepareViewModel($grid);
     $options = $this->getOptionsRenderer();
     $viewModel = $this->getViewModel();
     $mcvEvent = $grid->getMvcEvent();
     //$routeMatch = $mvcEvent->getRouteMatch(); getMatchedRouteName
     $controller = $mcvEvent->getRouteMatch()->getParam('controller');
     $action = $mcvEvent->getRouteMatch()->getParam('action');
     $routeName = $mcvEvent->getRouteMatch()->getMatchedRouteName();
     $route = array("routeName" => $routeName, "action" => $action, "controller" => $controller);
     //var_dump($route);
     $viewModel->setVariable('main_ruote', $route);
     $viewModel->setVariable('jsCodeElement', $this->getJsCodeElement($grid));
     $viewModel->setVariable('crudform', $grid->getFrmMainCrud());
     $viewModel->setVariable('injectedJsFormCode', $grid->getInjetJsFormCode());
 }
示例#2
0
 public function prepareViewModel(Datagrid $grid)
 {
     parent::prepareViewModel($grid);
     $options = $this->getOptionsRenderer();
     $viewModel = $this->getViewModel();
     // Check if the datarange picker is enabled
     if (isset($options['daterange']['enabled']) && $options['daterange']['enabled'] === true) {
         // load js and stylesheet
         $basePath = $grid->getPluginViewHelperManager()->get('BasePath');
         $grid->getPluginViewHelperManager()->get('HeadLink')->appendStylesheet($basePath->__invoke() . '/css/daterangepicker-bs3.css');
         $grid->getPluginViewHelperManager()->get('HeadScript')->appendFile($basePath->__invoke() . '/js/moment.js');
         $grid->getPluginViewHelperManager()->get('HeadScript')->appendFile($basePath->__invoke() . '/js/daterangepicker.js');
         $dateRangeParameters = $options['daterange']['options'];
         $viewModel->setVariable('daterangeEnabled', true);
         $viewModel->setVariable('additionalButton', $grid->getAdditionalButton());
         $viewModel->setVariable('daterangeParameters', $dateRangeParameters);
         $viewModel->setVariable('twuitterVersion', $grid->getTwitterBoostrapVersion());
         $viewModel->setVariable('uriRedirectJson', $grid->getDefaultUriRedirect());
         $viewModel->setVariable('additionalFilters', $grid->getAdditionalFilter());
     } else {
         $viewModel->setVariable('daterangeEnabled', false);
     }
     $viewModel->setVariable('isAllowAddCrud', $grid->getisAllowAdd());
     $viewModel->setVariable('successMessages', $grid->getPluginControllerManager()->get('flashmessenger')->getSuccessMessages());
     $viewModel->setVariable('errorMessages', $grid->getPluginControllerManager()->get('flashmessenger')->getErrorMessages());
     $viewModel->setVariable('injectedJsCode', $grid->getInjetJsCode());
     $childModel = $grid->getViewChild();
     if ($childModel['ViewModel'] instanceof \Zend\View\Model\ViewModel) {
         $viewModel->addChild($childModel['ViewModel'], $childModel['Position']);
     }
 }