Skip to content
Snippets Groups Projects
Unverified Commit 6b24c297 authored by Kevin Wenger's avatar Kevin Wenger Committed by GitHub
Browse files

Issue #3090756 by wengerk: Drupal 9 Readiness

parents 2e0f8645 7c05b1c3
No related branches found
No related tags found
No related merge requests found
...@@ -8,17 +8,19 @@ language: php ...@@ -8,17 +8,19 @@ language: php
sudo: false sudo: false
php: php:
- 7 - 7.3
- 7.1
- 7.2
services: services:
- mysql - mysql
matrix: matrix:
fast_finish: true include:
allow_failures: - name: D8.8
- php: hhvm env: DRUPAL_TI_RUNNERS="phpunit-core" DRUPAL_TI_CORE_BRANCH="8.8.x" DRUPAL_TI_PHPUNIT_ARGS="--group template_whisperer"
- name: D8.9
env: DRUPAL_TI_RUNNERS="phpunit-core" DRUPAL_TI_CORE_BRANCH="8.9.x" DRUPAL_TI_PHPUNIT_ARGS="--group template_whisperer"
- name: D9.0
env: DRUPAL_TI_RUNNERS="phpunit-core" DRUPAL_TI_ENVIRONMENT="drupal-9" DRUPAL_TI_CORE_BRANCH="9.0.x" DRUPAL_TI_PHPUNIT_ARGS="--group template_whisperer"
env: env:
global: global:
...@@ -39,8 +41,11 @@ env: ...@@ -39,8 +41,11 @@ env:
# The environment to use, supported are: drupal-7, drupal-8 # The environment to use, supported are: drupal-7, drupal-8
- DRUPAL_TI_ENVIRONMENT="drupal-8" - DRUPAL_TI_ENVIRONMENT="drupal-8"
# Switch to 8.6.x versions instead of 8.1.x by default. # The drush version to use, by default: drush/drush:8.0.*
- DRUPAL_TI_CORE_BRANCH="8.6.x" - DRUPAL_TI_DRUSH_VERSION="drush/drush:^10.1.1"
# Switch to 8.9.x versions instead of 8.1.x by default.
- DRUPAL_TI_CORE_BRANCH="8.9.x"
# The installation profile to use: # The installation profile to use:
#- DRUPAL_TI_INSTALL_PROFILE="testing" #- DRUPAL_TI_INSTALL_PROFILE="testing"
...@@ -71,6 +76,7 @@ env: ...@@ -71,6 +76,7 @@ env:
- DRUPAL_TI_BEHAT_BROWSER="firefox" - DRUPAL_TI_BEHAT_BROWSER="firefox"
# PHPUnit specific commandline arguments. # PHPUnit specific commandline arguments.
- DRUPAL_TI_PHPUNIT_VERSION="^7.0"
- DRUPAL_TI_PHPUNIT_ARGS="" - DRUPAL_TI_PHPUNIT_ARGS=""
# Specifying the phpunit-core src/ directory is useful when e.g. a vendor/ # Specifying the phpunit-core src/ directory is useful when e.g. a vendor/
# directory is present in the module directory, which phpunit would then # directory is present in the module directory, which phpunit would then
...@@ -106,7 +112,8 @@ mysql: ...@@ -106,7 +112,8 @@ mysql:
before_install: before_install:
- composer self-update - composer self-update
- cd ./tests - cd ./tests
- composer global require "lionsad/drupal_ti:1.*" - composer global config repositories.repo-name git https://github.com/wengerk/drupal_ti
- composer global require "lionsad/drupal_ti:dev-add-drupal-9-support"
- drupal-ti before_install - drupal-ti before_install
install: install:
...@@ -114,8 +121,6 @@ install: ...@@ -114,8 +121,6 @@ install:
before_script: before_script:
- drupal-ti before_script - drupal-ti before_script
# Update from PHPUnit 4.x to 6.x as required by Drupal 8.6.x.
- composer run-script drupal-phpunit-upgrade --working-dir=/home/travis/build/antistatique/drupal-8/drupal --no-interaction
script: script:
# Disable deprecations helper to avoid build failed caused by usage of # Disable deprecations helper to avoid build failed caused by usage of
......
...@@ -18,7 +18,7 @@ Github repo ...@@ -18,7 +18,7 @@ Github repo
```bash ```bash
git remote add github \ git remote add github \
https://github.com/antistatique/drupal-template-whisperer.git git@github.com:antistatique/drupal-bamboo-twig.git
``` ```
## 🔧 Prerequisites ## 🔧 Prerequisites
......
...@@ -68,11 +68,23 @@ but those are some of the obvious uses of Template Whisperer. ...@@ -68,11 +68,23 @@ but those are some of the obvious uses of Template Whisperer.
## Template Whisperer versions ## Template Whisperer versions
Template Whisperer is only available for Drupal 8 ! Template Whisperer is available for Drupal 8 and Drupal 9!
The module is ready to be used in Drupal 8, there are no known issues.
This version should work with all Drupal 8 releases, and it is always - If you are running Drupal `8.7.x`, use Template Whisperer `2.x`.
recommended to keep Drupal core installations up to date. - If you are running Drupal `8.8.x`, use Bamboo Twig `3.x`.
The version `8.x-3.x` is not compatible with Drupal `8.7.x`.
Drupal `8.8.x` brings some breaking change with tests and so you
must upgrade to `8.x-3.x` version of **Bamboo Twig**.
## Which version should I use?
|Drupal Core|Bamboo Twig|
|:---------:|:---------:|
|8.0.x |1.x |
|8.4.x |2.x |
|8.8.x |3.x |
|9.x |3.x |
## Dependencies ## Dependencies
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
namespace Drupal\template_whisperer\Controller; namespace Drupal\template_whisperer\Controller;
use Drupal\Core\Pager\PagerManagerInterface;
use Drupal\template_whisperer\Entity\TemplateWhispererSuggestionEntityInterface; use Drupal\template_whisperer\Entity\TemplateWhispererSuggestionEntityInterface;
use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Controller\ControllerBase;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
...@@ -35,13 +36,21 @@ class AdminSuggestionController extends ControllerBase { ...@@ -35,13 +36,21 @@ class AdminSuggestionController extends ControllerBase {
*/ */
protected $urlGenerator; protected $urlGenerator;
/**
* The pager manager.
*
* @var \Drupal\Core\Pager\PagerManagerInterface
*/
protected $pagerManager;
/** /**
* Class constructor. * Class constructor.
*/ */
public function __construct(EntityTypeManagerInterface $entity_type_manager, TemplateWhispererSuggestionUsage $tw_suggestion_usage, UrlGeneratorInterface $url_generator) { public function __construct(EntityTypeManagerInterface $entity_type_manager, TemplateWhispererSuggestionUsage $tw_suggestion_usage, UrlGeneratorInterface $url_generator, PagerManagerInterface $pager_manager) {
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
$this->twSuggestionUsage = $tw_suggestion_usage; $this->twSuggestionUsage = $tw_suggestion_usage;
$this->urlGenerator = $url_generator; $this->urlGenerator = $url_generator;
$this->pagerManager = $pager_manager;
} }
/** /**
...@@ -50,10 +59,11 @@ class AdminSuggestionController extends ControllerBase { ...@@ -50,10 +59,11 @@ class AdminSuggestionController extends ControllerBase {
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
// Instantiates this form class. // Instantiates this form class.
return new static( return new static(
// Load the service required to construct this class. // Load the service required to construct this class.
$container->get('entity_type.manager'), $container->get('entity_type.manager'),
$container->get('template_whisperer.suggestion.usage'), $container->get('template_whisperer.suggestion.usage'),
$container->get('url_generator') $container->get('url_generator'),
$container->get('pager.manager')
); );
} }
...@@ -84,8 +94,8 @@ class AdminSuggestionController extends ControllerBase { ...@@ -84,8 +94,8 @@ class AdminSuggestionController extends ControllerBase {
$usages = $this->twSuggestionUsage->listUsage($template_whisperer_suggestion); $usages = $this->twSuggestionUsage->listUsage($template_whisperer_suggestion);
$count = $this->twSuggestionUsage->countUsage($template_whisperer_suggestion); $count = $this->twSuggestionUsage->countUsage($template_whisperer_suggestion);
$this->pagerManager->createPager($count, 30);
// Pager. // Pager.
pager_default_initialize($count, 30);
$output[] = [ $output[] = [
'#type' => 'pager', '#type' => 'pager',
'#quantity' => '3', '#quantity' => '3',
...@@ -105,7 +115,7 @@ class AdminSuggestionController extends ControllerBase { ...@@ -105,7 +115,7 @@ class AdminSuggestionController extends ControllerBase {
// Build the table empty state. // Build the table empty state.
if (!empty($entity)) { if (!empty($entity)) {
$output['table'][$i]['entity'] = ['#markup' => '<a target="_blank" href="' . $entity->url() . '">' . $entity->getTitle() . '</a>']; $output['table'][$i]['entity'] = ['#markup' => '<a target="_blank" href="' . $entity->toUrl()->toString() . '">' . $entity->getTitle() . '</a>'];
} }
} }
......
...@@ -34,6 +34,11 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; ...@@ -34,6 +34,11 @@ use Drupal\Core\Config\Entity\ConfigEntityBase;
* "collection" = "/admin/structure/template-whisperer", * "collection" = "/admin/structure/template-whisperer",
* "usage" = "/admin/structure/template-whisperer/{template_whisperer_suggestion}/usage", * "usage" = "/admin/structure/template-whisperer/{template_whisperer_suggestion}/usage",
* }, * },
* config_export = {
* "id",
* "name",
* "suggestion",
* }
* ) * )
*/ */
class TemplateWhispererSuggestionEntity extends ConfigEntityBase implements TemplateWhispererSuggestionEntityInterface { class TemplateWhispererSuggestionEntity extends ConfigEntityBase implements TemplateWhispererSuggestionEntityInterface {
......
...@@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -15,7 +15,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @Condition( * @Condition(
* id = "template_whisperer", * id = "template_whisperer",
* label = @Translation("Template Whisperer"), * label = @Translation("Template Whisperer"),
* context = { * context_definitions = {
* "node" = @ContextDefinition("entity:node", label = @Translation("Node")) * "node" = @ContextDefinition("entity:node", label = @Translation("Node"))
* } * }
* ) * )
......
...@@ -8,6 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -8,6 +8,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityStorageInterface; use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Routing\UrlGeneratorInterface;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
/** /**
* Defines a class to build a listing of templates whisperer entities. * Defines a class to build a listing of templates whisperer entities.
...@@ -54,7 +55,7 @@ class TemplateWhispererSuggestionListBuilder extends ConfigEntityListBuilder { ...@@ -54,7 +55,7 @@ class TemplateWhispererSuggestionListBuilder extends ConfigEntityListBuilder {
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) { public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
return new static( return new static(
$entity_type, $entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()), $container->get('entity_type.manager')->getStorage($entity_type->id()),
$container->get('url_generator'), $container->get('url_generator'),
$container->get('template_whisperer.suggestion.usage') $container->get('template_whisperer.suggestion.usage')
); );
......
name: Template Whisperer name: Template Whisperer
type: module type: module
description: Provides a formalized way to declare and suggest page templates. description: Provides a formalized way to declare and suggest page templates.
core: 8.x core_version_requirement: ^8.8 || ^9
package: Fields types package: Fields types
dependencies: dependencies:
......
...@@ -9,6 +9,11 @@ use Drupal\Tests\BrowserTestBase; ...@@ -9,6 +9,11 @@ use Drupal\Tests\BrowserTestBase;
*/ */
abstract class TemplateWhispererTestBase extends BrowserTestBase { abstract class TemplateWhispererTestBase extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
/** /**
* Enables Twig debugging. * Enables Twig debugging.
*/ */
......
...@@ -12,6 +12,11 @@ namespace Drupal\Tests\template_whisperer\Functional; ...@@ -12,6 +12,11 @@ namespace Drupal\Tests\template_whisperer\Functional;
*/ */
class UiFieldTest extends TemplateWhispererTestBase { class UiFieldTest extends TemplateWhispererTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -12,6 +12,11 @@ namespace Drupal\Tests\template_whisperer\Functional; ...@@ -12,6 +12,11 @@ namespace Drupal\Tests\template_whisperer\Functional;
*/ */
class UiPageTest extends TemplateWhispererTestBase { class UiPageTest extends TemplateWhispererTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
namespace Drupal\Tests\template_whisperer\Functional; namespace Drupal\Tests\template_whisperer\Functional;
use Drupal\Core\Entity\Entity\EntityFormDisplay;
/** /**
* @coversDefaultClass \Drupal\template_whisperer\Plugin\Field\FieldWidget\TemplateWhispererWidget * @coversDefaultClass \Drupal\template_whisperer\Plugin\Field\FieldWidget\TemplateWhispererWidget
* *
...@@ -90,11 +92,10 @@ class WidgetFormElementTest extends TemplateWhispererTestBase { ...@@ -90,11 +92,10 @@ class WidgetFormElementTest extends TemplateWhispererTestBase {
'bundle' => 'article', 'bundle' => 'article',
])->save(); ])->save();
entity_get_form_display('node', 'article', 'default') EntityFormDisplay::load('node.article.default')->setComponent('field_template_whisperer_1', [
->setComponent('field_template_whisperer_1', [ 'type' => 'template_whisperer',
'type' => 'template_whisperer', 'weight' => 20,
'weight' => 20, ])->save();
])->save();
$this->article = $em->getStorage('node')->create([ $this->article = $em->getStorage('node')->create([
'type' => 'article', 'type' => 'article',
...@@ -127,11 +128,15 @@ class WidgetFormElementTest extends TemplateWhispererTestBase { ...@@ -127,11 +128,15 @@ class WidgetFormElementTest extends TemplateWhispererTestBase {
'bundle' => 'tags', 'bundle' => 'tags',
])->save(); ])->save();
entity_get_form_display('taxonomy_term', 'tags', 'default') EntityFormDisplay::create([
->setComponent('field_template_whisperer_2', [ 'targetEntityType' => 'taxonomy_term',
'type' => 'template_whisperer', 'bundle' => 'tags',
'weight' => 20, 'mode' => 'default',
])->save(); 'status' => TRUE,
])->setComponent('field_template_whisperer_2', [
'type' => 'template_whisperer',
'weight' => 20,
])->save();
$this->tag = $em->getStorage('taxonomy_term')->create([ $this->tag = $em->getStorage('taxonomy_term')->create([
'name' => 'Tags N°1', 'name' => 'Tags N°1',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment