You are here

final class Update200 in Lightning Media 8.3

Same name and namespace in other branches
  1. 8.4 src/Update/Update200.php \Drupal\lightning_media\Update\Update200
  2. 8.2 src/Update/Update200.php \Drupal\lightning_media\Update\Update200

Contains optional updates targeting Lightning Media 2.0.0.

Plugin annotation

@Update("2.0.0");

Hierarchy

Expanded class hierarchy of Update200

File

src/Update/Update200.php, line 16

Namespace

Drupal\lightning_media\Update
View source
final class Update200 implements ContainerInjectionInterface {
  use StringTranslationTrait;

  /**
   * The config factory service.
   *
   * @var \Drupal\Core\Config\ConfigFactoryInterface
   */
  protected $configFactory;

  /**
   * Update200 constructor.
   *
   * @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
   *   The config factory service.
   * @param \Drupal\Core\StringTranslation\TranslationInterface $translation
   *   (optional) The string translation service.
   */
  public function __construct(ConfigFactoryInterface $config_factory, TranslationInterface $translation = NULL) {
    $this->configFactory = $config_factory;
    if ($translation) {
      $this
        ->setStringTranslation($translation);
    }
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container
      ->get('config.factory'), $container
      ->get('string_translation'));
  }

  /**
   * Renames the Media overview page's Source filter.
   *
   * @update
   *
   * @ask Do you want to rename the "Media Type" filter label on the Media
   * overview page to "Type"? This will also change the filter's URL identifier
   * to 'type' and will make the label and URL identifier consistent with new
   * installs of Lightning.
   */
  public function renameMediaOverviewTypeFilter() {
    $view = $this->configFactory
      ->getEditable('views.view.media');
    if ($view
      ->isNew()) {
      return;
    }
    $property = 'display.default.display_options.filters.bundle';
    $filter = $view
      ->get($property);
    if ($filter) {
      $filter['expose']['label'] = 'Type';
      $filter['expose']['identifier'] = 'type';
      $view
        ->set($property, $filter)
        ->save();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.
Update200::$configFactory protected property The config factory service.
Update200::create public static function Instantiates a new instance of this class. Overrides ContainerInjectionInterface::create
Update200::renameMediaOverviewTypeFilter public function Renames the Media overview page's Source filter.
Update200::__construct public function Update200 constructor.