/**
  * {@inheritdoc}
  */
 public function handle(MassActionHandlerArgs $args)
 {
     $massAction = $args->getMassAction();
     $options = $massAction->getOptions()->toArray();
     if (empty($options['entity_name'])) {
         throw new InvalidArgumentException('Entity name is missing.');
     }
     $entityIdentifier = $this->doctrineHelper->getSingleIdentifierFieldName($options['entity_name']);
     $entityIds = $this->getIdsFromResult($args->getResults(), $entityIdentifier);
     $entities = $this->doctrineHelper->getEntitiesByIds($options['entity_name'], $entityIds);
     return new MassActionResponse(true, null, array('entities' => $entities, 'entity_name' => $options['entity_name'], 'options' => $options));
 }
示例#2
0
 public function testGetEntitiesByIdsForEmptyArray()
 {
     $className = 'TestEntity';
     $this->assertEquals(array(), $this->doctrineHelper->getEntitiesByIds($className, array()));
 }
示例#3
0
 /**
  * @param string $entityName
  * @param array  $entityIds
  * @return EntityData
  */
 public function createEntityDataByIds($entityName, array $entityIds)
 {
     $entities = $this->doctrineHelper->getEntitiesByIds($entityName, $entityIds);
     return $this->createEntityData($entityName, $entities);
 }