Create set of origins and prefixed for a nested array of models.

@param InputInterface $input
@param array          $map

@return \Generator
359039
private function iterate(InputInterface $input, array $map): \Generator
    {
        $values = $input->getValue($map[self::ITERATE_SOURCE], $map[self::ITERATE_ORIGIN]);
        if (empty($values) || !is_array($values)) {
            return [];
        }

        foreach (array_keys($values) as $key) {
            yield $key => $map[self::ORIGIN] . '.' . $key;
        }
    }
328568
public function createObjectStateGroupFromInputStruct(InputStruct $input)
    {
        $objectStateGroup = new Group();

        $objectStateGroup->identifier = $input->identifier;
        $objectStateGroup->defaultLanguage = $input->defaultLanguage;
        $objectStateGroup->name = $input->name;
        $objectStateGroup->description = $input->description;

        $objectStateGroup->languageCodes = array();
        foreach ($input->name as $languageCode => $name) {
            $objectStateGroup->languageCodes[] = $languageCode;
        }

        return $objectStateGroup;
    }
326693
final public function console(InputInterface $input)
    {
        if (!$input) {
            $input = new ArgvInput();
        }
        $application = new Application($this);
        return $application->run($input);
    }
949836
public static function toReadMap($input)
    {
        Arguments::define(Boa::readMap())->check($input);

        if ($input instanceof ReadMapInterface) {
            return $input;
        }

        if (is_array($input)
            || $input instanceof ArrayObject
            || $input instanceof ArrayAccess
        ) {
            return static::toMap($input);
        }

        if ($input instanceof Traversable) {
            return new TraversableLeftFoldable($input);
        }

        throw new CoreException('Unable to build ReadMap');
    }
108254
protected function execute(InputInterface $input, OutputInterface $output)
  {
    $name = strtolower($input->getArgument('name'));
    $table = $input->getOption('table');

    $class = implode('', array_map('ucfirst', explode('_', $name)));

    if ($table == null || $table == '') {
      if ($this->add($name, $class)) {
        return $output->writeln('<info>Migration "' . $class . '" has been successfully created.</info>');
      }

      return $output->writeln('Migration "' . $class . '" already exists.');
    }

    if ($this->add($name, $class, $table)) {
      return $output->writeln('<info>Migration "' . $class . '" has been successfully created.</info>');
    }

    return $output->writeln('Migration "' . $class . '" already exists.');
  }
1298577
protected static function addValidators(InputInterface $input, array $data)
    {
        $hasValidators = isset($data['validates']) && is_array($data['validates']);
        if (! $hasValidators) {
            return;
        }

        foreach ($data['validates'] as $validator => $message) {
            self::checkIfRequired($validator, $input);
            if (!is_array($message)) {
                $message = ['message' => $message];
            }
            $message['form'] = self::$form;
            $input->addValidator($validator, $message);
        }
    }
1297337
protected function execute(InputInterface $input, OutputInterface $output)
    {
        parent::execute($input, $output);
        
        $builder = new EntityBuilder($this->getConfiguration(), $output);
        
        $output->writeln('<info>Start build application!</info>');
        $builder->generateMetadata();
        $output->writeln('<info>Build models from schema file</info>');
        $builder->generateAllModels();
        $output->writeln('<info>Well done! Application was successfully installed!</info>');
    }
364282
protected function init(InputInterface $input, OutputInterface $output)
    {
    	$this->input = $input;
    	$this->output = $output;

    	$this->bbapp = $this->getApplication()->getApplication();
    	$this->entyMgr = $this->bbapp->getEntityManager();

    	$this->siteLabel = $this->input->getOption('site_label');

        if (filter_var($this->input->getOption('site_domain'), FILTER_VALIDATE_URL)) {
            $urlData = parse_url($this->input->getOption('site_domain'));

            if(!empty($urlData['host']) && $urlData['host'] !== null) {
                $this->siteDomain = $urlData['host'].(empty($urlData['port']) ? '' : ':'.$urlData['port']).(empty($urlData['path']) ? '' : $urlData['path']);
            }
        } else {
            throw new \InvalidArgumentException('Invalid site domain format. Example of valid domain: http://backbee.com');
        }

    	return $this;
    }
