public function addRole($role)
    {
        if (!$role instanceof Role) {
            //throw new \Exception( "addRole takes a Role object as the parameter" );
            $_role = new Role($role);
        } else {
            $_role = $role;
        }

        if (!$this->hasRole($_role->getRole())) {
            $_role->addUser($this);
            $this->roles->add($_role);
        }
    }
public function addRole($role)
    {
        if (!$role instanceof Role) {
            //throw new \Exception( "addRole takes a Role object as the parameter" );
            $_role = new Role($role);
        } else {
            $_role = $role;
        }

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

@throws \Exception

@param Role $role

@return \FOS\UserBundle\Model\UserInterface|void
Adds a Role OBJECT to the ArrayCollection . Can t type hint due to interface so throws Exception .