Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / media / tests / modules / media_test_source / src / Plugin / media / Source / TestWithHiddenSourceField.php
1 <?php
2
3 namespace Drupal\media_test_source\Plugin\media\Source;
4
5 use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
6 use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
7 use Drupal\media\MediaTypeInterface;
8
9 /**
10  * Provides test media source.
11  *
12  * @MediaSource(
13  *   id = "test_hidden_source_field",
14  *   label = @Translation("Test source with hidden source field"),
15  *   description = @Translation("Test media source with hidden source field."),
16  *   allowed_field_types = {"string"},
17  * )
18  */
19 class TestWithHiddenSourceField extends Test {
20
21   /**
22    * {@inheritdoc}
23    */
24   public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
25     $display->removeComponent($this->getSourceFieldDefinition($type)->getName());
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function prepareFormDisplay(MediaTypeInterface $type, EntityFormDisplayInterface $display) {
32     $display->removeComponent($this->getSourceFieldDefinition($type)->getName());
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   protected function getSourceFieldName() {
39     return 'field_media_hidden';
40   }
41
42 }