Ejemplo n.º 1
0
Archivo: User.php Proyecto: blitzik/CMS
 /**
  * @return array
  */
 public function getRoles()
 {
     $rolesEntities = $this->roles->toArray();
     $roles = [];
     foreach ($rolesEntities as $role) {
         $roles[$role->getId()] = $role->getName();
     }
     return $roles;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function getRoles()
 {
     $roles = $this->roles->toArray();
     /** @var Group $group */
     foreach ($this->groups as $group) {
         $roles = array_merge($roles, $group->getRoles());
     }
     return array_values(array_unique($roles));
 }
Ejemplo n.º 3
0
 public function __toString()
 {
     if ($this->children->count()) {
         $childNameList = array();
         foreach ($this->children as $child) {
             $childNameList[] = $child->getName();
         }
         return sprintf('%s [%s]', $this->name, implode(', ', $childNameList));
     }
     return sprintf('%s', $this->name);
 }
Ejemplo n.º 4
0
 /**
  * Pass an array or Collection of Role objects and re-set roles collection with new Roles.
  * Type hinted array due to interface.
  *
  * @param  array|Collection $roles Array of Role objects
  *
  * @return User
  * @throws \InvalidArgumentException
  */
 public function setRoles($roles)
 {
     if (!$roles instanceof Collection && !is_array($roles)) {
         throw new \InvalidArgumentException('$roles must be an instance of Doctrine\\Common\\Collections\\Collection or an array');
     }
     $this->roles->clear();
     foreach ($roles as $role) {
         $this->addRole($role);
     }
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * @param Role $role
  *
  * @return $this
  */
 public function removeAuthorizedRole(Role $role)
 {
     $this->authorizedRoles->removeElement($role);
     return $this;
 }
Ejemplo n.º 6
0
 public function removeRole(Role $role)
 {
     $this->roles->removeElement($role);
 }
Ejemplo n.º 7
0
Archivo: User.php Proyecto: j7mbo/aurex
 /**
  * @return Role[]
  *
  * @note Every user must *at least* have ROLE_USER as a role
  */
 public function getRoles()
 {
     return array_unique(array_merge($this->roles->toArray(), ['ROLE_USER']));
 }
Ejemplo n.º 8
0
 /**
  * Replace the old platform roles of a user by a new array.
  *
  * @param $platformRoles
  */
 public function setPlatformRoles($platformRoles)
 {
     $roles = $this->getEntityRoles();
     $removedRoles = array();
     foreach ($roles as $role) {
         if ($role->getType() != Role::WS_ROLE) {
             $removedRoles[] = $role;
         }
     }
     foreach ($removedRoles as $removedRole) {
         $this->roles->removeElement($removedRole);
     }
     foreach ($platformRoles as $platformRole) {
         $this->roles->add($platformRole);
     }
 }
Ejemplo n.º 9
0
 /**
  * @param Role $role
  */
 public function addRole(Role $role)
 {
     if (!$this->roles->contains($role)) {
         $this->roles->add($role);
     }
 }
Ejemplo n.º 10
0
 /**
  * Remove children
  *
  * @param \Bigfish\Bundle\UserBundle\Entity\Role $children
  */
 public function removeChild(\Bigfish\Bundle\UserBundle\Entity\Role $children)
 {
     $this->children->removeElement($children);
 }
Ejemplo n.º 11
0
 /**
  * {@inheritdoc}
  */
 public function hasAuthorizationRole(RoleInterface $role)
 {
     return $this->authorizationRoles->contains($role);
 }
Ejemplo n.º 12
0
 /**
  * Remove role
  *
  * @param \AppBundle\Entity\Role $role
  */
 public function removeRole(\AppBundle\Entity\Role $role)
 {
     $this->roles->removeElement($role);
 }
Ejemplo n.º 13
0
 /**
  * Remove child
  *
  * @param \Fp\UserBundle\Entity\Role $child
  */
 public function removeChild(\Fp\UserBundle\Entity\Role $child)
 {
     $this->children->removeElement($child);
 }
Ejemplo n.º 14
0
 /**
  * (PHP 5 &gt;= 5.1.0)<br/>
  * Returns if an iterator can be created for the current entry.
  * @link http://php.net/manual/en/recursiveiterator.haschildren.php
  * @return bool true if the current entry can be iterated over, otherwise returns false.
  */
 public function hasChildren()
 {
     return $this->children->count() > 0;
 }
Ejemplo n.º 15
0
 public function addRole(Movie $movie, $roles = null)
 {
     $roles = is_array($roles) ? $roles : [];
     $this->roles->add(new Role($this, $movie, $roles));
 }
Ejemplo n.º 16
0
 /**
  * @return Role[]
  */
 public function getAuthorizedRoles()
 {
     return $this->authorizedRoles->toArray();
 }