/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aRole) { $this->aRole->removeRolePermission($this); } if (null !== $this->aPermission) { $this->aPermission->removeRolePermission($this); } $this->role_id = null; $this->permission_id = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
$role->setName("SYS-ADMIN"); $role->save(); echo "Role created: " . $role->getName() . "<br/>"; } $role = $cerberus->getRole("SYS-ADMIN"); $user->addRole($role); $user->save(); // setting permissions if (!$cerberus->permissionExists("users-view")) { $permission = new Cerberus\Model\Permission(); $permission->setName("users-view"); $permission->save(); echo "Permission created: " . $permission->getName() . "<br/>"; } if (!$cerberus->permissionExists("users-edit")) { $permission = new Cerberus\Model\Permission(); $permission->setName("users-edit"); $permission->save(); echo "Permission created: " . $permission->getName() . "<br/>"; } $permission1 = $cerberus->getPermission("users-view"); $permission2 = $cerberus->getPermission("users-edit"); $role->addPermission($permission1); $role->addPermission($permission2); $role->save(); echo "User updated: " . $user->getUpdateDate()->format('Y-m-d H:i:s') . "<br/>"; echo "Role Updated: " . $user->getUpdateDate()->format('Y-m-d H:i:s') . "<br/>"; // authenticate a user by its password $me = $cerberus->getUser("admin"); $password = "******"; $result = $me->authenticate($password) ? "Yes" : "No";
/** * Clears the current object, sets all attributes to their default values and removes * outgoing references as well as back-references (from other objects to this one. Results probably in a database * change of those foreign objects when you call `save` there). */ public function clear() { if (null !== $this->aPermissionRelatedByParentId) { $this->aPermissionRelatedByParentId->removePermissionRelatedById($this); } $this->id = null; $this->name = null; $this->create_date = null; $this->description = null; $this->update_date = null; $this->status = null; $this->parent_id = null; $this->alreadyInSave = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
/** * Exclude object from result * * @param ChildPermission $permission Object to remove from the list of results * * @return $this|ChildPermissionQuery The current query, for fluid interface */ public function prune($permission = null) { if ($permission) { $this->addUsingAlias(PermissionTableMap::COL_ID, $permission->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Filter the query by a related \Alchemy\Component\Cerberus\Model\Permission object * * @param \Alchemy\Component\Cerberus\Model\Permission|ObjectCollection $permission The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildRolePermissionQuery The current query, for fluid interface */ public function filterByPermission($permission, $comparison = null) { if ($permission instanceof \Alchemy\Component\Cerberus\Model\Permission) { return $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permission->getId(), $comparison); } elseif ($permission instanceof ObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(RolePermissionTableMap::COL_PERMISSION_ID, $permission->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByPermission() only accepts arguments of type \\Alchemy\\Component\\Cerberus\\Model\\Permission or Collection'); } }