Browse Source

Code clean-up

8.x-1.x
Chi 5 years ago
parent
commit
3f5be90b3a
  1. 29
      composer.json
  2. 4
      src/TwigExtension.php
  3. 6
      tests/src/Functional/TwigTweakTest.php

29
composer.json

@ -1,15 +1,18 @@
{ {
"name": "drupal/twig_tweak", "name": "drupal/twig_tweak",
"type": "drupal-module", "type": "drupal-module",
"description": "A Twig extension with some useful functions and filters for Drupal development.", "description": "A Twig extension with some useful functions and filters for Drupal development.",
"keywords": ["Drupal", "Twig"], "keywords": ["Drupal", "Twig"],
"license": "GPL-2.0+", "license": "GPL-2.0+",
"homepage": "https://www.drupal.org/project/twig_tweak", "homepage": "https://www.drupal.org/project/twig_tweak",
"suggest": { "suggest": {
"symfony/var-dumper": "better dump() function for debugging Twig variables" "symfony/var-dumper": "better dump() function for debugging Twig variables"
}, },
"support": { "support": {
"issues": "https://www.drupal.org/project/issues/twig_tweak", "issues": "https://www.drupal.org/project/issues/twig_tweak",
"source": "http://cgit.drupalcode.org/twig_tweak" "source": "http://cgit.drupalcode.org/twig_tweak"
} },
"require": {
"drupal/core": "^8.5"
}
} }

4
src/TwigExtension.php

@ -312,11 +312,9 @@ class TwigExtension extends \Twig_Extension {
* *
* @return array * @return array
* A render array to disable caching. * A render array to disable caching.
*
* @see drupal_set_message()
*/ */
public function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) { public function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) {
drupal_set_message($message, $type, $repeat); \Drupal::messenger()->addMessage($message, $type, $repeat);
$build['#cache']['max-age'] = 0; $build['#cache']['max-age'] = 0;
return $build; return $build;
} }

6
tests/src/Functional/TwigTweakTest.php

@ -12,6 +12,11 @@ use Drupal\Tests\BrowserTestBase;
*/ */
class TwigTweakTest extends BrowserTestBase { class TwigTweakTest extends BrowserTestBase {
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'classy';
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -73,7 +78,6 @@ class TwigTweakTest extends BrowserTestBase {
// Test region. // Test region.
$xpath = '//div[@class = "tt-region"]'; $xpath = '//div[@class = "tt-region"]';
$xpath .= '/div[contains(@class, "block-page-title-block") and h1[@class="page-title" and text() = "Log in"]]'; $xpath .= '/div[contains(@class, "block-page-title-block") and h1[@class="page-title" and text() = "Log in"]]';
$xpath .= '/following-sibling::div[@class="messages messages--warning" and contains(., "Hi!")]';
$xpath .= '/following-sibling::div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]'; $xpath .= '/following-sibling::div[contains(@class, "block-system-powered-by-block")]/span[. = "Powered by Drupal"]';
$this->assertByXpath($xpath); $this->assertByXpath($xpath);

Loading…
Cancel
Save