summaryrefslogtreecommitdiffstats
path: root/core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithConstraints.php
blob: 98039ca2d2a2859db931239c57a8906a2b603ef6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<?php

namespace Drupal\media_test_source\Plugin\media\Source;

use Drupal\media\MediaSourceEntityConstraintsInterface;
use Drupal\media\MediaSourceFieldConstraintsInterface;

/**
 * Provides generic media type.
 *
 * @MediaSource(
 *   id = "test_constraints",
 *   label = @Translation("Test source with constraints"),
 *   description = @Translation("Test media source that provides constraints."),
 *   allowed_field_types = {"string_long"},
 * )
 */
class TestWithConstraints extends Test implements MediaSourceEntityConstraintsInterface, MediaSourceFieldConstraintsInterface {

  /**
   * {@inheritdoc}
   */
  public function getEntityConstraints() {
    return \Drupal::state()->get('media_source_test_entity_constraints', []);
  }

  /**
   * {@inheritdoc}
   */
  public function getSourceFieldConstraints() {
    return \Drupal::state()->get('media_source_test_field_constraints', []);
  }

}