src/Command/UserEditCommand.php
protected function editor(User $user)
    {
        // store props
        $oldProps = new UserUpdater($user);
        $newProps = $this->getNewValues($user);

        // confirm
        $ln = <<<EOL
Summary
-------
Username: "{$newProps->getUsername()}"
Email:    "{$newProps->getEmail()}"
Password: "{$newProps->getPassword()}"
EOL;
        $this->logger->block($ln);

        // check changes
        $changedValues = $oldProps->getChanged($newProps);
        if (empty($changedValues)) {
            $this->logger->note('Nothing changed, exiting.');

            return;
        }
        // persist
        if ($persist = $this->ask(new ConfirmationQuestion('Confirm user update?'))) {
            $this->userEditor->updateUser($user, $newProps);
            $this->logger->success('User updated!');
        }
        // send mail
        if ($persist) {
            $dontSend = 'Don\'t send';
            $emailChoices = [$dontSend, $oldProps->getEmail()];
            if (isset($changedValues['email'])) {
                $emailChoices[] = $changedValues['email'];
            }
            $to = $this->ask(new ChoiceQuestion('Send notification to', $emailChoices));
            if ($to !== $dontSend) {
                $this->sendNotification($to, $changedValues);
            }
        }
    }
protected function editor(User $user)
    {
        // store props
        $oldProps = new UserUpdater($user);
        $newProps = $this->getNewValues($user);

        // confirm
        $ln = <<<EOL
Summary
-------
Username: "{$newProps->getUsername()}"
Email:    "{$newProps->getEmail()}"
Password: "{$newProps->getPassword()}"
EOL;
        $this->logger->block($ln);

        // check changes
        $changedValues = $oldProps->getChanged($newProps);
        if (empty($changedValues)) {
            $this->logger->note('Nothing changed, exiting.');

            return;
        }
        // persist
        if ($persist = $this->ask(new ConfirmationQuestion('Confirm user update?'))) {
            $this->userEditor->updateUser($user, $newProps);
            $this->logger->success('User updated!');
        }
        // send mail
        if ($persist) {
            $dontSend = 'Don\'t send';
            $emailChoices = [$dontSend, $oldProps->getEmail()];
            if (isset($changedValues['email'])) {
                $emailChoices[] = $changedValues['email'];
            }
            $to = $this->ask(new ChoiceQuestion('Send notification to', $emailChoices));
            if ($to !== $dontSend) {
                $this->sendNotification($to, $changedValues);
            }
        }
    }
protected function editor ( User $ user ) { // store props $ oldProps = new UserUpdater ( $ user ) ; $ newProps = $ this -> getNewValues ( $ user ) ; // confirm $ ln =  <<<EOL
Summary
-------
Username: "{$newProps->getUsername()}"
Email:    "{$newProps->getEmail()}"
Password: "{$newProps->getPassword()}"
EOL ; $ this -> logger -> block ( $ ln ) ; // check changes $ changedValues = $ oldProps -> getChanged ( $ newProps ) ; if ( empty ( $ changedValues ) ) { $ this -> logger -> note ( 'Nothing changed, exiting.' ) ; return ; } // persist if ( $ persist = $ this -> ask ( new ConfirmationQuestion ( 'Confirm user update?' ) ) ) { $ this -> userEditor -> updateUser ( $ user , $ newProps ) ; $ this -> logger -> success ( 'User updated!' ) ; } // send mail if ( $ persist ) { $ dontSend = 'Don\'t send' ; $ emailChoices = [ $ dontSend , $ oldProps -> getEmail ( ) ] ; if ( isset ( $ changedValues [ 'email' ] ) ) { $ emailChoices [ ] = $ changedValues [ 'email' ] ; } $ to = $ this -> ask ( new ChoiceQuestion ( 'Send notification to' , $ emailChoices ) ) ; if ( $ to !== $ dontSend ) { $ this -> sendNotification ( $ to , $ changedValues ) ; } } }
Show user editor

@param User $user
Show user editor