Skip to content
Snippets Groups Projects
Commit d79031dc authored by Yevhen Lebid's avatar Yevhen Lebid Committed by Dima Storozhuk
Browse files

Issue #3436598 by yevhenlebid51, dstorozhuk: Setup GitLab CI pipelines for...

Issue #3436598 by yevhenlebid51, dstorozhuk: Setup GitLab CI pipelines for phpcs, phpstan, eslint, composer validations
parent 8acfa700
No related branches found
No related tags found
1 merge request!6#3436598: Add .gitlab-ci.yml
Pipeline #132128 passed
{
"version": "0.1",
"language": "en",
"words": [
"Dstorozhuk",
"Goodboy"
],
"ignorePaths": [
"resources/**"
]
}
\ No newline at end of file
################
# 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" value can be:
# - Recommended (default) - `ref: $_GITLAB_TEMPLATES_REF` - The Drupal Association will update this value to the recommended tag for contrib.
# - Latest - `ref: main` - Get the latest additions and bug fixes as they are merged into the templates.
# - Minor or Major latests - `ref: 1.x-latest` or `ref: 1.0.x-latest` - Get the latest additions within a minor (mostly bugfixes) or major (bugs and new features).
# - Fixed tag - `ref: 1.0.1` - Set the value to a known tag. This will not get any updates.
# If you change the default value of ref, you should set the _CURL_TEMPLATES_REF variable in the variables section to be the same as set here.
ref: $_GITLAB_TEMPLATES_REF
file:
- "/includes/include.drupalci.main.yml"
# 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/main/includes/include.drupalci.variables.yml
################
# variables:
# SKIP_ESLINT: '1'
# OPT_IN_TEST_NEXT_MAJOR: '1'
# _CURL_TEMPLATES_REF: 'main'
###################################################################################
#
# *
# /(
# ((((,
# /(((((((
# ((((((((((*
# ,(((((((((((((((
# ,(((((((((((((((((((
# ((((((((((((((((((((((((*
# *(((((((((((((((((((((((((((((
# ((((((((((((((((((((((((((((((((((*
# *(((((((((((((((((( .((((((((((((((((((
# ((((((((((((((((((. /(((((((((((((((((*
# /((((((((((((((((( .(((((((((((((((((,
# ,(((((((((((((((((( ((((((((((((((((((
# .(((((((((((((((((((( .(((((((((((((((((
# ((((((((((((((((((((((( ((((((((((((((((/
# (((((((((((((((((((((((((((/ ,(((((((((((((((*
# .((((((((((((((/ /(((((((((((((. ,(((((((((((((((
# *(((((((((((((( ,(((((((((((((/ *((((((((((((((.
# ((((((((((((((, /(((((((((((((. ((((((((((((((,
# (((((((((((((/ ,(((((((((((((* ,(((((((((((((,
# *((((((((((((( .((((((((((((((( ,(((((((((((((
# ((((((((((((/ /((((((((((((((((((. ,((((((((((((/
# ((((((((((((( *(((((((((((((((((((((((* *((((((((((((
# ((((((((((((( ,(((((((((((((..((((((((((((( *((((((((((((
# ((((((((((((, /((((((((((((* /((((((((((((/ ((((((((((((
# ((((((((((((( /((((((((((((/ (((((((((((((* ((((((((((((
# (((((((((((((/ /(((((((((((( ,((((((((((((, *((((((((((((
# (((((((((((((( *(((((((((((/ *((((((((((((. ((((((((((((/
# *((((((((((((((((((((((((((, /(((((((((((((((((((((((((
# ((((((((((((((((((((((((( ((((((((((((((((((((((((,
# .(((((((((((((((((((((((/ ,(((((((((((((((((((((((
# ((((((((((((((((((((((/ ,(((((((((((((((((((((/
# *((((((((((((((((((((( (((((((((((((((((((((,
# ,(((((((((((((((((((((, ((((((((((((((((((((/
# ,(((((((((((((((((((((* /((((((((((((((((((((
# ((((((((((((((((((((((, ,/((((((((((((((((((((,
# ,(((((((((((((((((((((((((((((((((((((((((((((((((((
# .(((((((((((((((((((((((((((((((((((((((((((((
# .((((((((((((((((((((((((((((((((((((,.
# .,(((((((((((((((((((((((((.
#
###################################################################################
includes:
- phar://phpstan.phar/conf/bleedingEdge.neon
parameters:
level: 1
reportUnmatchedIgnoredErrors: false
ignoreErrors:
# new static() is a best practice in Drupal, so we cannot fix that.
- "#^Unsafe usage of new static#"
\ No newline at end of file
......@@ -15,6 +15,7 @@ use Drupal\field\FieldStorageConfigInterface;
* Views integration for simple address fields.
*/
function simple_address_field_views_data(FieldStorageConfigInterface $field) {
$data = [];
$field_type = $field->getType();
if ($field_type == 'simple_address') {
$data = views_field_default_views_data($field);
......
......@@ -83,7 +83,7 @@ class AddressRepository {
*/
public function getCountriesAlpha2Codes() {
$mapping = &drupal_static(__METHOD__, []);
if (empty($countries)) {
if (empty($mapping)) {
$mapping_storage = $this->modulePath . "/resources/countries_alfa_2_3_mapping.json";
$mapping = Json::decode(file_get_contents($mapping_storage));
}
......
......@@ -5,9 +5,12 @@ namespace Drupal\simple_address\Plugin\Field\FieldWidget;
use Drupal\Component\Utility\Html;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\DependencyInjection\DependencySerializationTrait;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\simple_address\AddressRepository;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Plugin implementation of the 'simple_address_widget' widget.
......@@ -25,6 +28,37 @@ class AddressWidget extends WidgetBase {
use DependencySerializationTrait;
/**
* The address repository service.
*/
protected AddressRepository $addressRepository;
public function __construct(
$plugin_id,
$plugin_definition,
FieldDefinitionInterface $field_definition,
array $settings,
array $third_party_settings,
AddressRepository $address_repository
) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
$this->addressRepository = $address_repository;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['third_party_settings'],
$container->get('simple_address.address_repository')
);
}
/**
* {@inheritdoc}
*/
......@@ -140,7 +174,7 @@ class AddressWidget extends WidgetBase {
*/
private function getCountryOptions(array $available_countries = []): array {
// phpcs:disable
$options = \Drupal::service('simple_address.address_repository')->getCountryOptions();
$options = $this->addressRepository->getCountryOptions();
// For some reason, DI doesn't work here with ajax.
// phpcs:enable
......@@ -169,9 +203,8 @@ class AddressWidget extends WidgetBase {
}
// phpcs:disable
// For some reason, DI doesn't work here with ajax.
$repository = \Drupal::service('simple_address.address_repository');
// phpcs:enable
$states = $repository->findSubDivision($country_code);
$states = $this->addressRepository->findSubDivision($country_code);
foreach ($states as $state) {
$options[$state['state_code']] = $state['state'];
}
......
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