Пример #1
0
 /**
  * @param GridViewsLoadEvent $event
  */
 public function onViewsLoad(GridViewsLoadEvent $event)
 {
     $gridName = $event->getGridName();
     $currentUser = $this->getCurrentUser();
     if (!$currentUser) {
         return;
     }
     $gridViews = $this->getGridViewRepository()->findGridViews($this->aclHelper, $currentUser, $gridName);
     if (!$gridViews) {
         return;
     }
     $choices = [];
     $views = [];
     foreach ($gridViews as $gridView) {
         $view = $gridView->createView();
         $view->setEditable($this->securityFacade->isGranted('EDIT', $gridView));
         $view->setDeletable($this->securityFacade->isGranted('DELETE', $gridView));
         $views[] = $view->getMetadata();
         $choices[] = ['label' => $this->createGridViewLabel($currentUser, $gridView), 'value' => $gridView->getId()];
     }
     $newGridViews = $event->getGridViews();
     $newGridViews['choices'] = array_merge($newGridViews['choices'], $choices);
     $newGridViews['views'] = array_merge($newGridViews['views'], $views);
     $event->setGridViews($newGridViews);
 }
 public function onViewsLoad(GridViewsLoadEvent $event)
 {
     $gridName = $event->getGridName();
     $currentUser = $this->getCurrentUser();
     if (empty($currentUser)) {
         return;
     }
     $gridViews = $this->getGridViewRepository()->findGridViews($this->aclHelper, $currentUser, $gridName);
     if (empty($gridViews)) {
         return;
     }
     foreach ($gridViews as $gridView) {
         $filtersData = $gridView->getFiltersData();
         if (isset($filtersData['assigneeFullName']) && $filtersData['assigneeFullName'] !== false) {
             if (strpos($filtersData['assigneeFullName'], self::FIXTURE_USERNAME) !== false) {
                 $filtersData['assigneeFullName'] = $currentUser->getFirstName() . ' ' . $currentUser->getLastName();
                 $gridView->setFiltersData($filtersData);
             }
         }
     }
 }