1207558
public function getArgument(InputInterface $input, $key)
    {
        if ($input->hasArgument($key)) {
            return $input->getArgument($key);
        }

        if (isset($this->arguments[$key])) {
            return $this->arguments[$key];
        }

        return false;
    }
452822
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $themeName = $input->getArgument('theme');
        $kernel = $this->getContainer()->get('kernel');
        $dir = $kernel->locateResource('@' . $themeName);
        $namespace = $kernel
            ->getBundle($themeName)
            ->getNamespace()
        ;
        
        if (null === $this->templateParser) {
            $this->templateParser = new AlTemplateParser($dir . 'Resources/views/Theme', $kernel->getRootDir(), $themeName);
        }

        if (null === $this->templateGenerator) {
            $this->templateGenerator = new AlTemplateGenerator();
        }

        if (null === $this->slotsGenerator) {
            $this->slotsGenerator = new AlSlotsGenerator();
        }
        
        if (null === $this->extensionGenerator) {
            $this->extensionGenerator = new AlExtensionGenerator();
        }

        $baseSlots = array();
        $templates = $this->templateParser->parse();
        $this->addOption('template-name', '', InputOption::VALUE_NONE, '');
        foreach ($templates as $templateFileName => $elements) {
            $templateName = basename($templateFileName, '.html.twig');
            if ($elements['generate_template']) {
                $message = $this->templateGenerator->generateTemplate($dir . 'Resources/config/templates', $themeName, $templateName, $elements['assets']);
                $output->writeln($message);
                
                $slots = $elements['slots'];
                if (!empty($slots)) {
                    $message = $this->slotsGenerator->generateSlots($dir . 'Resources/config/templates/slots', $themeName, $templateName, $slots);
                    $output->writeln($message);
                }
            } else {
                $baseSlots = array_merge($baseSlots, $elements['slots']);
                if ($templateName != 'base') {
                    unset($templates[$templateFileName]);
                }
            }            
        }
        
        if ( ! empty($baseSlots)) {
            $message = $this->slotsGenerator->generateSlots($dir . 'Resources/config/templates/slots', $themeName, 'base', $baseSlots);
            $output->writeln($message);
        }
        
        $message = $this->extensionGenerator->generateExtension($namespace, $dir . 'DependencyInjection', $themeName, $templates);
        $output->writeln($message);
    }
333437
public function initializePluginConfigDumper(InputInterface $input)
    {
        $dumper = new ConfigDumper();
        $dumper->addSection('filter', 'notPaths', $this->csvToArray($input->getOption('not-paths')));
        $dumper->addSection('filter', 'notNames', $this->csvToArray($input->getOption('not-names')));

        foreach ($this->getApplication()->all() as $command) {
            if (!$command instanceof AbstractPluginCommand) {
                continue;
            }

            $prefix   = strtoupper($command->getName());
            $envPaths = $prefix.'_IGNORE_PATHS';
            $envNames = $prefix.'_IGNORE_NAMES';

            $paths = getenv($envPaths) !== false ? getenv($envPaths) : null;
            $names = getenv($envNames) !== false ? getenv($envNames) : null;

            if (!empty($paths)) {
                $dumper->addSection('filter-'.$command->getName(), 'notPaths', $this->csvToArray($paths));
            }
            if (!empty($names)) {
                $dumper->addSection('filter-'.$command->getName(), 'notNames', $this->csvToArray($names));
            }
        }

        return $dumper;
    }
