TestWithHiddenSourceField.php

Same filename in other branches
  1. 9 core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithHiddenSourceField.php
  2. 8.9.x core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithHiddenSourceField.php
  3. 10 core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithHiddenSourceField.php

Namespace

Drupal\media_test_source\Plugin\media\Source

File

core/modules/media/tests/modules/media_test_source/src/Plugin/media/Source/TestWithHiddenSourceField.php

View source
<?php

declare (strict_types=1);
namespace Drupal\media_test_source\Plugin\media\Source;

use Drupal\Core\Entity\Display\EntityFormDisplayInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\media\Attribute\MediaSource;
use Drupal\media\MediaTypeInterface;

/**
 * Provides test media source.
 */
class TestWithHiddenSourceField extends Test {
    
    /**
     * {@inheritdoc}
     */
    public function prepareViewDisplay(MediaTypeInterface $type, EntityViewDisplayInterface $display) {
        $display->removeComponent($this->getSourceFieldDefinition($type)
            ->getName());
    }
    
    /**
     * {@inheritdoc}
     */
    public function prepareFormDisplay(MediaTypeInterface $type, EntityFormDisplayInterface $display) {
        $display->removeComponent($this->getSourceFieldDefinition($type)
            ->getName());
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getSourceFieldName() {
        return 'field_media_hidden';
    }

}

Classes

Title Deprecated Summary
TestWithHiddenSourceField Provides test media source.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.