Browse Source

Fixed code style issues

merge-requests/7/head 8.x-2.9
Chi 4 years ago
parent
commit
b388508f13
  1. 10
      src/TwigExtension.php
  2. 5
      tests/src/Kernel/AccessTest.php

10
src/TwigExtension.php

@ -536,7 +536,7 @@ class TwigExtension extends AbstractExtension {
->addCacheTags($entity_type->getListCacheTags()) ->addCacheTags($entity_type->getListCacheTags())
->addCacheContexts($entity_type->getListCacheContexts()); ->addCacheContexts($entity_type->getListCacheContexts());
/* @var $blocks \Drupal\block\BlockInterface[] */ /** @var \Drupal\block\BlockInterface[] $blocks */
foreach ($blocks as $id => $block) { foreach ($blocks as $id => $block) {
$access = $block->access('view', NULL, TRUE); $access = $block->access('view', NULL, TRUE);
$cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($access)); $cache_metadata = $cache_metadata->merge(CacheableMetadata::createFromObject($access));
@ -1054,7 +1054,7 @@ class TwigExtension extends AbstractExtension {
* in an <img> tag. Requesting the URL will cause the image to be created. * in an <img> tag. Requesting the URL will cause the image to be created.
*/ */
public function imageStyle($path, $style) { public function imageStyle($path, $style) {
// @phpcs:ignore DrupalPractice.Objects.GlobalClass.GlobalClass
if (!$image_style = ImageStyle::load($style)) { if (!$image_style = ImageStyle::load($style)) {
trigger_error(sprintf('Could not load image style %s.', $style)); trigger_error(sprintf('Could not load image style %s.', $style));
return; return;
@ -1336,17 +1336,17 @@ class TwigExtension extends AbstractExtension {
/** /**
* Returns the translation for the given entity. * Returns the translation for the given entity.
* *
* @param object $entity * @param \Drupal\Core\Entity\EntityInterface $entity
* The entity to get the translation from. * The entity to get the translation from.
*
* @param string $langcode * @param string $langcode
* (optional) For which language the translation should be looked for, * (optional) For which language the translation should be looked for,
* defaults to the current language context. * defaults to the current language context.
* *
* @return EntityInterface * @return \Drupal\Core\Entity\EntityInterface
* The appropriate translation for the given language context. * The appropriate translation for the given language context.
*/ */
public function entityTranslation(EntityInterface $entity, $langcode = NULL) { public function entityTranslation(EntityInterface $entity, $langcode = NULL) {
return \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode); return \Drupal::service('entity.repository')->getTranslationFromContext($entity, $langcode);
} }
} }

5
tests/src/Kernel/AccessTest.php

@ -270,7 +270,10 @@ class AccessTest extends KernelTestBase {
self::assertSame($expected_cache, $build['#cache']); self::assertSame($expected_cache, $build['#cache']);
// -- Privileged user with access check. // -- Privileged user with access check.
$this->setUpCurrentUser(['name' => 'User 2'], ['access content', 'create article content']); $this->setUpCurrentUser(
['name' => 'User 2'],
['access content', 'create article content'],
);
$build = $this->twigExtension->drupalEntityForm('node', NULL, 'default', $node_values); $build = $this->twigExtension->drupalEntityForm('node', NULL, 'default', $node_values);
self::assertArrayHasKey('form_id', $build); self::assertArrayHasKey('form_id', $build);

Loading…
Cancel
Save