コード例 #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);
 }
コード例 #2
0
 public function onViewsLoad(GridViewsLoadEvent $event)
 {
     $currentUser = $this->getCurrentUser();
     if (empty($currentUser)) {
         return;
     }
     $gridViews = $event->getGridViews();
     if (empty($gridViews)) {
         return;
     }
     foreach ($gridViews['views'] as &$gridView) {
         if (isset($gridView['filters']['assigneeFullName']) && $gridView['filters']['assigneeFullName'] !== false) {
             if (is_array($gridView['filters']['assigneeFullName'])) {
                 $value = $gridView['filters']['assigneeFullName']['value'];
             } else {
                 $value = $gridView['filters']['assigneeFullName'];
             }
             if (strpos($value, self::FIXTURE_USERNAME) !== false) {
                 $gridView['filters']['assigneeFullName'] = $currentUser->getFirstName() . ' ' . $currentUser->getLastName();
             }
         }
         if (isset($gridView['filters']['watcher']) && $gridView['filters']['watcher']['value'] === self::CURRENT_USER_PLACEHOLDER) {
             $gridView['filters']['watcher']['value'] = sprintf("oro_%d", $currentUser->getId());
         }
     }
     $event->setGridViews($gridViews);
 }