protected function _actionAdd(AnCommandContext  $context)
     {
         $data = $context->data;

         dispatch_plugin('user.onBeforeAddPerson', array('data' => $context->data));

         $person = parent::_actionAdd($context);

         $this->getRepository()
         ->getValidator()
         ->addValidation('givenName', 'required')
         ->addValidation('familyName', 'required')
         ->addValidation('usertype', 'required')
         ->addValidation('username', 'uniqueness')
         ->addValidation('email', 'uniqueness');

         if ($person->validate() === false) {
             throw new AnErrorException($person->getErrors(), AnHttpResponse::BAD_REQUEST);
         }

         $viewer = get_viewer();

         if (in_array($data->usertype, $this->_allowed_user_types)) {
             $person->usertype = $data->usertype;
         } else {
             $person->usertype = ComPeopleDomainEntityPerson::USERTYPE_REGISTERED;
         }

         dispatch_plugin('user.onAfterAddPerson', array('person' => $person));

         if ($person->admin()) {
             $this->registerCallback('after.add', array($this, 'mailAdminsNewAdmin'));
         }
         
         $context->response->setRedirect(route('option=com_people&view=people'));
         
         return $person;
     }
protected function _actionAdd(AnCommandContext  $context)
     {
         $data = $context->data;

         dispatch_plugin('user.onBeforeAddPerson', array('data' => $context->data));

         $person = parent::_actionAdd($context);

         $this->getRepository()
         ->getValidator()
         ->addValidation('givenName', 'required')
         ->addValidation('familyName', 'required')
         ->addValidation('usertype', 'required')
         ->addValidation('username', 'uniqueness')
         ->addValidation('email', 'uniqueness');

         if ($person->validate() === false) {
             throw new AnErrorException($person->getErrors(), AnHttpResponse::BAD_REQUEST);
         }

         $viewer = get_viewer();

         if (in_array($data->usertype, $this->_allowed_user_types)) {
             $person->usertype = $data->usertype;
         } else {
             $person->usertype = ComPeopleDomainEntityPerson::USERTYPE_REGISTERED;
         }

         dispatch_plugin('user.onAfterAddPerson', array('person' => $person));

         if ($person->admin()) {
             $this->registerCallback('after.add', array($this, 'mailAdminsNewAdmin'));
         }
         
         $context->response->setRedirect(route('option=com_people&view=people'));
         
         return $person;
     }
protected function _actionAdd ( AnCommandContext $ context ) { $ data = $ context -> data ; dispatch_plugin ( 'user.onBeforeAddPerson' , array ( 'data' => $ context -> data ) ) ; $ person = parent :: _actionAdd ( $ context ) ; $ this -> getRepository ( ) -> getValidator ( ) -> addValidation ( 'givenName' , 'required' ) -> addValidation ( 'familyName' , 'required' ) -> addValidation ( 'usertype' , 'required' ) -> addValidation ( 'username' , 'uniqueness' ) -> addValidation ( 'email' , 'uniqueness' ) ; if ( $ person -> validate ( ) === false ) { throw new AnErrorException ( $ person -> getErrors ( ) , AnHttpResponse :: BAD_REQUEST ) ; } $ viewer = get_viewer ( ) ; if ( in_array ( $ data -> usertype , $ this -> _allowed_user_types ) ) { $ person -> usertype = $ data -> usertype ; } else { $ person -> usertype = ComPeopleDomainEntityPerson :: USERTYPE_REGISTERED ; } dispatch_plugin ( 'user.onAfterAddPerson' , array ( 'person' => $ person ) ) ; if ( $ person -> admin ( ) ) { $ this -> registerCallback ( 'after.add' , array ( $ this , 'mailAdminsNewAdmin' ) ) ; } $ context -> response -> setRedirect ( route ( 'option=com_people&view=people' ) ) ; return $ person ; }
Person add action creates a new person object.

@param AnCommandContext $context Commaind chain context

@return AnDomainEntityAbstract
Person add action creates a new person object .