src/Kunstmaan/AdminBundle/Entity/GroupPropertiesTrait.php
public function addRole($role)
    {
        if (!$role instanceof Role) {
            throw new InvalidArgumentException('addRole takes a Role object as the parameter');
        }

        if (!$this->hasRole($role->getRole())) {
            $this->roles->add($role);
        }

        return $this;
    }
public function addRole($role)
    {
        if (!$role instanceof Role) {
            throw new InvalidArgumentException('addRole takes a Role object as the parameter');
        }

        if (!$this->hasRole($role->getRole())) {
            $this->roles->add($role);
        }

        return $this;
    }
public function addRole ( $ role ) { if ( ! $ role instanceof Role ) { throw new InvalidArgumentException ( 'addRole takes a Role object as the parameter' ) ; } if ( ! $ this -> hasRole ( $ role -> getRole ( ) ) ) { $ this -> roles -> add ( $ role ) ; } return $ this ; }
Adds a Role object to the ArrayCollection. Can't type hint due to interface so throws Exception.

@param Role $role

@return GroupInterface

@throws InvalidArgumentException
Adds a Role object to the ArrayCollection . Can t type hint due to interface so throws Exception .