예제 #1
0
파일: User.php 프로젝트: blitzik/CMS
 /**
  * @return array
  */
 public function getRoles()
 {
     $rolesEntities = $this->roles->toArray();
     $roles = [];
     foreach ($rolesEntities as $role) {
         $roles[$role->getId()] = $role->getName();
     }
     return $roles;
 }
예제 #2
0
파일: User.php 프로젝트: Maksold/platform
 /**
  * {@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));
 }
예제 #3
0
파일: Role.php 프로젝트: bouna7/UserBundle
 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);
 }
예제 #4
0
파일: User.php 프로젝트: xamin123/platform
 /**
  * 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;
 }
예제 #5
0
파일: Mailbox.php 프로젝트: woei66/platform
 /**
  * @param Role $role
  *
  * @return $this
  */
 public function removeAuthorizedRole(Role $role)
 {
     $this->authorizedRoles->removeElement($role);
     return $this;
 }
예제 #6
0
파일: Facet.php 프로젝트: ngydat/CoreBundle
 public function removeRole(Role $role)
 {
     $this->roles->removeElement($role);
 }
예제 #7
0
파일: User.php 프로젝트: 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']));
 }
예제 #8
0
파일: User.php 프로젝트: ngydat/CoreBundle
 /**
  * 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);
     }
 }
예제 #9
0
 /**
  * @param Role $role
  */
 public function addRole(Role $role)
 {
     if (!$this->roles->contains($role)) {
         $this->roles->add($role);
     }
 }
예제 #10
0
 /**
  * Remove children
  *
  * @param \Bigfish\Bundle\UserBundle\Entity\Role $children
  */
 public function removeChild(\Bigfish\Bundle\UserBundle\Entity\Role $children)
 {
     $this->children->removeElement($children);
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function hasAuthorizationRole(RoleInterface $role)
 {
     return $this->authorizationRoles->contains($role);
 }
예제 #12
0
 /**
  * Remove role
  *
  * @param \AppBundle\Entity\Role $role
  */
 public function removeRole(\AppBundle\Entity\Role $role)
 {
     $this->roles->removeElement($role);
 }
예제 #13
0
파일: Role.php 프로젝트: sourcevx/Test
 /**
  * Remove child
  *
  * @param \Fp\UserBundle\Entity\Role $child
  */
 public function removeChild(\Fp\UserBundle\Entity\Role $child)
 {
     $this->children->removeElement($child);
 }
예제 #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;
 }
예제 #15
0
 public function addRole(Movie $movie, $roles = null)
 {
     $roles = is_array($roles) ? $roles : [];
     $this->roles->add(new Role($this, $movie, $roles));
 }
예제 #16
0
 /**
  * @return Role[]
  */
 public function getAuthorizedRoles()
 {
     return $this->authorizedRoles->toArray();
 }