Add options to a Symfony Console input definition.

@param InputDefinition $definition
17368
public function configureInputDefinition(InputDefinition $definition)
    {
        foreach ($this->fields as $field) {
            if ($field->includeAsOption()) {
                $definition->addOption($field->getAsOption());
            }
        }
    }
1143206
private function setDefinitionProperties(Definition $definition, array $array)
    {
        if (isset($array['public'])) {
            $definition->setPublic($array['public']);
        }

        if (isset($array['abstract'])) {
            $definition->setAbstract($array['abstract']);
        }

        if (isset($array['scope'])) {
            $definition->setScope($array['scope']);
        }

        if (isset($array['file'])) {
            $definition->setFile($array['file']);
        }
    }
132764
public function createWritableDictionary(DictionaryDefinition $definition): WritableDictionaryInterface
    {
        $builder = $this->getDictionaryBuilder($definition);

        /** @var DictionaryBuilderInterface $builder */
        return $builder->buildWritable($this, $definition);
    }
365719
public function setDefinition($definition)
	{
		if ($definition instanceof InputDefinition)
		{
			$this->definition = $definition;
		}
		else
		{
			$this->definition->setDefinition($definition);
		}

		$this->applicationDefinitionMerged = false;
	}
18690
private function merge(DataValidationDefinition $definition, DataValidationDefinition $profileDefinition): void
    {
        foreach ($profileDefinition->getProperties() as $key => $constraints) {
            $parameters = [];
            $parameters[] = $key;
            $parameters = array_merge($parameters, $constraints);

            call_user_func_array([$definition, 'add'], $parameters);
        }
    }
549398
private static function create_definition_object($definition) {
        global $CFG;

        $method = $definition['method'];
        $definitionobject = new stdClass();
        foreach ($definition as $key => $value) {
            if (!is_array($value)) {
                $definitionobject->$key = $value;
            }
        }
        $text = '';
        $format = FORMAT_MOODLE;
        if (isset($definition['description'])) {
            $text = $definition['description'];
            if (isset($definition['descriptionformat'])) {
                $format = $definition['descriptionformat'];
            }
        }
        $definitionobject->description_editor = array('text' => $text, 'format' => $format);

        require_once("$CFG->libdir/filelib.php");
        require_once($CFG->dirroot.'/grade/grading/form/'.$method.'/lib.php');
        $details  = call_user_func('gradingform_'.$method.'_controller::get_external_definition_details');
        $methodarray = array();
        foreach (array_keys($details) as $definitionkey) {
            $items = array();
            $idnumber = 1;
            foreach ($definition[$method][$definitionkey] as $item) {
                $processeditem = self::set_new_ids($item, $idnumber);
                $items[$processeditem['id']] = $processeditem;
                $idnumber++;
            }
            $definitionobjectkey = substr($definitionkey, strlen($method.'_'));
            $methodarray[$definitionobjectkey] = $items;
            $definitionobject->$method = $methodarray;
        }

        return $definitionobject;
    }
1059560
public function addDefinitions(array $definitions)
    {
        $resource          = new DefinitionResource($definitions);
        $this->definitions = array_merge($resource->getDefinitions(), $this->definitions);
    }
138990
public function load(\Asgard\Entity\Definition $definition) {
		$this->entityClass = $definition->getClass();

		if(!$definition->has('order_by'))
			$definition->set('order_by', 'id DESC');

		$definition->hook('get', [$this, 'hookGet']);
		$definition->hook('getTranslations', [$this, 'hookgetTranslations']);
		$definition->hook('validation', [$this, 'hookValidation']);
	}
249752
public function bind(Definition $definition) {
        $this->arguments = [];
        $this->options = [];
        $this->definition = $definition;

        $this->parse();
    }
192646
private function getDictionaryBuilder(DictionaryDefinition $definition): DictionaryBuilderInterface
    {
        if (!$this->dictionaryBuilders->has($typeName = $definition->getType())) {
            $typeName = 'default';
        }

        return $this->dictionaryBuilders->get($typeName);
    }
