/** * Checks if a delete operation is allowed * * @param object $entity * @param ObjectManager $em * @throws ForbiddenException if a delete operation is forbidden */ protected function checkPermissions($entity, ObjectManager $em) { if ($this->ownerDeletionManager->isOwner($entity) && $this->ownerDeletionManager->hasAssignments($entity)) { throw new ForbiddenException('has assignments'); } }
public function testIsOwner() { $this->assertEquals(true, $this->ownerDeletionManager->isOwner(new TestOwnerEntity())); $this->assertEquals(false, $this->ownerDeletionManager->isOwner(new TestEntity())); }