Commit f61ad20b authored by alexpott's avatar alexpott

Issue #2332885 by cs_shadow, Berdir, fago: Rename AllowedValuesInterface to...

Issue #2332885 by cs_shadow, Berdir, fago: Rename AllowedValuesInterface to OptionsProviderInterface.
parent fb6c562c
...@@ -263,7 +263,7 @@ public static function defaultFieldSettings(); ...@@ -263,7 +263,7 @@ public static function defaultFieldSettings();
* *
* An example of a conversion between representations might be an * An example of a conversion between representations might be an
* "allowed_values" setting that's structured by the field type as a * "allowed_values" setting that's structured by the field type as a
* \Drupal\Core\TypedData\AllowedValuesInterface::getPossibleOptions() * \Drupal\Core\TypedData\OptionsProviderInterface::getPossibleOptions()
* result (i.e., values as keys and labels as values). For such a use case, * result (i.e., values as keys and labels as values). For such a use case,
* in order to comply with the above, this method could convert that * in order to comply with the above, this method could convert that
* representation to a numerically indexed array whose values are sub-arrays * representation to a numerically indexed array whose values are sub-arrays
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\OptionsProviderInterface;
use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataDefinition;
/** /**
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* default_formatter = "boolean", * default_formatter = "boolean",
* ) * )
*/ */
class BooleanItem extends FieldItemBase implements AllowedValuesInterface { class BooleanItem extends FieldItemBase implements OptionsProviderInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/** /**
* @file * @file
* Contains \Drupal\Core\TypedData\AllowedValuesInterface. * Contains \Drupal\Core\TypedData\OptionsProviderInterface.
*/ */
namespace Drupal\Core\TypedData; namespace Drupal\Core\TypedData;
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* *
* @see \Drupal\options\Plugin\Field\FieldWidget\OptionsWidgetBase * @see \Drupal\options\Plugin\Field\FieldWidget\OptionsWidgetBase
*/ */
interface AllowedValuesInterface { interface OptionsProviderInterface {
/** /**
* Returns an array of possible values. * Returns an array of possible values.
......
...@@ -377,7 +377,7 @@ public function getDefaultConstraints(DataDefinitionInterface $definition) { ...@@ -377,7 +377,7 @@ public function getDefaultConstraints(DataDefinitionInterface $definition) {
$constraints['NotNull'] = array(); $constraints['NotNull'] = array();
} }
// Check if the class provides allowed values. // Check if the class provides allowed values.
if (is_subclass_of($definition->getClass(),'Drupal\Core\TypedData\AllowedValuesInterface')) { if (is_subclass_of($definition->getClass(),'Drupal\Core\TypedData\OptionsProviderInterface')) {
$constraints['AllowedValues'] = array(); $constraints['AllowedValues'] = array();
} }
// Add any constraints about referenced data. // Add any constraints about referenced data.
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
* label = @Translation("Allowed values", context = "Validation") * label = @Translation("Allowed values", context = "Validation")
* ) * )
* *
* @see \Drupal\Core\TypedData\AllowedValuesInterface * @see \Drupal\Core\TypedData\OptionsProviderInterface
*/ */
class AllowedValuesConstraint extends Choice { class AllowedValuesConstraint extends Choice {
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
namespace Drupal\Core\Validation\Plugin\Validation\Constraint; namespace Drupal\Core\Validation\Plugin\Validation\Constraint;
use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\OptionsProviderInterface;
use Drupal\Core\TypedData\ComplexDataInterface; use Drupal\Core\TypedData\ComplexDataInterface;
use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints\ChoiceValidator; use Symfony\Component\Validator\Constraints\ChoiceValidator;
...@@ -23,7 +23,7 @@ class AllowedValuesConstraintValidator extends ChoiceValidator { ...@@ -23,7 +23,7 @@ class AllowedValuesConstraintValidator extends ChoiceValidator {
public function validate($value, Constraint $constraint) { public function validate($value, Constraint $constraint) {
$typed_data = $this->context->getMetadata()->getTypedData(); $typed_data = $this->context->getMetadata()->getTypedData();
if ($typed_data instanceof AllowedValuesInterface) { if ($typed_data instanceof OptionsProviderInterface) {
$account = \Drupal::currentUser(); $account = \Drupal::currentUser();
$allowed_values = $typed_data->getSettableValues($account); $allowed_values = $typed_data->getSettableValues($account);
$constraint->choices = $allowed_values; $constraint->choices = $allowed_values;
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\OptGroup; use Drupal\Core\Form\OptGroup;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\OptionsProviderInterface;
use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataDefinition;
use Drupal\Core\Validation\Plugin\Validation\Constraint\AllowedValuesConstraint; use Drupal\Core\Validation\Plugin\Validation\Constraint\AllowedValuesConstraint;
use Drupal\field\FieldStorageConfigInterface; use Drupal\field\FieldStorageConfigInterface;
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* *
* @see entity_reference_field_info_alter(). * @see entity_reference_field_info_alter().
*/ */
class ConfigurableEntityReferenceItem extends EntityReferenceItem implements AllowedValuesInterface { class ConfigurableEntityReferenceItem extends EntityReferenceItem implements OptionsProviderInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace Drupal\filter\Plugin\DataType; namespace Drupal\filter\Plugin\DataType;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\OptionsProviderInterface;
use Drupal\Core\TypedData\Plugin\DataType\String; use Drupal\Core\TypedData\Plugin\DataType\String;
/** /**
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* label = @Translation("Filter format") * label = @Translation("Filter format")
* ) * )
*/ */
class FilterFormat extends String implements AllowedValuesInterface { class FilterFormat extends String implements OptionsProviderInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
namespace Drupal\filter\Tests; namespace Drupal\filter\Tests;
use Drupal\Core\Session\AnonymousUserSession; use Drupal\Core\Session\AnonymousUserSession;
use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\OptionsProviderInterface;
use Drupal\Core\TypedData\DataDefinition; use Drupal\Core\TypedData\DataDefinition;
use Drupal\filter\Plugin\DataType\FilterFormat; use Drupal\filter\Plugin\DataType\FilterFormat;
use Drupal\filter\Plugin\FilterInterface; use Drupal\filter\Plugin\FilterInterface;
...@@ -267,7 +267,7 @@ function testTypedDataAPI() { ...@@ -267,7 +267,7 @@ function testTypedDataAPI() {
$definition = DataDefinition::create('filter_format'); $definition = DataDefinition::create('filter_format');
$data = \Drupal::typedDataManager()->create($definition); $data = \Drupal::typedDataManager()->create($definition);
$this->assertTrue($data instanceof AllowedValuesInterface, 'Typed data object implements \Drupal\Core\TypedData\AllowedValuesInterface'); $this->assertTrue($data instanceof OptionsProviderInterface, 'Typed data object implements \Drupal\Core\TypedData\OptionsProviderInterface');
$filtered_html_user = $this->createUser(array('uid' => 2), array( $filtered_html_user = $this->createUser(array('uid' => 2), array(
entity_load('filter_format', 'filtered_html')->getPermissionName(), entity_load('filter_format', 'filtered_html')->getPermissionName(),
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
* *
* @param array $options * @param array $options
* The array of options for the field, as returned by * The array of options for the field, as returned by
* \Drupal\Core\TypedData\AllowedValuesInterface::getSettableOptions(). An * \Drupal\Core\TypedData\OptionsProviderInterface::getSettableOptions(). An
* empty option (_none) might have been added, depending on the field * empty option (_none) might have been added, depending on the field
* properties. * properties.
* *
......
...@@ -13,12 +13,12 @@ ...@@ -13,12 +13,12 @@
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\OptGroup; use Drupal\Core\Form\OptGroup;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\OptionsProviderInterface;
/** /**
* Plugin base class inherited by the options field types. * Plugin base class inherited by the options field types.
*/ */
abstract class ListItemBase extends FieldItemBase implements AllowedValuesInterface { abstract class ListItemBase extends FieldItemBase implements OptionsProviderInterface {
use AllowedTagsXssTrait; use AllowedTagsXssTrait;
......
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
* *
* Field types willing to enable one or several of the widgets defined in * Field types willing to enable one or several of the widgets defined in
* options.module (select, radios/checkboxes, on/off checkbox) need to * options.module (select, radios/checkboxes, on/off checkbox) need to
* implement the AllowedValuesInterface to specify the list of options to * implement the OptionsProviderInterface to specify the list of options to
* display in the widgets. * display in the widgets.
* *
* @see \Drupal\Core\TypedData\AllowedValuesInterface * @see \Drupal\Core\TypedData\OptionsProviderInterface
*/ */
abstract class OptionsWidgetBase extends WidgetBase { abstract class OptionsWidgetBase extends WidgetBase {
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Form\OptGroup; use Drupal\Core\Form\OptGroup;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\AllowedValuesInterface; use Drupal\Core\TypedData\OptionsProviderInterface;
/** /**
* Plugin implementation of the 'term_reference' field type. * Plugin implementation of the 'term_reference' field type.
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
* list_class = "\Drupal\Core\Field\EntityReferenceFieldItemList" * list_class = "\Drupal\Core\Field\EntityReferenceFieldItemList"
* ) * )
*/ */
class TaxonomyTermReferenceItem extends EntityReferenceItem implements AllowedValuesInterface { class TaxonomyTermReferenceItem extends EntityReferenceItem implements OptionsProviderInterface {
/** /**
* {@inheritdoc} * {@inheritdoc}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment