Verified Commit cc89478f authored by Dave Long's avatar Dave Long
Browse files

refactor: #3575585 Convert remaining themes to OOP

By: nicxvan
By: smustgrave
By: longwave
parent f33a27a3
Loading
Loading
Loading
Loading
Loading
+48 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\test_base_theme\Hook;

use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\ViewExecutable;
use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for test_base_theme.
 */
class TestBaseThemeHooks {

  /**
   * Implements hook_views_pre_render().
   */
  #[Hook('views_pre_render')]
  public function viewsPreRender(ViewExecutable $view): void {
    // We append the function name to the title for test to check for.
    $view->setTitle($view->getTitle() . ":" . 'test_base_theme_views_pre_render');
  }

  /**
   * Implements hook_views_post_render().
   */
  #[Hook('views_post_render')]
  public function viewsPostRender(ViewExecutable $view, &$output, CachePluginBase $cache): void {
    // We append the function name to the title for test to check for.
    $view->setTitle($view->getTitle() . ":" . 'test_base_theme_views_post_render');
  }

  /**
   * Implements hook_preprocess_HOOK() for theme_test_template_test templates.
   */
  #[Hook('preprocess_theme_test_template_test')]
  public function preprocessThemeTestTemplateTest(&$variables): void {
  }

  /**
   * Implements hook_preprocess_HOOK() for theme_test_function_suggestions theme functions.
   */
  #[Hook('preprocess_theme_test_function_suggestions')]
  public function preprocessThemeTestFunctionSuggestions(&$variables): void {
  }

}
+0 −39
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Add hooks for tests to use.
 */

declare(strict_types=1);

use Drupal\views\Plugin\views\cache\CachePluginBase;
use Drupal\views\ViewExecutable;

/**
 * Implements hook_views_pre_render().
 */
function test_base_theme_views_pre_render(ViewExecutable $view): void {
  // We append the function name to the title for test to check for.
  $view->setTitle($view->getTitle() . ":" . __FUNCTION__);
}

/**
 * Implements hook_views_post_render().
 */
function test_base_theme_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache): void {
  // We append the function name to the title for test to check for.
  $view->setTitle($view->getTitle() . ":" . __FUNCTION__);
}

/**
 * Implements hook_preprocess_HOOK() for theme_test_template_test templates.
 */
function test_base_theme_preprocess_theme_test_template_test(&$variables): void {
}

/**
 * Implements hook_preprocess_HOOK() for theme_test_function_suggestions theme functions.
 */
function test_base_theme_preprocess_theme_test_function_suggestions(&$variables): void {
}
+27 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\test_deprecated_suggestion_theme\Hook;

use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for test_deprecated_suggestion_theme.
 */
class TestDeprecatedSuggestionThemeHooks {

  /**
   * Implements hook_theme_suggestions_alter().
   */
  #[Hook('theme_suggestions_alter')]
  public function themeSuggestionsAlter(array &$suggestions, array $variables, $hook): void {
    \Drupal::messenger()->addStatus('test_deprecated_suggestion_theme_theme_suggestions_alter() executed for ' . $hook . '.');
    if ($hook == 'theme_test_suggestion_provided') {
      // Add a deprecated suggestion.
      $suggestions[] = 'theme_test_suggestion_provided__deprecated';
      $suggestions['__DEPRECATED']['theme_test_suggestion_provided__deprecated'] = 'Theme suggestion theme_test_suggestion_provided__deprecated is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. This is a test.';
    }
  }

}
+0 −20
Original line number Diff line number Diff line
<?php

/**
 * @file
 * Theme to help test deprecated theme suggestions.
 */

declare(strict_types=1);

/**
 * Implements hook_theme_suggestions_alter().
 */
function test_deprecated_suggestion_theme_theme_suggestions_alter(array &$suggestions, array $variables, $hook): void {
  \Drupal::messenger()->addStatus(__FUNCTION__ . '() executed for ' . $hook . '.');
  if ($hook == 'theme_test_suggestion_provided') {
    // Add a deprecated suggestion.
    $suggestions[] = 'theme_test_suggestion_provided__deprecated';
    $suggestions['__DEPRECATED']['theme_test_suggestion_provided__deprecated'] = 'Theme suggestion theme_test_suggestion_provided__deprecated is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. This is a test.';
  }
}
+21 −0
Original line number Diff line number Diff line
<?php

declare(strict_types=1);

namespace Drupal\test_subsubtheme\Hook;

use Drupal\Core\Hook\Attribute\Hook;

/**
 * Hook implementations for test_subsubtheme.
 */
class TestSubsubthemeHooks {

  /**
   * Implements hook_preprocess_HOOK() for theme_test_template_test templates.
   */
  #[Hook('preprocess_theme_test_template_test')]
  public function preprocessThemeTestTemplateTest(&$variables): void {
  }

}
Loading