Elcodi\Component\Geo\Command\LocationLoadCommand::execute PHP Method

execute() protected method

This command loads all the locations for the received country.
protected execute ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer | null | void
$input Symfony\Component\Console\Input\InputInterface The input interface
$output Symfony\Component\Console\Output\OutputInterface The output interface
return integer | null | void
    protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->startCommand($output);
        $countries = $this->getCountriesFromInput($input);
        foreach ($countries as $countryCode) {
            $countryCode = strtoupper($countryCode);
            if ($input->getOption('drop-if-exists')) {
                $this->deleteCountry($input, $output, $countryCode);
            }
            try {
                $this->locationLoader->loadCountry($countryCode);
                $this->printMessage($output, 'Geo', 'Country ' . $countryCode . ' loaded from repository');
            } catch (Exception $exception) {
                $this->printMessageFail($output, 'Geo', 'Country ' . $countryCode . ' cannot be loaded from repository');
            }
        }
        $this->finishCommand($output);
    }