/** * {@inheritdoc} */ public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); if (isset($operations['edit'])) { $destination = drupal_get_destination(); $operations['edit']['query'] = $destination; } return $operations; }
/** * @covers ::getOperations */ public function testGetOperations() { $operation_name = $this->randomMachineName(); $operations = array($operation_name => array('title' => $this->randomMachineName())); $this->moduleHandler->expects($this->once())->method('invokeAll')->with('entity_operation', array($this->role))->will($this->returnValue($operations)); $this->moduleHandler->expects($this->once())->method('alter')->with('entity_operation'); $this->container->set('module_handler', $this->moduleHandler); $this->role->expects($this->any())->method('access')->will($this->returnValue(AccessResult::allowed())); $this->role->expects($this->any())->method('hasLinkTemplate')->will($this->returnValue(TRUE)); $url = $this->getMockBuilder('\\Drupal\\Core\\Url')->disableOriginalConstructor()->getMock(); $url->expects($this->any())->method('toArray')->will($this->returnValue(array())); $this->role->expects($this->any())->method('urlInfo')->will($this->returnValue($url)); $list = new EntityListBuilder($this->entityType, $this->roleStorage, $this->moduleHandler); $list->setStringTranslation($this->translationManager); $operations = $list->getOperations($this->role); $this->assertInternalType('array', $operations); $this->assertArrayHasKey('edit', $operations); $this->assertInternalType('array', $operations['edit']); $this->assertArrayHasKey('title', $operations['edit']); $this->assertArrayHasKey('delete', $operations); $this->assertInternalType('array', $operations['delete']); $this->assertArrayHasKey('title', $operations['delete']); $this->assertArrayHasKey($operation_name, $operations); $this->assertInternalType('array', $operations[$operation_name]); $this->assertArrayHasKey('title', $operations[$operation_name]); }
/** * {@inheritdoc} */ public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); if (isset($operations['edit'])) { $destination = $this->redirectDestination->getAsArray(); $operations['edit']['query'] = $destination; } return $operations; }
/** * {@inheritdoc} */ public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); foreach ($operations as &$operation) { $operation['query'] = $this->redirectDestination->getAsArray(); } return $operations; }
/** * {@inheritdoc} */ public function getOperations(EntityInterface $entity) { $operations = parent::getOperations($entity); if (!$entity->isDefault()) { $operations['set_default'] = ['title' => $this->t('Mark as default'), 'url' => $entity->toUrl('set-default'), 'parameter' => $entity]; } return $operations; }