Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / filter / src / Plugin / DataType / FilterFormat.php
1 <?php
2
3 namespace Drupal\filter\Plugin\DataType;
4
5 use Drupal\Core\Session\AccountInterface;
6 use Drupal\Core\TypedData\OptionsProviderInterface;
7 use Drupal\Core\TypedData\Plugin\DataType\StringData;
8
9 /**
10  * The filter format data type.
11  *
12  * @DataType(
13  *   id = "filter_format",
14  *   label = @Translation("Filter format")
15  * )
16  */
17 class FilterFormat extends StringData implements OptionsProviderInterface {
18
19   /**
20    * {@inheritdoc}
21    */
22   public function getPossibleValues(AccountInterface $account = NULL) {
23     return array_keys($this->getPossibleOptions($account));
24   }
25
26   /**
27    * {@inheritdoc}
28    */
29   public function getPossibleOptions(AccountInterface $account = NULL) {
30     return array_map(function ($format) {
31       return $format->label();
32     }, filter_formats());
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function getSettableValues(AccountInterface $account = NULL) {
39     return array_keys($this->getSettableOptions($account));
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function getSettableOptions(AccountInterface $account = NULL) {
46     // @todo: Avoid calling functions but move to injected dependencies.
47     return array_map(function ($format) {
48       return $format->label();
49     }, filter_formats($account));
50   }
51
52 }