コード例 #1
0
 /**
  * @param BuildBefore $event
  */
 public function onBuildBefore(BuildBefore $event)
 {
     $config = $event->getConfig();
     // get root entity
     $rootEntity = null;
     $rootEntityAlias = null;
     $from = $config->offsetGetByPath('[source][query][from]');
     if ($from) {
         $firstFrom = current($from);
         if (!empty($firstFrom['table']) && !empty($firstFrom['alias'])) {
             $rootEntity = $this->updateEntityClass($firstFrom['table']);
             $rootEntityAlias = $firstFrom['alias'];
         }
     }
     $groupBy = $config->offsetGetByPath('[source][query][groupBy]', null);
     if (!$rootEntity || !$rootEntityAlias || $groupBy) {
         return;
     }
     // whether entity has active workflow and entity should render workflow step field
     $isShowWorkflowStep = $this->workflowManager->hasApplicableWorkflowByEntityClass($rootEntity) && $this->isShowWorkflowStep($rootEntity);
     // check whether grid contains workflow step column
     $columns = $config->offsetGetByPath('[columns]', array());
     $workflowStepColumns = array_intersect($this->workflowStepColumns, array_keys($columns));
     // remove workflow step if it must be hidden but there are workflow step columns
     if (!$isShowWorkflowStep && $workflowStepColumns) {
         $this->removeWorkflowStep($config, $workflowStepColumns);
     }
     // add workflow step if it must be shown and there are no workflow step columns
     if ($isShowWorkflowStep && empty($workflowStepColumns)) {
         $this->addWorkflowStep($config, $rootEntity, $rootEntityAlias);
     }
 }
コード例 #2
0
 /**
  * Check for workflow instances
  *
  * @param string $entityClass
  * @return bool
  */
 public function hasWorkflow($entityClass)
 {
     if (!$entityClass) {
         return false;
     }
     return $this->workflowManager->hasApplicableWorkflowByEntityClass($entityClass);
 }
コード例 #3
0
 /**
  * @param bool $result
  * @dataProvider trueFalseDataProvider
  */
 public function testHasApplicableWorkflowByEntityClass($result)
 {
     $entityClass = 'TestEntity';
     $this->workflowRegistry->expects($this->once())->method('hasActiveWorkflowByEntityClass')->with($entityClass)->will($this->returnValue($result));
     $this->assertEquals($result, $this->workflowManager->hasApplicableWorkflowByEntityClass($entityClass));
 }