view core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithConstraints.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children
line wrap: on
line source
<?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', []);
  }

}