304540
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $dialog = $this->getDialogHelper();

        if ($input->isInteractive()) {
            if (!$dialog->askConfirmation($output, $dialog->getQuestion('Do you confirm generation', 'yes', '?'), true)) {
                $output->writeln('<error>Command aborted</error>');

                return 1;
            }
        }

        foreach (array('namespace', 'dir') as $option) {
            if (null === $input->getOption($option)) {
                throw new \RuntimeException(sprintf('The "%s" option must be provided.', $option));
            }
        }

        $namespace = Validators::validateBundleNamespace($input->getOption('namespace'));
        if (!$bundle = $input->getOption('bundle-name')) {
            $bundle = strtr($namespace, array('\\' => ''));
        }
        $bundle = Validators::validateBundleName($bundle);
        $dir = Validators::validateTargetDir($input->getOption('dir'), $bundle, $namespace);
        $format = Validators::validateFormat($input->getOption('format'));
        $structure = $input->getOption('structure');

        $dialog->writeSection($output, 'Bundle generation');

        if (!$this->getContainer()->get('filesystem')->isAbsolutePath($dir)) {
            $dir = getcwd().'/'.$dir;
        }

        $generatorName = $input->getOption('generator');
        $modelName = $input->getOption('model-name');

        $generator = $this->createGenerator();
        $generator->setGenerator($generatorName);
        $generator->setPrefix($input->getOption('prefix'));

        $generator->generate($namespace, $bundle, $dir, $format, $structure, $generatorName, $modelName);

        $output->writeln('Generating the bundle code: <info>OK</info>');

        $errors = array();
        $runner = $dialog->getRunner($output, $errors);

        // check that the namespace is already autoloaded
        $runner($this->checkAutoloader($output, $namespace, $bundle, $dir));

        // register the bundle in the Kernel class
        $runner($this->updateKernel($dialog, $input, $output, $this->getContainer()->get('kernel'), $namespace, $bundle));

        // routing
        $runner($this->updateRouting($dialog, $input, $output, $bundle, $format));

        $dialog->writeGeneratorSummary($output, $errors);
    }
915586
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator)
    {
        $name = $input->getArgument('name');
        $generatorClass = $input->getArgument('generator-class');

        $generatorClassNameDetails = $generator->createClassNameDetails(
            $generatorClass,
            'Generator\\'
        );

        $generator->generateClass(
            $generatorClassNameDetails->getFullName(),
            __DIR__.'/../Resources/skeleton/generator/Generator.php.tpl',
            [
                'name' => $name,
            ]
        );

        $generator->writeChanges();

        $this->writeSuccessMessage($io);
    }
1198571
private function validateInput(InputInterface $input)
    {
        if (!$input->getArgument('target')) {
            // if no target is passed, there can be no properties or methods
            foreach (['properties', 'methods', 'no-inherit'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense without a specified target');
                }
            }

            foreach (['globals', 'vars', 'constants', 'functions', 'classes', 'interfaces', 'traits'] as $option) {
                if ($input->getOption($option)) {
                    return;
                }
            }

            // default to --vars if no other options are passed
            $input->setOption('vars', true);
        } else {
            // if a target is passed, classes, functions, etc don't make sense
            foreach (['vars', 'globals', 'functions', 'classes', 'interfaces', 'traits'] as $option) {
                if ($input->getOption($option)) {
                    throw new RuntimeException('--' . $option . ' does not make sense with a specified target');
                }
            }

            foreach (['constants', 'properties', 'methods'] as $option) {
                if ($input->getOption($option)) {
                    return;
                }
            }

            // default to --constants --properties --methods if no other options are passed
            $input->setOption('constants',  true);
            $input->setOption('properties', true);
            $input->setOption('methods',    true);
        }
    }
255642
protected function mapInputToCommand($command, array $input)
    {
        $dependencies = [];

        $class = new ReflectionClass($command);

        foreach ($class->getConstructor()->getParameters() as $parameter)
        {
            $name = $parameter->getName();

            if (array_key_exists($name, $input))
            {
                $dependencies[] = $input[$name];
            }
            elseif ($parameter->isDefaultValueAvailable())
            {
                $dependencies[] = $parameter->getDefaultValue();
            }
            else
            {
                throw new InvalidArgumentException("Unable to map input to command: {$name}");
            }
        }

        return $class->newInstanceArgs($dependencies);
    }
302498
public function createModel(InputInterface $input, OutputInterface $output)
    {
        $model = $this->getApplication()->find('create:model');
        $model_arguments = array(
            'command'   => 'create:model',
            'module'    => $input->getArgument('module'),
            'table'     => $input->getArgument('table'),
            'column'    => $input->getArgument('column')
        );

        $input_model = new ArrayInput($model_arguments);
        $return_model= $model->run($input_model,$output);
        $output->writeln($return_model);
    }
411494
private function getCustomMapper(MappingInterface $mapping): ?MapperInterface
    {
        $customMapper = $mapping->getCustomMapper();

        if ($customMapper instanceof MapperAwareOperation) {
            $customMapper->setMapper($this);
        }

        return $customMapper;
    }