37351
public function generate(InputInterface $input, ConsoleStyle $io, Generator $generator): void
    {
        $this->configure($input);

        $adminClassNameDetails = $generator->createClassNameDetails(
            $this->adminClassBasename,
            'Admin\\',
            'Admin'
        );

        $adminClassFullName = $adminClassNameDetails->getFullName();
        $this->generateAdmin($io, $generator, $adminClassNameDetails);

        $controllerClassFullName = '';
        if ($this->controllerClassBasename) {
            $controllerClassNameDetails = $generator->createClassNameDetails(
                $this->controllerClassBasename,
                'Controller\\',
                'Controller'
            );

            $this->generateController($input, $io, $generator, $controllerClassNameDetails);

            $controllerClassFullName = $controllerClassNameDetails->getFullName();
        }

        $this->generateService($input, $io, $adminClassFullName, $controllerClassFullName);
    }
754224
protected function buildInputDefinition() : InputDefinition
    {
        return new InputDefinition(
            [
                new InputOption(
                    'target',
                    't',
                    InputOption::VALUE_REQUIRED,
                    'Finds Files which have changed since the current branch parted from the target branch '
                    . 'only. The Value has to be a commit-ish.',
                    false
                ),
                new InputOption(
                    'auto-target',
                    'a',
                    InputOption::VALUE_NONE,
                    'Finds Files which have changed since the current branch parted from the parent branch '
                    . 'only. It tries to find the parent branch by automagic.'
                ),
                new InputOption(
                    'fix',
                    'f',
                    InputOption::VALUE_NONE,
                    'Runs tool to try to fix violations automagically.'
                ),
                new InputOption(
                    'process-isolation',
                    'p',
                    InputOption::VALUE_NONE,
                    'Runs all checks in separate processes. Slow but not as resource hungry.'
                ),
            ]
        );
    }
118856
protected function resolveObjectRealInterfaceExtensions(ClassAwareDefinitionInterface $definition): void
    {
        $class = $definition->getClass();

        if (class_exists($class)) {
            $refClass = new \ReflectionClass($definition->getClass());
            if ($interfaces = $refClass->getInterfaceNames()) {
                foreach ($interfaces as $interface) {
                    $bundleNamespace = ClassUtils::relatedBundleNamespace($interface);
                    if (preg_match('/(\w+)Interface?$/', $interface, $matches)) {
                        $extensionClass = ClassUtils::applyNamingConvention($bundleNamespace, 'Extension', null, $matches[1].'Extension');
                        if (class_exists($extensionClass)) {
                            if ($definition instanceof HasExtensionsInterface) {
                                $definition->addExtension($extensionClass);
                            }
                        }
                    }
                }
            }
        }
    }
553384
protected function appendFilterDefinition(NodeBuilder $filterDefinition): void
    {
        $fieldDefinition = $filterDefinition
            ->scalarNode('provider')->isRequired()->end()
            ->integerNode('results_per_page')->defaultValue(15)->end()
            ->arrayNode('sortable')
                ->prototype('scalar')->end()
            ->end()
            ->arrayNode('default_sort')
                ->prototype('scalar')->defaultValue([])->end()
            ->end()
            ->variableNode('options')
                ->defaultValue([])
                ->validate()
                    ->ifTrue(function ($value) {
                        return !\is_array($value) && null !== $value;
                    })
                    ->thenInvalid('"options" configuration must be an array or left empty')
                ->end()
            ->end()
            ->arrayNode('filters')
                ->prototype('array')
                    ->children();

        $this->appendFieldDefinition($fieldDefinition);

        $fieldDefinition->end()
                ->end()
            ->end();
    }
946792
protected function initializeEvents($eventsDefinition)
    {
        foreach ($eventsDefinition as $variableName => $eventValue) {
            $value = array();

            if (!empty($eventValue) && !\is_array($eventValue)) {
                $value = [$eventValue];
            } elseif (\is_array($eventValue)) {
                $value = $eventValue;
            }

            $this->$variableName = $value;
        }
    }
242047
public function setDefinition($definition)
    {
        if ($definition instanceof Expression) {
            $definition = (string) $definition;
        }

        $this->definition = $definition;
    }
625959
protected function getDefaultInputDefinition() {
		$definition = parent::getDefaultInputDefinition();
		$definition->addOption(new InputOption('--env', null, InputOption::VALUE_OPTIONAL, 'The environment the console should run under.'));

		return $definition;
	}