Skip to content
Snippets Groups Projects
Commit fd8e4512 authored by Bálint Junkuncz's avatar Bálint Junkuncz Committed by Wolfgang Ziegler
Browse files

Issue #3431256 by junkuncz: Fix phpstan issues in 3.x CI build.

parent 1416123c
No related branches found
Tags 1.0.1
1 merge request!39Stabilise 3.x CI build
Pipeline #129636 failed
......@@ -48,8 +48,8 @@ include:
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################
# variables:
# SKIP_ESLINT: '1'
variables:
SKIP_CSPELL: '1'
###################################################################################
......
......@@ -9,6 +9,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides dynamic permissions of the custom_elements_ui module.
*
* @phpstan-consistent-constructor
*/
class CustomElementsUiPermissions implements ContainerInjectionInterface {
......
......@@ -24,6 +24,7 @@ class EntityCustomElementsDisplayEditForm extends EntityDisplayFormBase {
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
// @phpstan-ignore-next-line
return new static(
$container->get('plugin.manager.field.field_type'),
$container->get('plugin.manager.field.formatter'),
......
......@@ -11,6 +11,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides Custom Elements local task definitions for all entity bundles.
*
* @phpstan-consistent-constructor
*/
class CustomElementsUiLocalTask extends DeriverBase implements ContainerDeriverInterface {
......
......@@ -120,6 +120,7 @@ class CustomElement implements CacheableDependencyInterface {
* The created custom element.
*/
public static function create($tag = 'div') {
// @phpstan-ignore-next-line
$element = new static();
$element->setTag($tag);
return $element;
......@@ -264,6 +265,7 @@ class CustomElement implements CacheableDependencyInterface {
* @return $this
*/
public function setSlotFromRenderArray($key, array $build, string $tag = 'div', array $attributes = [], int $index = NULL, int $weight = 0) {
// @phpstan-ignore-next-line
$markup = \Drupal::service('renderer')->renderPlain($build);
// Add cache metadata as needed from the cache metadata attached to the
// render array.
......
......@@ -81,14 +81,27 @@ class CustomElementsConfigGenerator implements CustomElementsConfigGeneratorInte
$id = $entity_type_id . '.' . $bundle . '.default';
$element_name = $entity_type_id . '-' . $bundle . '-default';
/** @var \Drupal\custom_elements\Entity\EntityCeDisplayInterface $config */
$config = $storage->create([
'id' => $id,
'targetEntityType' => $entity_type_id,
'bundle' => $bundle,
'customElementName' => $element_name,
'mode' => 'default',
'status' => TRUE,
]);
// These components must be set
// otherwise it breaks item generation.
$components = $config->getComponents();
if (!empty($components)) {
foreach ($components as $key => $component) {
$component['name'] = $key;
$component['is_slot'] = FALSE;
$config->setComponent($key, $component);
}
}
$config->save();
}
}
......
......@@ -91,6 +91,7 @@ class DefaultContentEntityProcessor implements CustomElementProcessorInterface {
*/
public function getEntityTypeManager() {
if (empty($this->entityTypeManager)) {
// @phpstan-ignore-next-line
$this->entityTypeManager = \Drupal::entityTypeManager();
}
return $this->entityTypeManager;
......@@ -126,7 +127,7 @@ class DefaultContentEntityProcessor implements CustomElementProcessorInterface {
}
// Render it from layout builder config if enabled.
// @todo: Solve it in issue #3426888.
// @todo Solve it in issue #3426888.
if ($display->getThirdPartySetting('layout_builder', 'enabled')) {
// Skip processing of the fields and let the layout builder render it all.
$this->addLayoutBuilderContent($entity, $element, $display);
......@@ -140,7 +141,6 @@ class DefaultContentEntityProcessor implements CustomElementProcessorInterface {
}
/**
* Add content of layout builder to the element.
*
......@@ -177,7 +177,6 @@ class DefaultContentEntityProcessor implements CustomElementProcessorInterface {
$custom_element->addCacheableDependency(BubbleableMetadata::createFromRenderArray($build));
}
/**
* Builds custom element from configuration.
*
......@@ -257,7 +256,6 @@ class DefaultContentEntityProcessor implements CustomElementProcessorInterface {
return $elements;
}
/**
* Fetch raw field items data and adds to the custom element.
*
......
......@@ -69,6 +69,9 @@ class CustomElementsRenderMarkupTest extends BrowserTestBase {
$this->image->save();
$config = $this->config('custom_elements.settings');
$config->save();
$config_generator = \Drupal::service('custom_elements.default_config_generator');
$config_generator->initializeConfig();
}
/**
......
......@@ -71,6 +71,9 @@ class CustomElementsRenderMarkupVue3Test extends BrowserTestBase {
$config = $this->config('custom_elements.settings');
$config->set('markup_style', 'vue-3');
$config->save();
$config_generator = \Drupal::service('custom_elements.default_config_generator');
$config_generator->initializeConfig();
}
/**
......
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