N98\Magento\Command\Customer\CreateCommand::execute PHP Метод

execute() защищенный Метод

protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer | null | void
$input Symfony\Component\Console\Input\InputInterface
$output Symfony\Component\Console\Output\OutputInterface
Результат integer | null | void
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->detectMagento($output, true);
        if (!$this->initMagento()) {
            return;
        }
        $dialog = $this->getHelper('dialog');
        // Email
        $email = $this->getHelper('parameter')->askEmail($input, $output);
        // Password
        $password = $this->getHelper('parameter')->askPassword($input, $output, 'password', false);
        // Firstname
        if (($firstname = $input->getArgument('firstname')) == null) {
            $firstname = $dialog->ask($output, '<question>Firstname:</question>');
        }
        // Lastname
        if (($lastname = $input->getArgument('lastname')) == null) {
            $lastname = $dialog->ask($output, '<question>Lastname:</question>');
        }
        $website = $this->getHelper('parameter')->askWebsite($input, $output);
        // create new customer
        $customer = $this->getCustomerModel();
        $customer->setWebsiteId($website->getId());
        $customer->loadByEmail($email);
        $outputPlain = $input->getOption('format') === null;
        $table = array();
        if (!$customer->getId()) {
            $customer->setWebsiteId($website->getId());
            $customer->setEmail($email);
            $customer->setFirstname($firstname);
            $customer->setLastname($lastname);
            $customer->setPassword($password);
            $customer->save();
            $customer->setConfirmation(null);
            $customer->save();
            if ($outputPlain) {
                $output->writeln('<info>Customer <comment>' . $email . '</comment> successfully created</info>');
            } else {
                $table[] = array($email, $password, $firstname, $lastname);
            }
        } else {
            if ($outputPlain) {
                $output->writeln('<error>Customer ' . $email . ' already exists</error>');
            }
        }
        if (!$outputPlain) {
            $this->getHelper('table')->setHeaders(array('email', 'password', 'firstname', 'lastname'))->renderByFormat($output, $table, $input->getOption('format'));
        }
    }