diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 33fc66f2683080e05ad579f516dbc9e01845e19f..d6afb7b7318bc8444be83d1efc1e2c2af5fbcf45 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,160 +1,4 @@ -################################################################################ -# Gitlab CI integration for Drupal 8/9 project or module: tests, code quality, -# linting, metrics and deploy samples. -# -# Project: https://gitlab.com/mog33/gitlab-ci-drupal -# Documentation: https://mog33.gitlab.io/gitlab-ci-drupal -# Issues: https://gitlab.com/mog33/gitlab-ci-drupal/-/issues -# Author: Jean Valverde contact@dev-drupal.com -# License: GPL-3 -# -# If you want to support this project, you can -# - Buy me a coffee: https://bit.ly/34jPKcE -# - Hire me as a freelance for any Drupal related work -# - Promote me to any company looking for any Drupal related work -# - Help me with testing / documentation / grammar fixes / use cases -# -################################################################################ - -# The ref is relative to the version of the project to use, best to use a tag. include: - # If hosted on gitlab.com. - # - project: 'mog33/gitlab-ci-drupal' - # ref: 3.x-dev - # file: '/.gitlab-ci/.gitlab-ci-template.yml' - # If hosted on an other Gitlab instance. - # - remote: 'https://gitlab.com/mog33/gitlab-ci-drupal/-/raw/3.x-dev/.gitlab-ci/.gitlab-ci-template.yml' - - remote: 'https://git.startx.be/forks/gitlab-ci-drupal/-/raw/startx/.gitlab-ci/.gitlab-ci-template.yml' - -# If needed by your Gitlab-ci instance, you can set global tags for all jobs. -# default: -# tags: -# - docker - -################################################################################ -# Gitlab-CI variables documentation: -# https://docs.gitlab.com/ee/ci/variables/ -# -# Variables, can be set here or on -# Gitlab CI UI > settings > CI/CD > variables -# UI take precedence on variables here. -# https://docs.gitlab.com/ee/ci/variables/README.html#priority-of-environment-variables -################################################################################ - -variables: - # This is mandatory to get default variables. - extends: .default_variables - - # Global config remote files ref. - # MUST be the same as include: ref: from above. - CI_REF: 3.x-dev - - # Set a version, default is Drupal 8.9, can be 9.0 or 9.1. - # CI_DRUPAL_VERSION: "8.9" - - ############################################################################## - # Tests disabled by default because need a specific setup / configuration. - # - # Only needed if you have Behat tests, comment or set to 0 to enable. - # https://mog33.gitlab.io/gitlab-ci-drupal/advanced-usage/#behat-tests - SKIP_TEST_BEHAT: 1 - - # Accessibility tests, need a profile and setup. - # https://mog33.gitlab.io/gitlab-ci-drupal/advanced-usage/#accessibility-with-pa11y - SKIP_TEST_PA11Y: 1 - - # Only if you have Nightwatch tests in your code. - # https://mog33.gitlab.io/gitlab-ci-drupal/advanced-usage/#nightwatchjs - SKIP_TEST_NIGHTWATCH: 1 - # Default is '--skiptags core', add your tag. - # NIGHTWATCH_TESTS: --tag my_module - - # Phpunit tests to run, default provide only custom code or if this variable - # is empty all tests (including Drupal core). - # https://mog33.gitlab.io/gitlab-ci-drupal/advanced-usage/#phpunit-tests - PHPUNIT_TESTS: "custom" - - ############################################################################## - # Override default variables for a module. - # - # Default CI setup is for a 'project' (full Drupal with a composer.json), next - # section contains common variables to change for a module (module, theme or - # profile). Simply uncomment and adapt dirs to set the CI for a module. - # - CI_TYPE: module - # Code quality dirs, must include your PHP code to check. - # Phpstan need autoloading, that's why we use web_root. - DIRS_QA: "${WEB_ROOT}/modules/custom" - # Eslint / Stylelint files to test. - DIRS_JS: "${CI_PROJECT_DIR}/js/*.js" - DIRS_CSS: "${CI_PROJECT_DIR}/css/*.css" - # Twig files to test. - DIRS_TWIG: "${CI_PROJECT_DIR}/templates" - # phpmetrics / phpstats dirs to include. - DIRS_PHP: "${CI_PROJECT_DIR}" - # Set SKIP_XXX variable to 1 to skip. - # Security is for a Drupal project with third party. - SKIP_TEST_SECURITY: 1 - # If you don't have any css files, you can skip with - SKIP_LINT_CSS: 1 - # If you don't have any javascript files, you can skip with - SKIP_LINT_JS: 1 - # If you don't have any twig files, you can skip with - SKIP_LINT_TWIG: 1 - # - ############################################################################## - - ############################################################################## - # As a sample here is a list of some variables, see documentation for more - # variables. - # - # List of DIRS_* variables to define dirs to analyse for specific jobs. - # Code quality dirs, must include your PHP code to check. - # - # DIRS_QA: "${WEB_ROOT}/modules/custom,${WEB_ROOT}/themes/custom" - # - # Eslint / Stylelint files to test. - # Space separated for multiple folders. - # Default is to check files under all custom folders. - # - # DIRS_JS: "${WEB_ROOT}/**/custom/**/*.js" - # DIRS_CSS: "${WEB_ROOT}/**/custom/**/css/*.css" - # - # Twig files to test, recursive. - # - # DIRS_TWIG: "${WEB_ROOT}/themes/custom" - # - # Phpmetrics / Phpstats dirs to include. - # Default is to check all dirs. - # - # DIRS_PHP: "${WEB_ROOT}/modules/custom,${WEB_ROOT}/themes/custom" - # - # # ALL SKIP variables, uncomment and set to 1 to skip a job. - # SKIP_BUILD: 1 # if not running any tests or deploy. - # - # SKIP_TESTS: 1 # Skip all tests, ignore SKIP_TEST_*. - # SKIP_TEST_UNITKERNEL: 1 - # SKIP_TEST_FUNCTIONAL: 1 - # SKIP_TEST_FUNCTIONALJS: 1 - # SKIP_TEST_SECURITY: 1 - # - # SKIP_QA: 1 - # - # SKIP_LINT: 1 # Skip all lint, ignore SKIP_LINT_*. - # SKIP_LINT_CSS: 1 - # SKIP_LINT_JS: 1 - # SKIP_LINT_TWIG: 1 - # - # SKIP_METRICS: 1 - - # QA and Metrics tools. - # See Phpqa available tools: https://github.com/EdgedesignCZ/phpqa#available-tools - # ':0' is the number of errors allowed, default here is very strict. - # - # TOOLS_QA: "phpcs:0,phpmd:0,parallel-lint:0,phpstan:0,phpcpd:0" - # TOOLS_METRICS: "phpmetrics,phploc,pdepend" - -################################################################################ -# Advanced usage with this file, see doc. -# https://mog33.gitlab.io/gitlab-ci-drupal/advanced-usage -################################################################################ + - remote: 'https://git.drupalcode.org/project/gitlab_templates/-/raw/1.0.x/includes/include.drupalci.main.yml' + - remote: 'https://git.drupalcode.org/project/gitlab_templates/-/raw/1.0.x/includes/include.drupalci.variables.yml' + - remote: 'https://git.drupalcode.org/project/gitlab_templates/-/raw/1.0.x/includes/include.drupalci.workflows.yml' diff --git a/.gitlab-ci/build.php b/.gitlab-ci/build.php deleted file mode 100644 index c87d0dee0ad449011a7b91d1bb2449f996e5d788..0000000000000000000000000000000000000000 --- a/.gitlab-ci/build.php +++ /dev/null @@ -1,55 +0,0 @@ -<?php - -/** - * @file - * You can use this file to run extra Robo build tasks. - * - * See RoboFile.php and https://robo.li/ documentation to run a task. - * - * For CI_TYPE='project', this file is executed directly during the Build job - * script after the regular composer install. - * - * For CI_TYPE='module', this file is executed on each 'before_script' part of - * jobs. - * - * It's important to have any action relative to the docRoot or webRoot - * as we are not working from the CI_PROJECT_DIR. - * - * Examples: - * - * $this->say("This will be run in Build script!"); - * - * $this->taskGulpRun() - * ->dir($this->webRoot . 'themes/my_theme_with_gulp_task') - * ->run(); - * - * $this->taskComposerRequire() - * ->noInteraction() - * ->noAnsi() - * ->workingDir($this->docRoot); - * ->dependency('drupal/webform', '^5.13') - * ->run(); - * - * Or shortcut method in the RoboFile.php with this project: - * $this->composerRequire() - * ->dependency('drupal/webform', '^5.13') - * ->run(); - */ - -$this->taskComposerConfig() - ->noInteraction() - ->noAnsi() - ->workingDir($this->docRoot) - ->repository("0", "https://packages.startx.be", "composer") - ->run(); - -$this->taskComposerConfig() - ->noInteraction() - ->noAnsi() - ->workingDir($this->docRoot) - ->repository("1", "https://packages.drupal.org/8", "composer") - ->run(); - -$this->composerRequire() - ->dependency('drupal/views_bulk_operations', '^4.0') - ->run(); diff --git a/composer.json b/composer.json index 078a549fc3816fbc51fb6f6a2e845afae14dccf1..8a4f07ba812d3bbc6af6e69e3f9f79f02ab8c183 100644 --- a/composer.json +++ b/composer.json @@ -13,6 +13,9 @@ "require": { "mikehaertl/phpwkhtmltopdf": "^2.3" }, + "require-dev": { + "drupal/views_bulk_operations": "^4.0" + }, "extra": { "branch-alias": { "dev-master": "1.0.x-dev" diff --git a/mail_template.info.yml b/mail_template.info.yml index 55ba9cbbdaeb72aae17cd4cf030c541b16dc961f..87abe8aa36c52e513b6e2d52423226c9ccca2176 100644 --- a/mail_template.info.yml +++ b/mail_template.info.yml @@ -1,7 +1,7 @@ name: 'Mail Template' type: module description: 'Mail Template' -core_version_requirement: ^8.8 || ^9 +core_version_requirement: ^8.8 || ^9 || ^10 package: 'startx' dependencies: - drupal:views diff --git a/src/Plugin/Action/DownloadDocumentAction.php b/src/Plugin/Action/DownloadDocumentAction.php index dd2979a34f8bb87c52b4a5d9c01b0176578b08c6..6ee3f6a401c0f03a0528c8ba1c2ec4da1de17d52 100644 --- a/src/Plugin/Action/DownloadDocumentAction.php +++ b/src/Plugin/Action/DownloadDocumentAction.php @@ -69,7 +69,7 @@ class DownloadDocumentAction extends ViewsBulkOperationsActionBase { if (count($this->context['sandbox']['results']) > 1) { $destination = $wrapper . '://documents.zip'; - $archive_file = file_save_data(hex2bin('504b0506000000000000000000000000000000000000'), $destination); + $archive_file = \Drupal::service('file.repository')->writeData(hex2bin('504b0506000000000000000000000000000000000000'), $destination); $archive_file->setTemporary(); $archive_file->save(); @@ -84,7 +84,7 @@ class DownloadDocumentAction extends ViewsBulkOperationsActionBase { $file_number++; } - $file_url = Url::fromUri(file_create_url($archive_file->getFileUri())); + $file_url = \Drupal::service('file_url_generator')->generate($archive_file->getFileUri()); $link = Link::fromTextAndUrl($this->t('Click here'), $file_url); $this->messenger()->addMessage($this->t('Document archive created. @link to download.', ['@link' => $link->toString()])); } @@ -94,11 +94,11 @@ class DownloadDocumentAction extends ViewsBulkOperationsActionBase { // FIXME: filename. $destination = $wrapper . '://document.pdf'; - $fileobj = file_save_data(file_get_contents($fileUri), $destination); + $fileobj = \Drupal::service('file.repository')->writeData(file_get_contents($fileUri), $destination); $fileobj->setTemporary(); $fileobj->save(); - $file_url = Url::fromUri(file_create_url($fileobj->getFileUri())); + $file_url = \Drupal::service('file_url_generator')->generate($fileobj->getFileUri()); $link = Link::fromTextAndUrl($this->t('Click here'), $file_url); $this->messenger()->addMessage($this->t('Document created. @link to download.', ['@link' => $link->toString()])); } diff --git a/src/Plugin/Action/DownloadSingleDocumentAction.php b/src/Plugin/Action/DownloadSingleDocumentAction.php index 507cc8ad87ae2cd989579033c1f316cdf5311cae..7d724d5c86aedda57554f42bca691a4c2245e534 100644 --- a/src/Plugin/Action/DownloadSingleDocumentAction.php +++ b/src/Plugin/Action/DownloadSingleDocumentAction.php @@ -94,7 +94,7 @@ class DownloadSingleDocumentAction extends ViewsBulkOperationsActionBase { if (count($this->context['sandbox']['results']) > 1) { $destination = $wrapper . '://documents.zip'; - $archive_file = file_save_data('', $destination); + $archive_file = \Drupal::service('file.repository')->writeData('', $destination); $archive_file->setTemporary(); $archive_file->save(); @@ -109,7 +109,7 @@ class DownloadSingleDocumentAction extends ViewsBulkOperationsActionBase { $file_number++; } - $file_url = Url::fromUri(file_create_url($archive_file->getFileUri())); + $file_url = \Drupal::service('file_url_generator')->generate($archive_file->getFileUri()); $link = Link::fromTextAndUrl($this->t('Click here'), $file_url); $this->messenger()->addMessage($this->t('Document archive created. @link to download.', ['@link' => $link->toString()])); } @@ -119,11 +119,11 @@ class DownloadSingleDocumentAction extends ViewsBulkOperationsActionBase { // FIXME: filename. $destination = $wrapper . '://document.pdf'; - $fileobj = file_save_data(file_get_contents($fileUri), $destination); + $fileobj = \Drupal::service('file.repository')->writeData(file_get_contents($fileUri), $destination); $fileobj->setTemporary(); $fileobj->save(); - $file_url = Url::fromUri(file_create_url($fileobj->getFileUri())); + $file_url = \Drupal::service('file_url_generator')->generate($fileobj->getFileUri()); $link = Link::fromTextAndUrl($this->t('Click here'), $file_url); $this->messenger()->addMessage($this->t('Document created. @link to download.', ['@link' => $link->toString()])); } diff --git a/src/TwigExtension/MailTemplateTwigExtension.php b/src/TwigExtension/MailTemplateTwigExtension.php index 8daedb4056831a282ac2f703d1305851939755ac..91ace2e541b851c9285bc7303ebad65fc2ae80af 100644 --- a/src/TwigExtension/MailTemplateTwigExtension.php +++ b/src/TwigExtension/MailTemplateTwigExtension.php @@ -2,10 +2,12 @@ namespace Drupal\mail_template\TwigExtension; +use Twig\Extension\AbstractExtension; +use Twig\TwigFunction; /** * Provides TwigExtension for the MailTemplate module. */ -class MailTemplateTwigExtension extends \Twig_Extension { +class MailTemplateTwigExtension extends AbstractExtension { /** * {@inheritdoc} @@ -40,7 +42,7 @@ class MailTemplateTwigExtension extends \Twig_Extension { */ public function getFunctions() { return [ - new \Twig_SimpleFunction('getPasswordReset', [$this, 'getPasswordReset'], []), + new TwigFunction('getPasswordReset', [$this, 'getPasswordReset'], []), ]; }