You are here

MediaSettingsOverride.php in Media Download 1.0.x

File

src/MediaSettingsOverride.php
View source
<?php

namespace Drupal\media_download;

use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Config\ConfigFactoryOverrideInterface;
use Drupal\Core\Config\StorageInterface;

/**
 * Overrides the Media module's settings to forcibly enable standalone URL.
 *
 * Copyright (C) 2021  Library Solutions, LLC (et al.).
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 */
class MediaSettingsOverride implements ConfigFactoryOverrideInterface {

  /**
   * {@inheritdoc}
   */
  public function createConfigObject($name, $collection = StorageInterface::DEFAULT_COLLECTION) {
    return NULL;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheSuffix() {
    return self::CLASS;
  }

  /**
   * {@inheritdoc}
   */
  public function getCacheableMetadata($name) {
    return new CacheableMetadata();
  }

  /**
   * {@inheritdoc}
   */
  public function loadOverrides($names) {
    $overrides = [];
    if (in_array('media.settings', $names)) {
      $overrides['media.settings']['standalone_url'] = TRUE;
    }
    return $overrides;
  }

}

Classes

Namesort descending Description
MediaSettingsOverride Overrides the Media module's settings to forcibly enable standalone URL.