You are here

ConfigEntityRevisionsControllerBase.php in Config Entity Revisions 8.2

File

src/ConfigEntityRevisionsControllerBase.php
View source
<?php

namespace Drupal\config_entity_revisions;

use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Config\ImmutableConfig;
use Drupal\diff\DiffEntityComparison;
use Drupal\Core\Entity\EntityTypeManager;
use Drupal\Core\Session\AccountProxyInterface;
use Symfony\Component\Serializer\Serializer;
use Drupal\Core\Database\Connection;

/**
 * Controller to make library functions available to various consumers.
 */
abstract class ConfigEntityRevisionsControllerBase extends ControllerBase implements ConfigEntityRevisionsControllerInterface {

  /**
   * The renderer service.
   *
   * @var \Drupal\Core\Render\RendererInterface
   */
  protected $renderer;

  /**
   * Wrapper object for simple configuration from diff.settings.yml.
   *
   * @var \Drupal\Core\Config\ImmutableConfig
   */
  protected $config;

  /**
   * Wrapper object for simple configuration from diff.settings.yml.
   *
   * @var \Drupal\diff\DiffEntityComparison
   */
  protected $entityComparison;

  /**
   * Serialiser service.
   *
   * @var \Symfony\Component\Serializer\Serializer
   */
  protected $serialiser;

  /**
   * Container instance.
   *
   * @var \Symfony\Component\DependencyInjection\ContainerInterface
   */
  protected $container;

  /**
   * Date formatter service.
   *
   * @var \Drupal\Core\Datetime\DateFormatterInterface
   */
  protected $dateFormatter;

  /**
   * The database connection.
   *
   * @var \Drupal\Core\Database\Connection
   */
  protected $connection;

  /**
   * Constructs a ConfigEntityRevisionsController object.
   *
   * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
   *   The container interface object.
   * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
   *   The date formatter service.
   * @param \Drupal\Core\Render\RendererInterface $renderer
   *   The renderer service.
   * @param \Drupal\Core\Config\ImmutableConfig $config
   *   The configuration service.
   * @param \Drupal\diff\DiffEntityComparison $entity_comparison
   *   The diff entity comparison service.
   * @param \Drupal\Core\Entity\EntityTypeManager $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\Core\Session\AccountProxyInterface $current_user
   *   The current user.
   * @param \Symfony\Component\Serializer\Serializer $serialiser
   *   The serialiser service.
   * @param \Drupal\Core\Database\Connection $connection
   *   The database connection.
   */
  public function __construct(ContainerInterface $container, DateFormatterInterface $date_formatter, RendererInterface $renderer, ImmutableConfig $config, DiffEntityComparison $entity_comparison, EntityTypeManager $entity_type_manager, AccountProxyInterface $current_user, Serializer $serialiser, Connection $connection) {
    $this->container = $container;
    $this->dateFormatter = $date_formatter;
    $this->renderer = $renderer;
    $this->config = $this
      ->config('diff.settings');
    $this->entityComparison = $entity_comparison;
    $this->entityTypeManager = $entity_type_manager;
    $this->currentUser = $current_user;
    $this->serialiser = $serialiser;
    $this->connection = $connection;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container) {
    return new static($container, $container
      ->get('date.formatter'), $container
      ->get('renderer'), $container
      ->get('config.factory')
      ->get('diff.settings'), $container
      ->get('diff.entity_comparison'), $container
      ->get('entity_type.manager'), $container
      ->get('current_user'), $container
      ->get('serializer'), $container
      ->get('database'));
  }

}

Classes

Namesort descending Description
ConfigEntityRevisionsControllerBase Controller to make library functions available to various consumers.