/** * {@inheritdoc} */ public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE) { if ($operation == 'create') { return parent::access($operation, $account, $return_as_object); } return \Drupal::entityManager() ->getAccessControlHandler($this->entityTypeId) ->access($this, $operation, $account, $return_as_object); }
/** * @covers ::access */ public function testAccess() { $access = $this->getMock('\\Drupal\\Core\\Entity\\EntityAccessControllerInterface'); $operation = $this->randomName(); $access->expects($this->at(0))->method('access')->with($this->entity, $operation)->will($this->returnValue(TRUE)); $access->expects($this->at(1))->method('createAccess')->will($this->returnValue(TRUE)); $this->entityManager->expects($this->exactly(2))->method('getAccessController')->will($this->returnValue($access)); $this->assertTrue($this->entity->access($operation)); $this->assertTrue($this->entity->access('create')); }
/** * @covers ::access */ public function testAccess() { $access = $this->getMock('\\Drupal\\Core\\Entity\\EntityAccessControlHandlerInterface'); $operation = $this->randomMachineName(); $access->expects($this->at(0))->method('access')->with($this->entity, $operation)->will($this->returnValue(TRUE)); $access->expects($this->at(1))->method('access')->with($this->entity, $operation)->will($this->returnValue(AccessResult::allowed())); $access->expects($this->at(2))->method('createAccess')->will($this->returnValue(TRUE)); $access->expects($this->at(3))->method('createAccess')->will($this->returnValue(AccessResult::allowed())); $this->entityManager->expects($this->exactly(4))->method('getAccessControlHandler')->will($this->returnValue($access)); $this->assertTrue($this->entity->access($operation)); $this->assertEquals(AccessResult::allowed(), $this->entity->access($operation, NULL, TRUE)); $this->assertTrue($this->entity->access('create')); $this->assertEquals(AccessResult::allowed(), $this->entity->access('create', NULL, TRUE)); }
public function access($operation, AccountInterface $account = NULL, $return_as_object = FALSE) { return parent::access($operation, $account, $return_as_object); // TODO: Change the autogenerated stub }
/** * {@inheritdoc} */ public function access($operation = 'view', AccountInterface $account = NULL, $return_as_object = FALSE) { // This override exists to set the operation to the default value "view". return parent::access($operation, $account, $return_as_object); }
/** * {@inheritdoc} */ public function access($operation = 'view', AccountInterface $account = NULL) { if ($operation == 'create') { return parent::access($operation, $account); } return \Drupal::entityManager()->getAccessController($this->entityTypeId)->access($this, $operation, $this->prepareLangcode(), $account); }