/** * {@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)); }
public function testGetSingleIdentifierFieldName() { $entityClass = 'stdClass'; $identifier = 'id'; $this->entityManager->expects($this->once())->method('getClassMetadata')->with($entityClass)->will($this->returnValue($this->metadata)); $this->metadata->expects($this->once())->method('getSingleIdentifierFieldName')->will($this->returnValue($identifier)); $this->assertEquals($identifier, $this->doctrineHelper->getSingleIdentifierFieldName($entityClass)); }