Skip to content
Snippets Groups Projects
Commit 7f3fae16 authored by Bohdan Melnychuk's avatar Bohdan Melnychuk Committed by Damien McKenna
Browse files

#3413255 by bobi-mel, damienmckenna: Enabled testing with GitLab CI; resolved phpstan issues.

parent de24c91d
No related branches found
No related tags found
1 merge request!12Issue #3413255: Change Testing to GitLab CI
Pipeline #390570 failed
################
# DrupalCI GitLabCI template
#
# Gitlab-ci.yml to replicate DrupalCI testing for Contrib
#
# With thanks to:
# * The GitLab Acceleration Initiative participants
# * DrupalSpoons
################
################
# Guidelines
#
# This template is designed to give any Contrib maintainer everything they need to test, without requiring modification. It is also designed to keep up to date with Core Development automatically through the use of include files that can be centrally maintained.
#
# However, you can modify this template if you have additional needs for your project.
################
################
# Includes
#
# Additional configuration can be provided through includes.
# One advantage of include files is that if they are updated upstream, the changes affect all pipelines using that include.
#
# Includes can be overridden by re-declaring anything provided in an include, here in gitlab-ci.yml
# https://docs.gitlab.com/ee/ci/yaml/includes.html#override-included-configuration-values
################
include:
################
# DrupalCI includes:
# As long as you include this, any future includes added by the Drupal Association will be accessible to your pipelines automatically.
# View these include files at https://git.drupalcode.org/project/gitlab_templates/
################
- project: $_GITLAB_TEMPLATES_REPO
ref: $_GITLAB_TEMPLATES_REF
file:
- '/includes/include.drupalci.main.yml'
# EXPERIMENTAL: For Drupal 7, remove the above line and uncomment the below.
# - '/includes/include.drupalci.main-d7.yml'
- '/includes/include.drupalci.variables.yml'
- '/includes/include.drupalci.workflows.yml'
################
# Pipeline configuration variables
#
# These are the variables provided to the Run Pipeline form that a user may want to override.
#
# Docs at https://git.drupalcode.org/project/gitlab_templates/-/blob/1.0.x/includes/include.drupalci.variables.yml
################
# variables:
# SKIP_ESLINT: '1'
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/
# ((((((((((((( *(((((((((((((((((((((((* *((((((((((((
# ((((((((((((( ,(((((((((((((..((((((((((((( *((((((((((((
# ((((((((((((, /((((((((((((* /((((((((((((/ ((((((((((((
# ((((((((((((( /((((((((((((/ (((((((((((((* ((((((((((((
# (((((((((((((/ /(((((((((((( ,((((((((((((, *((((((((((((
# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
###################################################################################
# Configuration file for PHPStan static code checking.
# @see: https://git.drupalcode.org/project/drupal/-/blob/10.0.x/core/phpstan.neon.dist
parameters:
level: 1
ignoreErrors:
# new static() is a best practice in Drupal, so we cannot fix that.
# @see https://www.drupal.org/docs/develop/development-tools/phpstan/handling-unsafe-usage-of-new-static
- "#^Unsafe usage of new static#"
......@@ -2,11 +2,11 @@
namespace Drupal\taxonomy_menu\Form;
use Drupal\Core\Entity\EntityFieldManager;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Menu\MenuParentFormSelector;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Drupal\Core\Entity\EntityFieldManager;
/**
* Builds the taxonomy menu form.
......@@ -190,7 +190,7 @@ class TaxonomyMenuForm extends EntityForm {
/**
* {@inheritdoc}
*/
public function save(array $form, FormStateInterface $form_state) {
public function save(array $form, FormStateInterface $form_state): void {
$taxonomy_menu = $this->entity;
$status = $taxonomy_menu->save();
......
......@@ -3,8 +3,8 @@
namespace Drupal\taxonomy_menu\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......
......@@ -106,10 +106,10 @@ class TaxonomyMenuMenuLink extends MenuLinkBase implements ContainerFactoryPlugi
public function getTitle() {
/** @var \Drupal\taxonomy\Entity\Term. $link */
$link = $this->entityTypeManager->getStorage('taxonomy_term')
->load($this->pluginDefinition['metadata']['taxonomy_term_id']);
->load($this->pluginDefinition['metadata']['taxonomy_term_id']) ?? NULL;
$language = $this->languageManager->getCurrentLanguage()->getId();
if (!empty($link) && $link->hasTranslation($language)) {
if ($link && $link->hasTranslation($language)) {
$translation = $link->getTranslation($language);
return $translation->label();
}
......@@ -126,23 +126,28 @@ class TaxonomyMenuMenuLink extends MenuLinkBase implements ContainerFactoryPlugi
public function getDescription() {
/** @var \Drupal\taxonomy\Entity\Term. $link */
$link = $this->entityTypeManager->getStorage('taxonomy_term')
->load($this->pluginDefinition['metadata']['taxonomy_term_id']);
->load($this->pluginDefinition['metadata']['taxonomy_term_id']) ?? NULL;
// Get the description field name.
$taxonomy_menu = $this->entityTypeManager->getStorage('taxonomy_menu')->load($this->pluginDefinition['metadata']['taxonomy_menu_id']);
$description_field_name = !empty($taxonomy_menu) ? $taxonomy_menu->getDescriptionFieldName() : '';
$taxonomy_menu = $this->entityTypeManager->getStorage('taxonomy_menu')
->load($this->pluginDefinition['metadata']['taxonomy_menu_id']);
$description_field_name = !empty($taxonomy_menu)
? $taxonomy_menu->getDescriptionFieldName()
: '';
$language = $this->languageManager->getCurrentLanguage()->getId();
if (!empty($link) && $link->hasTranslation($language)) {
$translation = $link->getTranslation($language);
if (!empty($translation) && $translation->hasField($description_field_name)) {
if ($link && $link->hasTranslation($language)) {
$translation = $link->getTranslation($language) ?? NULL;
if ($translation && $translation->hasField($description_field_name)) {
return $translation->{$description_field_name}->value;
}
}
elseif (!empty($link) && $link->hasField($description_field_name)) {
elseif ($link && $link->hasField($description_field_name)) {
return $link->{$description_field_name}->value;
}
return NULL;
}
/**
......
......@@ -146,7 +146,7 @@ class TaxonomyMenuHelper {
}
// Remove specific term link.
// Note: this link does not exist in the taxonomy menu and not in $links.
elseif (!empty($term)) {
else {
$this->manager->removeDefinition($menu->buildMenuPluginId($term), FALSE);
}
}
......
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