Unverified Commit 74862b6d authored by Stefan Auditor's avatar Stefan Auditor Committed by Stefan Auditor
Browse files

Issue #3282696 by sanduhrs: Port of l10n_community: Add controller stubs

parent 591654d4
Loading
Loading
Loading
Loading
+109 −2
Original line number Diff line number Diff line
@@ -6,17 +6,124 @@ l10n_community.welcome_page:
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityWelcomePageController::build'
  requirements:
    _permission: 'access localization community'
l10n_community.explore_languages:
l10n_community.language.explore:
  path: '/translate/languages'
  defaults:
    _title: 'Explore languages'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityExploreLanguagesController::build'
  requirements:
    _permission: 'access localization community'
l10n_community.explore_projects:
l10n_community.project.explore:
  path: '/translate/projects'
  defaults:
    _title: 'Explore projects'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityExploreProjectsController::build'
  requirements:
    _permission: 'access localization community'

l10n_community.language.translate:
  path: '/translate/languages/{language}'
  defaults:
    _title: 'Translate'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityLanguagesController::overview'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      language:
        type: language
l10n_community.language.translate.translate:
  path: '/translate/languages/{language}/translate'
  defaults:
    _title: 'Translate'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityLanguagesController::translate'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      language:
        type: language
l10n_community.language.translate.import:
  path: '/translate/languages/{language}/import'
  defaults:
    _title: 'Import'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityLanguagesController::import'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      language:
        type: language
l10n_community.language.translate.export:
  path: '/translate/languages/{language}/export'
  defaults:
    _title: 'Export'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityLanguagesController::export'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      language:
        type: language

l10n_community.project.overview:
  path: '/translate/projects/{project}'
  defaults:
    _title: 'Overview'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityProjectsController::overview'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      project:
        type: l10n_server_project
l10n_community.project.export:
  path: '/translate/projects/{project}/export'
  defaults:
    _title: 'Overview'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityProjectsController::export'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      project:
        type: l10n_server_project
l10n_community.project.releases:
  path: '/translate/projects/{project}/releases'
  defaults:
    _title: 'Overview'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityProjectsController::releases'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      project:
        type: l10n_server_project
l10n_community.project.releases.release:
  path: '/translate/projects/{project}/releases/{release}'
  defaults:
    _title: 'Overview'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityProjectsController::release'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      project:
        type: l10n_server_project
      release:
        type: l10n_server_release
l10n_community.language.translate.reset:
  path: '/translate/languages/{language}/translate/reset/{project}/{release}'
  defaults:
    _title: 'Export'
    _controller: '\Drupal\l10n_community\Controller\L10nCommunityLanguagesController::reset'
  requirements:
    _permission: 'access localization community'
  options:
    parameters:
      language:
        type: language
      project:
        type: l10n_server_project
      release:
        type: l10n_server_release
+22 −4
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Drupal\l10n_community\Controller;

use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Connection;
use Drupal\Core\Url;
@@ -143,15 +144,32 @@ class L10nCommunityExploreLanguagesController extends ControllerBase {
    }

    $header = [
      ['data' => t('Language'), 'class' => ['rowhead'], 'field' => 'language'],
      ['data' => t('Overall progress'), 'field' => 'progress'],
      ['data' => t('Contributors'), 'field' => 'contributors'],
      [
        'data' => t('Language'),
        'class' => ['rowhead'],
        'field' => 'language',
      ],
      [
        'data' => t('Overall progress'),
        'field' => 'progress',
      ],
      [
        'data' => t('Contributors'),
        'field' => 'contributors',
      ],
    ];
    $build['content'] = [
      '#type' => 'table',
      '#header' => $header,
      '#rows' => $table_rows,
      '#attributes' => ['class' => ['l10n-community-overview l10n-community-highlighted']],
      '#attributes' => [
        'class' => [
          'l10n-community-overview l10n-community-highlighted',
        ],
      ],
      '#cache' => [
        'max-age' => Cache::PERMANENT,
      ],
    ];
    return $build;
  }
+4 −0
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\l10n_community\Controller;

use Drupal\Core\Cache\Cache;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Database\Connection;
use Drupal\Core\Url;
@@ -245,6 +246,9 @@ class L10nCommunityExploreProjectsController extends ControllerBase {
          'l10n-community-overview',
        ],
      ],
      '#cache' => [
        'max-age' => Cache::PERMANENT,
      ],
    ];

    return $build;
