Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

implemented resolver like in https://github.com/symfony/symfony/issue… #33867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
implemented resolver like in https://github.com/symfony/symfony/issue…
  • Loading branch information
boscho87 committed Oct 5, 2019
commit f9bec06101b7f0dfd70a96cd215da942e643796c
94 changes: 94 additions & 0 deletions 94 src/Symfony/Component/OptionsResolver/OptionConfigurator.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php


namespace Symfony\Component\OptionsResolver;

/**
* Class OptionConfigurator
* @author Simon D. Mueller <simon.d.mueller@gmail.com>
*/
final class OptionConfigurator
{

/**
* @var string
*/
private $name;
/**
* @var OptionsResolver
*/
private $resolver;

/**
* OptionConfigurator constructor.
* @param string $name
* @param OptionsResolver $resolver
*/
public function __construct(string $name, OptionsResolver $resolver)
{
$this->name = $name;
$this->resolver = $resolver;
$this->resolver->setDefined($name);
}

/**
* @param $value
* @return OptionConfigurator
*/
public function default($value): self
{
$this->resolver->setDefault($this->name, $value);

return $this;
}

/**
* @return OptionConfigurator
*/
public function required(): self
{
$this->resolver->setRequired($this->name);
return $this;
}

/**
* @param $message
* @return OptionConfigurator
*/
public function deprecated($message): self
{
$this->resolver->setDeprecated($this->name, $message);
return $this;
}

/**
* @param $type
* @return OptionConfigurator
*/
public function allowedTypes($type): self
{
$this->resolver->setAllowedTypes($this->name, $type);
return $this;
}

/**
* @param $values
* @return OptionConfigurator
*/
public function allowedValues($values): self
{
$this->resolver->setAllowedValues($this->name, $values);
return $this;
}

/**
* @param callable $normalizer
* @return OptionConfigurator
*/
public function normalize(callable $normalizer): self
{
$this->resolver->setNormalizer($this->name, $normalizer);
return $this;
}

}
9 changes: 9 additions & 0 deletions 9 src/Symfony/Component/OptionsResolver/OptionsResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,15 @@ class OptionsResolver implements Options
'double' => 'float',
];

/**
* @param string $optionName
* @return OptionConfigurator
*/
public function define(string $optionName): OptionConfigurator
{
return new OptionConfigurator($optionName, $this);
}

/**
* Sets the default value of a given option.
*
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.