login consent app sql
This commit is contained in:
207
vendor/symfony/form/Console/Descriptor/Descriptor.php
vendored
Normal file
207
vendor/symfony/form/Console/Descriptor/Descriptor.php
vendored
Normal file
@ -0,0 +1,207 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Form\Console\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Descriptor\DescriptorInterface;
|
||||
use Symfony\Component\Console\Input\ArrayInput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\OutputStyle;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Form\ResolvedFormTypeInterface;
|
||||
use Symfony\Component\Form\Util\OptionsResolverWrapper;
|
||||
use Symfony\Component\OptionsResolver\Debug\OptionsResolverIntrospector;
|
||||
use Symfony\Component\OptionsResolver\Exception\NoConfigurationException;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
abstract class Descriptor implements DescriptorInterface
|
||||
{
|
||||
/** @var OutputStyle */
|
||||
protected $output;
|
||||
protected $type;
|
||||
protected $ownOptions = [];
|
||||
protected $overriddenOptions = [];
|
||||
protected $parentOptions = [];
|
||||
protected $extensionOptions = [];
|
||||
protected $requiredOptions = [];
|
||||
protected $parents = [];
|
||||
protected $extensions = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function describe(OutputInterface $output, $object, array $options = [])
|
||||
{
|
||||
$this->output = $output instanceof OutputStyle ? $output : new SymfonyStyle(new ArrayInput([]), $output);
|
||||
|
||||
switch (true) {
|
||||
case null === $object:
|
||||
$this->describeDefaults($options);
|
||||
break;
|
||||
case $object instanceof ResolvedFormTypeInterface:
|
||||
$this->describeResolvedFormType($object, $options);
|
||||
break;
|
||||
case $object instanceof OptionsResolver:
|
||||
$this->describeOption($object, $options);
|
||||
break;
|
||||
default:
|
||||
throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object)));
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected function describeDefaults(array $options);
|
||||
|
||||
abstract protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = []);
|
||||
|
||||
abstract protected function describeOption(OptionsResolver $optionsResolver, array $options);
|
||||
|
||||
protected function collectOptions(ResolvedFormTypeInterface $type)
|
||||
{
|
||||
$this->parents = [];
|
||||
$this->extensions = [];
|
||||
|
||||
if (null !== $type->getParent()) {
|
||||
$optionsResolver = clone $this->getParentOptionsResolver($type->getParent());
|
||||
} else {
|
||||
$optionsResolver = new OptionsResolver();
|
||||
}
|
||||
|
||||
$type->getInnerType()->configureOptions($ownOptionsResolver = new OptionsResolverWrapper());
|
||||
$this->ownOptions = array_diff($ownOptionsResolver->getDefinedOptions(), $optionsResolver->getDefinedOptions());
|
||||
$overriddenOptions = array_intersect(array_merge($ownOptionsResolver->getDefinedOptions(), $ownOptionsResolver->getUndefinedOptions()), $optionsResolver->getDefinedOptions());
|
||||
|
||||
$this->parentOptions = [];
|
||||
foreach ($this->parents as $class => $parentOptions) {
|
||||
$this->overriddenOptions[$class] = array_intersect($overriddenOptions, $parentOptions);
|
||||
$this->parentOptions[$class] = array_diff($parentOptions, $overriddenOptions);
|
||||
}
|
||||
|
||||
$type->getInnerType()->configureOptions($optionsResolver);
|
||||
$this->collectTypeExtensionsOptions($type, $optionsResolver);
|
||||
$this->extensionOptions = [];
|
||||
foreach ($this->extensions as $class => $extensionOptions) {
|
||||
$this->overriddenOptions[$class] = array_intersect($overriddenOptions, $extensionOptions);
|
||||
$this->extensionOptions[$class] = array_diff($extensionOptions, $overriddenOptions);
|
||||
}
|
||||
|
||||
$this->overriddenOptions = array_filter($this->overriddenOptions);
|
||||
$this->parentOptions = array_filter($this->parentOptions);
|
||||
$this->extensionOptions = array_filter($this->extensionOptions);
|
||||
$this->requiredOptions = $optionsResolver->getRequiredOptions();
|
||||
|
||||
$this->parents = array_keys($this->parents);
|
||||
$this->extensions = array_keys($this->extensions);
|
||||
}
|
||||
|
||||
protected function getOptionDefinition(OptionsResolver $optionsResolver, string $option)
|
||||
{
|
||||
$definition = [];
|
||||
|
||||
if ($info = $optionsResolver->getInfo($option)) {
|
||||
$definition = [
|
||||
'info' => $info,
|
||||
];
|
||||
}
|
||||
|
||||
$definition += [
|
||||
'required' => $optionsResolver->isRequired($option),
|
||||
'deprecated' => $optionsResolver->isDeprecated($option),
|
||||
];
|
||||
|
||||
$introspector = new OptionsResolverIntrospector($optionsResolver);
|
||||
|
||||
$map = [
|
||||
'default' => 'getDefault',
|
||||
'lazy' => 'getLazyClosures',
|
||||
'allowedTypes' => 'getAllowedTypes',
|
||||
'allowedValues' => 'getAllowedValues',
|
||||
'normalizers' => 'getNormalizers',
|
||||
'deprecation' => 'getDeprecation',
|
||||
];
|
||||
|
||||
foreach ($map as $key => $method) {
|
||||
try {
|
||||
$definition[$key] = $introspector->{$method}($option);
|
||||
} catch (NoConfigurationException $e) {
|
||||
// noop
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($definition['deprecation']) && isset($definition['deprecation']['message']) && \is_string($definition['deprecation']['message'])) {
|
||||
$definition['deprecationMessage'] = strtr($definition['deprecation']['message'], ['%name%' => $option]);
|
||||
$definition['deprecationPackage'] = $definition['deprecation']['package'];
|
||||
$definition['deprecationVersion'] = $definition['deprecation']['version'];
|
||||
}
|
||||
|
||||
return $definition;
|
||||
}
|
||||
|
||||
protected function filterOptionsByDeprecated(ResolvedFormTypeInterface $type)
|
||||
{
|
||||
$deprecatedOptions = [];
|
||||
$resolver = $type->getOptionsResolver();
|
||||
foreach ($resolver->getDefinedOptions() as $option) {
|
||||
if ($resolver->isDeprecated($option)) {
|
||||
$deprecatedOptions[] = $option;
|
||||
}
|
||||
}
|
||||
|
||||
$filterByDeprecated = function (array $options) use ($deprecatedOptions) {
|
||||
foreach ($options as $class => $opts) {
|
||||
if ($deprecated = array_intersect($deprecatedOptions, $opts)) {
|
||||
$options[$class] = $deprecated;
|
||||
} else {
|
||||
unset($options[$class]);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
};
|
||||
|
||||
$this->ownOptions = array_intersect($deprecatedOptions, $this->ownOptions);
|
||||
$this->overriddenOptions = $filterByDeprecated($this->overriddenOptions);
|
||||
$this->parentOptions = $filterByDeprecated($this->parentOptions);
|
||||
$this->extensionOptions = $filterByDeprecated($this->extensionOptions);
|
||||
}
|
||||
|
||||
private function getParentOptionsResolver(ResolvedFormTypeInterface $type): OptionsResolver
|
||||
{
|
||||
$this->parents[$class = \get_class($type->getInnerType())] = [];
|
||||
|
||||
if (null !== $type->getParent()) {
|
||||
$optionsResolver = clone $this->getParentOptionsResolver($type->getParent());
|
||||
} else {
|
||||
$optionsResolver = new OptionsResolver();
|
||||
}
|
||||
|
||||
$inheritedOptions = $optionsResolver->getDefinedOptions();
|
||||
$type->getInnerType()->configureOptions($optionsResolver);
|
||||
$this->parents[$class] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions);
|
||||
|
||||
$this->collectTypeExtensionsOptions($type, $optionsResolver);
|
||||
|
||||
return $optionsResolver;
|
||||
}
|
||||
|
||||
private function collectTypeExtensionsOptions(ResolvedFormTypeInterface $type, OptionsResolver $optionsResolver)
|
||||
{
|
||||
foreach ($type->getTypeExtensions() as $extension) {
|
||||
$inheritedOptions = $optionsResolver->getDefinedOptions();
|
||||
$extension->configureOptions($optionsResolver);
|
||||
$this->extensions[\get_class($extension)] = array_diff($optionsResolver->getDefinedOptions(), $inheritedOptions);
|
||||
}
|
||||
}
|
||||
}
|
118
vendor/symfony/form/Console/Descriptor/JsonDescriptor.php
vendored
Normal file
118
vendor/symfony/form/Console/Descriptor/JsonDescriptor.php
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Form\Console\Descriptor;
|
||||
|
||||
use Symfony\Component\Form\ResolvedFormTypeInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class JsonDescriptor extends Descriptor
|
||||
{
|
||||
protected function describeDefaults(array $options)
|
||||
{
|
||||
$data['builtin_form_types'] = $options['core_types'];
|
||||
$data['service_form_types'] = $options['service_types'];
|
||||
if (!$options['show_deprecated']) {
|
||||
$data['type_extensions'] = $options['extensions'];
|
||||
$data['type_guessers'] = $options['guessers'];
|
||||
}
|
||||
|
||||
$this->writeData($data, $options);
|
||||
}
|
||||
|
||||
protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = [])
|
||||
{
|
||||
$this->collectOptions($resolvedFormType);
|
||||
|
||||
if ($options['show_deprecated']) {
|
||||
$this->filterOptionsByDeprecated($resolvedFormType);
|
||||
}
|
||||
|
||||
$formOptions = [
|
||||
'own' => $this->ownOptions,
|
||||
'overridden' => $this->overriddenOptions,
|
||||
'parent' => $this->parentOptions,
|
||||
'extension' => $this->extensionOptions,
|
||||
'required' => $this->requiredOptions,
|
||||
];
|
||||
$this->sortOptions($formOptions);
|
||||
|
||||
$data = [
|
||||
'class' => \get_class($resolvedFormType->getInnerType()),
|
||||
'block_prefix' => $resolvedFormType->getInnerType()->getBlockPrefix(),
|
||||
'options' => $formOptions,
|
||||
'parent_types' => $this->parents,
|
||||
'type_extensions' => $this->extensions,
|
||||
];
|
||||
|
||||
$this->writeData($data, $options);
|
||||
}
|
||||
|
||||
protected function describeOption(OptionsResolver $optionsResolver, array $options)
|
||||
{
|
||||
$definition = $this->getOptionDefinition($optionsResolver, $options['option']);
|
||||
|
||||
$map = [];
|
||||
if ($definition['deprecated']) {
|
||||
$map['deprecated'] = 'deprecated';
|
||||
if (\is_string($definition['deprecationMessage'])) {
|
||||
$map['deprecation_message'] = 'deprecationMessage';
|
||||
}
|
||||
}
|
||||
$map += [
|
||||
'info' => 'info',
|
||||
'required' => 'required',
|
||||
'default' => 'default',
|
||||
'allowed_types' => 'allowedTypes',
|
||||
'allowed_values' => 'allowedValues',
|
||||
];
|
||||
foreach ($map as $label => $name) {
|
||||
if (\array_key_exists($name, $definition)) {
|
||||
$data[$label] = $definition[$name];
|
||||
|
||||
if ('default' === $name) {
|
||||
$data['is_lazy'] = isset($definition['lazy']);
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['has_normalizer'] = isset($definition['normalizers']);
|
||||
|
||||
$this->writeData($data, $options);
|
||||
}
|
||||
|
||||
private function writeData(array $data, array $options)
|
||||
{
|
||||
$flags = $options['json_encoding'] ?? 0;
|
||||
|
||||
$this->output->write(json_encode($data, $flags | \JSON_PRETTY_PRINT)."\n");
|
||||
}
|
||||
|
||||
private function sortOptions(array &$options)
|
||||
{
|
||||
foreach ($options as &$opts) {
|
||||
$sorted = false;
|
||||
foreach ($opts as &$opt) {
|
||||
if (\is_array($opt)) {
|
||||
sort($opt);
|
||||
$sorted = true;
|
||||
}
|
||||
}
|
||||
if (!$sorted) {
|
||||
sort($opts);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
222
vendor/symfony/form/Console/Descriptor/TextDescriptor.php
vendored
Normal file
222
vendor/symfony/form/Console/Descriptor/TextDescriptor.php
vendored
Normal file
@ -0,0 +1,222 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Component\Form\Console\Descriptor;
|
||||
|
||||
use Symfony\Component\Console\Helper\Dumper;
|
||||
use Symfony\Component\Console\Helper\TableSeparator;
|
||||
use Symfony\Component\Form\ResolvedFormTypeInterface;
|
||||
use Symfony\Component\HttpKernel\Debug\FileLinkFormatter;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @author Yonel Ceruto <yonelceruto@gmail.com>
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class TextDescriptor extends Descriptor
|
||||
{
|
||||
private $fileLinkFormatter;
|
||||
|
||||
public function __construct(FileLinkFormatter $fileLinkFormatter = null)
|
||||
{
|
||||
$this->fileLinkFormatter = $fileLinkFormatter;
|
||||
}
|
||||
|
||||
protected function describeDefaults(array $options)
|
||||
{
|
||||
if ($options['core_types']) {
|
||||
$this->output->section('Built-in form types (Symfony\Component\Form\Extension\Core\Type)');
|
||||
$shortClassNames = array_map(function ($fqcn) {
|
||||
return $this->formatClassLink($fqcn, \array_slice(explode('\\', $fqcn), -1)[0]);
|
||||
}, $options['core_types']);
|
||||
for ($i = 0, $loopsMax = \count($shortClassNames); $i * 5 < $loopsMax; ++$i) {
|
||||
$this->output->writeln(' '.implode(', ', \array_slice($shortClassNames, $i * 5, 5)));
|
||||
}
|
||||
}
|
||||
|
||||
if ($options['service_types']) {
|
||||
$this->output->section('Service form types');
|
||||
$this->output->listing(array_map([$this, 'formatClassLink'], $options['service_types']));
|
||||
}
|
||||
|
||||
if (!$options['show_deprecated']) {
|
||||
if ($options['extensions']) {
|
||||
$this->output->section('Type extensions');
|
||||
$this->output->listing(array_map([$this, 'formatClassLink'], $options['extensions']));
|
||||
}
|
||||
|
||||
if ($options['guessers']) {
|
||||
$this->output->section('Type guessers');
|
||||
$this->output->listing(array_map([$this, 'formatClassLink'], $options['guessers']));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected function describeResolvedFormType(ResolvedFormTypeInterface $resolvedFormType, array $options = [])
|
||||
{
|
||||
$this->collectOptions($resolvedFormType);
|
||||
|
||||
if ($options['show_deprecated']) {
|
||||
$this->filterOptionsByDeprecated($resolvedFormType);
|
||||
}
|
||||
|
||||
$formOptions = $this->normalizeAndSortOptionsColumns(array_filter([
|
||||
'own' => $this->ownOptions,
|
||||
'overridden' => $this->overriddenOptions,
|
||||
'parent' => $this->parentOptions,
|
||||
'extension' => $this->extensionOptions,
|
||||
]));
|
||||
|
||||
// setting headers and column order
|
||||
$tableHeaders = array_intersect_key([
|
||||
'own' => 'Options',
|
||||
'overridden' => 'Overridden options',
|
||||
'parent' => 'Parent options',
|
||||
'extension' => 'Extension options',
|
||||
], $formOptions);
|
||||
|
||||
$this->output->title(sprintf('%s (Block prefix: "%s")', \get_class($resolvedFormType->getInnerType()), $resolvedFormType->getInnerType()->getBlockPrefix()));
|
||||
|
||||
if ($formOptions) {
|
||||
$this->output->table($tableHeaders, $this->buildTableRows($tableHeaders, $formOptions));
|
||||
}
|
||||
|
||||
if ($this->parents) {
|
||||
$this->output->section('Parent types');
|
||||
$this->output->listing(array_map([$this, 'formatClassLink'], $this->parents));
|
||||
}
|
||||
|
||||
if ($this->extensions) {
|
||||
$this->output->section('Type extensions');
|
||||
$this->output->listing(array_map([$this, 'formatClassLink'], $this->extensions));
|
||||
}
|
||||
}
|
||||
|
||||
protected function describeOption(OptionsResolver $optionsResolver, array $options)
|
||||
{
|
||||
$definition = $this->getOptionDefinition($optionsResolver, $options['option']);
|
||||
|
||||
$dump = new Dumper($this->output);
|
||||
$map = [];
|
||||
if ($definition['deprecated']) {
|
||||
$map = [
|
||||
'Deprecated' => 'deprecated',
|
||||
'Deprecation package' => 'deprecationPackage',
|
||||
'Deprecation version' => 'deprecationVersion',
|
||||
'Deprecation message' => 'deprecationMessage',
|
||||
];
|
||||
}
|
||||
$map += [
|
||||
'Info' => 'info',
|
||||
'Required' => 'required',
|
||||
'Default' => 'default',
|
||||
'Allowed types' => 'allowedTypes',
|
||||
'Allowed values' => 'allowedValues',
|
||||
'Normalizers' => 'normalizers',
|
||||
];
|
||||
$rows = [];
|
||||
foreach ($map as $label => $name) {
|
||||
$value = \array_key_exists($name, $definition) ? $dump($definition[$name]) : '-';
|
||||
if ('default' === $name && isset($definition['lazy'])) {
|
||||
$value = "Value: $value\n\nClosure(s): ".$dump($definition['lazy']);
|
||||
}
|
||||
|
||||
$rows[] = ["<info>$label</info>", $value];
|
||||
$rows[] = new TableSeparator();
|
||||
}
|
||||
array_pop($rows);
|
||||
|
||||
$this->output->title(sprintf('%s (%s)', \get_class($options['type']), $options['option']));
|
||||
$this->output->table([], $rows);
|
||||
}
|
||||
|
||||
private function buildTableRows(array $headers, array $options): array
|
||||
{
|
||||
$tableRows = [];
|
||||
$count = \count(max($options));
|
||||
for ($i = 0; $i < $count; ++$i) {
|
||||
$cells = [];
|
||||
foreach (array_keys($headers) as $group) {
|
||||
$option = $options[$group][$i] ?? null;
|
||||
if (\is_string($option) && \in_array($option, $this->requiredOptions, true)) {
|
||||
$option .= ' <info>(required)</info>';
|
||||
}
|
||||
$cells[] = $option;
|
||||
}
|
||||
$tableRows[] = $cells;
|
||||
}
|
||||
|
||||
return $tableRows;
|
||||
}
|
||||
|
||||
private function normalizeAndSortOptionsColumns(array $options): array
|
||||
{
|
||||
foreach ($options as $group => $opts) {
|
||||
$sorted = false;
|
||||
foreach ($opts as $class => $opt) {
|
||||
if (\is_string($class)) {
|
||||
unset($options[$group][$class]);
|
||||
}
|
||||
|
||||
if (!\is_array($opt) || 0 === \count($opt)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$sorted) {
|
||||
$options[$group] = [];
|
||||
} else {
|
||||
$options[$group][] = null;
|
||||
}
|
||||
$options[$group][] = sprintf('<info>%s</info>', (new \ReflectionClass($class))->getShortName());
|
||||
$options[$group][] = new TableSeparator();
|
||||
|
||||
sort($opt);
|
||||
$sorted = true;
|
||||
$options[$group] = array_merge($options[$group], $opt);
|
||||
}
|
||||
|
||||
if (!$sorted) {
|
||||
sort($options[$group]);
|
||||
}
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
private function formatClassLink(string $class, string $text = null): string
|
||||
{
|
||||
if (null === $text) {
|
||||
$text = $class;
|
||||
}
|
||||
|
||||
if ('' === $fileLink = $this->getFileLink($class)) {
|
||||
return $text;
|
||||
}
|
||||
|
||||
return sprintf('<href=%s>%s</>', $fileLink, $text);
|
||||
}
|
||||
|
||||
private function getFileLink(string $class): string
|
||||
{
|
||||
if (null === $this->fileLinkFormatter) {
|
||||
return '';
|
||||
}
|
||||
|
||||
try {
|
||||
$r = new \ReflectionClass($class);
|
||||
} catch (\ReflectionException $e) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return (string) $this->fileLinkFormatter->format($r->getFileName(), $r->getStartLine());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user