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

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

        $isFirstUser = !(bool) $this->getService('repos:people.person')
                                    ->getQuery(true)
                                    ->fetchValue('id');

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

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

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

        $viewer = get_viewer();

        if ($isFirstUser) {
            $person->usertype = ComPeopleDomainEntityPerson::USERTYPE_SUPER_ADMINISTRATOR;
        } else {
            $person->usertype = ComPeopleDomainEntityPerson::USERTYPE_REGISTERED;
        }

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

        if ($isFirstUser) {
            $this->registerCallback('after.signup', array($this, 'activateFirstAdmin'));
        } else {
            $context->response->setHeader('X-User-Activation-Required', true);
            $this->setMessage(AnTranslator::sprintf('COM-PEOPLE-PROMPT-ACTIVATION-LINK-SENT', $person->name), 'success');
        }
        
        $this->getResponse()->status = AnHttpResponse::OK;

        return $person;
    }
protected function _actionSignup(AnCommandContext  $context)
    {
        $data = $context->data;

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

        $isFirstUser = !(bool) $this->getService('repos:people.person')
                                    ->getQuery(true)
                                    ->fetchValue('id');

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

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

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

        $viewer = get_viewer();

        if ($isFirstUser) {
            $person->usertype = ComPeopleDomainEntityPerson::USERTYPE_SUPER_ADMINISTRATOR;
        } else {
            $person->usertype = ComPeopleDomainEntityPerson::USERTYPE_REGISTERED;
        }

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

        if ($isFirstUser) {
            $this->registerCallback('after.signup', array($this, 'activateFirstAdmin'));
        } else {
            $context->response->setHeader('X-User-Activation-Required', true);
            $this->setMessage(AnTranslator::sprintf('COM-PEOPLE-PROMPT-ACTIVATION-LINK-SENT', $person->name), 'success');
        }
        
        $this->getResponse()->status = AnHttpResponse::OK;

        return $person;
    }
protected function _actionSignup ( AnCommandContext $ context ) { $ data = $ context -> data ; dispatch_plugin ( 'user.onBeforeAddPerson' , array ( 'data' => $ context -> data ) ) ; $ isFirstUser = ! ( bool ) $ this -> getService ( 'repos:people.person' ) -> getQuery ( true ) -> fetchValue ( 'id' ) ; $ person = parent :: _actionAdd ( $ context ) ; $ this -> getRepository ( ) -> getValidator ( ) -> addValidation ( 'givenName' , 'required' ) -> addValidation ( 'familyName' , 'required' ) -> addValidation ( 'username' , 'uniqueness' ) -> addValidation ( 'email' , 'uniqueness' ) ; if ( $ person -> validate ( ) === false ) { throw new AnErrorException ( $ person -> getErrors ( ) , AnHttpResponse :: BAD_REQUEST ) ; } $ viewer = get_viewer ( ) ; if ( $ isFirstUser ) { $ person -> usertype = ComPeopleDomainEntityPerson :: USERTYPE_SUPER_ADMINISTRATOR ; } else { $ person -> usertype = ComPeopleDomainEntityPerson :: USERTYPE_REGISTERED ; } dispatch_plugin ( 'user.onAfterAddPerson' , array ( 'person' => $ person ) ) ; if ( $ isFirstUser ) { $ this -> registerCallback ( 'after.signup' , array ( $ this , 'activateFirstAdmin' ) ) ; } else { $ context -> response -> setHeader ( 'X-User-Activation-Required' , true ) ; $ this -> setMessage ( AnTranslator :: sprintf ( 'COM-PEOPLE-PROMPT-ACTIVATION-LINK-SENT' , $ person -> name ) , 'success' ) ; } $ this -> getResponse ( ) -> status = AnHttpResponse :: OK ; return $ person ; }
Person signup action creates a new person object.

@param AnCommandContext $context Commaind chain context

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