+106 −0
Original line number Diff line number Diff line
<?php
declare(strict_types=1);

namespace Drupal\l10n_community\Controller;

use Drupal\Core\Config\ConfigManagerInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Language\Language;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Returns responses for Localization community UI routes.
 */
class L10NCommunityLanguagesController extends ControllerBase {

  /**
   * The config manager.
   *
   * @var \Drupal\Core\Config\ConfigManagerInterface
   */
  protected ConfigManagerInterface $configManager;

  /**
   * The controller constructor.
   *
   * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager
   *   The config manager.
   */
  public function __construct(
      ConfigManagerInterface $config_manager
  ) {
    $this->configManager = $config_manager;
  }

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

  /**
   * Builds the response.
   *
   * @param \Drupal\Core\Language\Language $language
   *
   * @return array
   */
  public function overview(Language $language): array {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $language->getId(),
    ];
    return $build;
  }

  /**
   * Builds the response.
   *
   * @param \Drupal\Core\Language\Language $language
   *
   * @return array
   */
  public function translate(Language $language): array {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $language->getId(),
    ];
    return $build;
  }

  /**
   * Builds the response.
   *
   * @param \Drupal\Core\Language\Language $language
   *
   * @return array
   */
  public function import(Language $language): array {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $language->getId(),
    ];
    return $build;
  }

  /**
   * Builds the response.
   *
   * @param \Drupal\Core\Language\Language $language
   *
   * @return array
   */
  public function export(Language $language): array {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $language->getId(),
    ];
    return $build;
  }

}
+126 −0
Original line number Diff line number Diff line
<?php
declare(strict_types=1);

namespace Drupal\l10n_community\Controller;

use Drupal\Core\Config\ConfigManagerInterface;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Language\Language;
use Drupal\l10n_server\Entity\L10nServerProjectInterface;
use Drupal\l10n_server\Entity\L10nServerReleaseInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Returns responses for Localization community UI routes.
 */
class L10NCommunityProjectsController extends ControllerBase {

  /**
   * The config manager.
   *
   * @var \Drupal\Core\Config\ConfigManagerInterface
   */
  protected ConfigManagerInterface $configManager;

  /**
   * The controller constructor.
   *
   * @param \Drupal\Core\Config\ConfigManagerInterface $config_manager
   *   The config manager.
   */
  public function __construct(
      ConfigManagerInterface $config_manager
  ) {
    $this->configManager = $config_manager;
  }

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

  /**
   * Builds the response.
   *
   * @param \Drupal\l10n_server\Entity\L10nServerProjectInterface $project
   *
   * @return array
   */
  public function overview(L10nServerProjectInterface $project) {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $project->label(),
    ];
    return $build;
  }

  /**
   * Builds the response.
   *
   * @param \Drupal\l10n_server\Entity\L10nServerProjectInterface $project
   *
   * @return array
   */
  public function export(L10nServerProjectInterface $project) {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $project->label(),
    ];
    return $build;
  }

  /**
   * Builds the response.
   *
   * @param \Drupal\l10n_server\Entity\L10nServerProjectInterface $project
   *
   * @return array
   */
  public function releases(L10nServerProjectInterface $project) {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $project->label(),
    ];
    return $build;
  }

  /**
   * Builds the response.
   *
   * @param \Drupal\l10n_server\Entity\L10nServerProjectInterface $project
   * @param \Drupal\l10n_server\Entity\L10nServerReleaseInterface $release
   *
   * @return array
   */
  public function release(L10nServerProjectInterface $project, L10nServerReleaseInterface $release) {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $project->label() . '::' . $release->label(),
    ];
    return $build;
  }

  /**
   * Builds the response.
   *
   * @param \Drupal\Core\Language\Language $language
   * @param \Drupal\l10n_server\Entity\L10nServerProjectInterface $project
   * @param \Drupal\l10n_server\Entity\L10nServerReleaseInterface $release
   *
   * @return array
   */
  public function reset(Language $language, L10nServerProjectInterface $project, L10nServerReleaseInterface $release) {
    $build['content'] = [
      '#type' => 'item',
      '#markup' => __METHOD__ . '::' . $project->label() . '::' . $release->label() . '::' . $language->getId(),
    ];
    return $build;
  }

}
Loading