/** * @param ChildPermission $permissionRelatedById The ChildPermission object to remove. * @return $this|ChildPermission The current object (for fluent API support) */ public function removePermissionRelatedById(ChildPermission $permissionRelatedById) { if ($this->getPermissionsRelatedById()->contains($permissionRelatedById)) { $pos = $this->collPermissionsRelatedById->search($permissionRelatedById); $this->collPermissionsRelatedById->remove($pos); if (null === $this->permissionsRelatedByIdScheduledForDeletion) { $this->permissionsRelatedByIdScheduledForDeletion = clone $this->collPermissionsRelatedById; $this->permissionsRelatedByIdScheduledForDeletion->clear(); } $this->permissionsRelatedByIdScheduledForDeletion[] = $permissionRelatedById; $permissionRelatedById->setPermissionRelatedByParentId(null); } return $this; }
/** * Remove permission of this object * through the role_permission cross reference table. * * @param ChildPermission $permission * @return ChildRole The current object (for fluent API support) */ public function removePermission(ChildPermission $permission) { if ($this->getPermissions()->contains($permission)) { $rolePermission = new ChildRolePermission(); $rolePermission->setPermission($permission); if ($permission->isRolesLoaded()) { //remove the back reference if available $permission->getRoles()->removeObject($this); } $rolePermission->setRole($this); $this->removeRolePermission(clone $rolePermission); $rolePermission->clear(); $this->collPermissions->remove($this->collPermissions->search($permission)); if (null === $this->permissionsScheduledForDeletion) { $this->permissionsScheduledForDeletion = clone $this->collPermissions; $this->permissionsScheduledForDeletion->clear(); } $this->permissionsScheduledForDeletion->push($permission); } return $this; }