Skip to content

Commit

Permalink
Merge pull request #102 from openeuropa/EWPP-1912
Browse files Browse the repository at this point in the history
EWPP-1912: Update to PHP8 and Composer v2.
  • Loading branch information
hernani authored Feb 7, 2022
2 parents 6637c9e + e57f979 commit c93eb92
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 82 deletions.
17 changes: 11 additions & 6 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ services:
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
environment: &web-environment
- DOCUMENT_ROOT=/test/oe_editorial
- COMPOSERVER=--2
- POETRY_IDENTIFIER_SEQUENCE=NEXT_EUROPA_COUNTER
- POETRY_SERVICE_ENDPOINT=http://web:8080/build/poetry-mock/wsdl
- POETRY_SERVICE_USERNAME=admin
Expand All @@ -41,30 +42,33 @@ services:
- NODE_MAX_SESSION=5

pipeline:
composer-install:
composer-install-highest:
group: prepare
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
volumes:
- /cache/${DRONE_REPO_NAME}:/cache
commands:
- composer install --ansi --no-suggest --no-progress
- composer self-update --2
- composer install --ansi --no-progress
when:
matrix:
COMPOSER_BOUNDARY: highest

composer-update-lowest:
group: post-prepare
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
volumes:
- /cache/${DRONE_REPO_NAME}:/cache
commands:
# @todo remove "composer install" step once the following issue is fixed.
# @link https://webgate.ec.europa.eu/CITnet/jira/browse/OPENEUROPA-1234
- composer update --prefer-lowest --prefer-stable --ansi --no-suggest --no-progress --no-interaction
- composer update --prefer-lowest --prefer-stable --ansi --no-progress --no-interaction
when:
matrix:
COMPOSER_BOUNDARY: lowest

site-install:
image: registry.fpfis.eu/fpfis/httpd-php:${PHP_VERSION}-ci
commands:
- while ! mysqladmin ping -h mysql --silent; do sleep 1; done
- ./vendor/bin/run drupal:site-install

grumphp:
Expand Down Expand Up @@ -99,4 +103,5 @@ matrix:
- lowest
- highest
PHP_VERSION:
- 7.3
- 7.4
- 8.0
50 changes: 35 additions & 15 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,35 @@
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=7.3",
"drupal/core": "^8.9 || ^9.1"
"php": ">=7.4",
"drupal/core": "^9.2"
},
"require-dev": {
"behat/behat": "^3.10",
"behat/mink-extension": "^2.3.1",
"composer/installers": "^1.5",
"drupal/core-composer-scaffold": "^8.9 || ^9.1",
"drupal/address": "^1.8",
"drupal/config_devel": "^1.2",
"drupal/content_lock": "^2.2",
"drupal/core-composer-scaffold": "^9.2",
"drupal/core-dev": "^9.2",
"drupal/ctools": "^3.7",
"drupal/drupal-extension": "^4.0",
"drupal/entity_version": "^1.0-beta8",
"drupal/address": "^1.8",
"openeuropa/oe_paragraphs": "^1.10",
"drupal/token": "^1.10",
"drush/drush": "^10.3",
"ec-europa/oe-poetry-client": "dev-master",
"ec-europa/oe-poetry-client": "^0.6",
"egulias/email-validator": "^2.1.22 || ^3.0",
"instaclick/php-webdriver": "^1.4.7",
"nikic/php-parser": "^3.1.5 || ^4",
"nikic/php-parser": "^4.12.0",
"openeuropa/behat-transformation-context": "~0.1",
"openeuropa/code-review": "^1.7",
"openeuropa/drupal-core-require-dev": "^8.9 || ^9.1",
"openeuropa/oe_multilingual": "^1.5",
"openeuropa/oe_translation": "dev-master",
"openeuropa/task-runner-drupal-project-symlink": "^1.0",
"phpspec/prophecy-phpunit": "^1 || ^2"
"openeuropa/code-review": "^2.0",
"openeuropa/oe_multilingual": "^1.10",
"openeuropa/oe_paragraphs": "^1.10",
"openeuropa/oe_translation": "^0.17",
"openeuropa/task-runner-drupal-project-symlink": "^1.0-beta5",
"phpspec/prophecy-phpunit": "^2",
"symfony/dom-crawler": "^4.4.12"
},
"scripts": {
"post-install-cmd": "./vendor/bin/run drupal:site-setup",
Expand Down Expand Up @@ -71,9 +77,23 @@
"locations": {
"web-root": "./build"
}
}
},
"_readme": [
"Explicit minimum version requirement of drupal/ctools module due to D9.2 compatability.",
"Explicit requirement for egulias/email-validator due to https://www.drupal.org/project/drupal/issues/3061074#comment-14300579. It can be removed when Drupal core 9.2 support is droppped.",
"Explicit requirement of drupal/token module due to PHP7.4 compatbility.",
"Explicit minimum version requirement of behat library due to PHP compatibility.",
"Explicit minimum version requirement for symfony/dom-crawler due to its lower versions using the deprecated function libxml_disable_entity_loader() in PHP8."
]
},
"config": {
"sort-packages": true
"sort-packages": true,
"allow-plugins": {
"composer/installers": true,
"drupal/core-composer-scaffold": true,
"cweagans/composer-patches": true,
"dealerdirect/phpcodesniffer-composer-installer": true,
"phpro/grumphp": true
}
}
}
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
web:
image: fpfis/httpd-php-dev:7.3
image: fpfis/httpd-php-dev:8.0
working_dir: /var/www/html
ports:
- 8080:8080
Expand All @@ -10,6 +10,7 @@ services:
- .:/var/www/html # Non Mac users.
# - nfsmount:/var/www/html # Mac Users with the nfsmount volume.
environment:
COMPOSERVER: "--2"
XDEBUG_CONFIG: "client_host=172.17.0.1" # Non-Mac users.
# XDEBUG_CONFIG: "client_host=host.docker.internal" # Mac users.
XDEBUG_MODE: "develop, debug"
Expand Down
19 changes: 15 additions & 4 deletions grumphp.yml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
imports:
- { resource: vendor/openeuropa/code-review/dist/drupal-conventions.yml }
grumphp:
extensions:
- OpenEuropa\CodeReview\ExtraTasksExtension
git_hook_variables:
EXEC_GRUMPHP_COMMAND: 'docker-compose exec -T web'
parameters:
tasks.phpcs.ignore_patterns:
- vendor/
Expand All @@ -14,9 +19,15 @@ parameters:

extra_tasks:
phpparser:
ignore_patterns: "%tasks.phpcs.ignore_patterns%"
ignore_patterns:
- vendor/
- node_modules/
- build/
visitors:
declare_strict_types: ~
triggered_by: "%tasks.phpcs.triggered_by%"
extensions:
- OpenEuropa\CodeReview\ExtraTasksExtension
triggered_by:
- php
- module
- inc
- theme
- install
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Content Lock
description: Lock content to prevent concurrent editing.
package: OpenEuropa
type: module
core_version_requirement: ^8.9 || ^9.1
core_version_requirement: ^9.2

dependencies:
- content_lock:content_lock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow Translation Poetry
description: Integrates the editorial workflow with OE Translation Poetry
package: OpenEuropa
type: module
core_version_requirement: ^8.9 || ^9.1
core_version_requirement: ^9.2

dependencies:
- oe_editorial_corporate_workflow_translation:oe_editorial_corporate_workflow_translation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow Translation
description: Integrates the editorial workflow with OE Translation
package: OpenEuropa
type: module
core_version_requirement: ^8.9 || ^9.1
core_version_requirement: ^9.2

dependencies:
- oe_editorial_corporate_workflow:oe_editorial_corporate_workflow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow Translation Test
description: Test module for the OpenEuropa Editorial Corporate Workflow Translation
package: Testing
type: module
core_version_requirement: ^8.9 || ^9.1
core_version_requirement: ^9.2

dependencies:
- oe_editorial_workflow_demo:oe_editorial_workflow_demo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Drupal\KernelTests\KernelTestBase;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\node\Entity\NodeType;
use Drupal\workflows\Entity\Workflow;

/**
* Testing custom translation-related logic.
Expand Down Expand Up @@ -64,10 +65,9 @@ protected function setUp() {
$this->container->get('oe_editorial_corporate_workflow.workflow_installer')->installWorkflow($node_type->id());

// Add the workflow to the test entity as well.
$config = $this->config('workflows.workflow.oe_corporate_workflow');
$config_value = $config->get('type_settings.entity_types.entity_test_mulrev');
$config_value[] = 'entity_test_mulrev';
$config->set('type_settings.entity_types.entity_test_mulrev', $config_value)->save();
$workflow = Workflow::load('oe_corporate_workflow');
$workflow->getTypePlugin()->addEntityTypeAndBundle('entity_test_mulrev', 'entity_test_mulrev');
$workflow->save();

ConfigurableLanguage::create(['id' => 'fr'])->save();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Corporate Workflow
description: Editorial corporate workflow feature for the OpenEuropa project.
package: OpenEuropa
type: module
core_version_requirement: ^8.9 || ^9.1
core_version_requirement: ^9.2

dependencies:
- content_moderation:content_moderation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
oe_editorial_corporate_workflow.workflow_installer:
class: Drupal\oe_editorial_corporate_workflow\CorporateWorkflowInstaller
arguments: ['@config.factory', '@entity_type.manager']
arguments: ['@entity_type.manager']
oe_editorial_corporate_workflow.shortcut_transition_handler:
class: Drupal\oe_editorial_corporate_workflow\Services\ShortcutRevisionHandler
arguments: ['@content_moderation.moderation_information', '@current_user', '@entity_type.manager', '@datetime.time']
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

namespace Drupal\oe_editorial_corporate_workflow;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\user\RoleInterface;

Expand All @@ -14,11 +13,11 @@
class CorporateWorkflowInstaller {

/**
* The config factory.
* The corporate editorial workflow.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
* @var \Drupal\workflows\WorkflowInterface
*/
protected $configFactory;
protected $workflow;

/**
* The entity type manager.
Expand All @@ -30,14 +29,12 @@ class CorporateWorkflowInstaller {
/**
* CorporateWorkflowInstaller constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $configFactory
* The config factory.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
*/
public function __construct(ConfigFactoryInterface $configFactory, EntityTypeManagerInterface $entityTypeManager) {
$this->configFactory = $configFactory;
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->entityTypeManager = $entityTypeManager;
$this->workflow = $this->entityTypeManager->getStorage('workflow')->load('oe_corporate_workflow');
}

/**
Expand All @@ -47,10 +44,8 @@ public function __construct(ConfigFactoryInterface $configFactory, EntityTypeMan
* The content type to enable the workflow on.
*/
public function installWorkflow(string $content_type): void {
$config = $this->configFactory->getEditable('workflows.workflow.oe_corporate_workflow');
$config_value = $config->get('type_settings.entity_types.node');
$config_value[] = $content_type;
$config->set('type_settings.entity_types.node', $config_value)->save();
$this->workflow->getTypePlugin()->addEntityTypeAndBundle('node', $content_type);
$this->workflow->save();
$this->handlePermissions('grant', $content_type);
}

Expand All @@ -61,29 +56,10 @@ public function installWorkflow(string $content_type): void {
* The content type to uninstall the workflow from.
*/
public function uninstallWorkflow(string $content_type): void {
$config = $this->configFactory->getEditable('workflows.workflow.oe_corporate_workflow');
$config_values = $config->get('type_settings.entity_types.node');
if (!$config_values) {
$this->handlePermissions('revoke', $content_type);
return;
if ($this->workflow->getTypePlugin()->appliesToEntityTypeAndBundle('node', $content_type)) {
$this->workflow->getTypePlugin()->removeEntityTypeAndBundle('node', $content_type);
$this->workflow->save();
}

$search = array_search($content_type, $config_values);
if ($search === FALSE) {
$this->handlePermissions('revoke', $content_type);
return;
}

unset($config_values[$search]);

if (empty($config_values)) {
// We save without any entity types on the workflow.
$config->set('type_settings.entity_types', [])->save();
$this->handlePermissions('revoke', $content_type);
return;
}

$config->set('type_settings.entity_types.node', $config_values)->save();
$this->handlePermissions('revoke', $content_type);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait CorporateWorkflowTrait {
* The entity type manager.
*/
protected function getEntityTypeManager(): EntityTypeManagerInterface {
return isset($this->entityTypeManager) ? $this->entityTypeManager : \Drupal::entityTypeManager();
return $this->entityTypeManager ?? \Drupal::entityTypeManager();
}

/**
Expand Down Expand Up @@ -49,7 +49,7 @@ protected function moderateNode(NodeInterface $node, string $target_state): Node

$pos = array_search($current_state, $states);
foreach (array_slice($states, $pos + 1) as $new_state) {
$node = isset($revision) ? $revision : $node;
$node = $revision ?? $node;
$revision = $this->getEntityTypeManager()->getStorage('node')->createRevision($node);
$revision->set('moderation_state', $new_state);
$revision->save();
Expand All @@ -58,7 +58,7 @@ protected function moderateNode(NodeInterface $node, string $target_state): Node
}
}

return isset($revision) ? $revision : $node;
return $revision ?? $node;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: OpenEuropa Editorial Entity Version
description: Editorial entity version brings the entity_version module configured for workflows.
package: OpenEuropa
type: module
core_version_requirement: ^8.9 || ^9.1
core_version_requirement: ^9.2

dependencies:
- entity_version_workflows:entity_version_workflows
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function oe_editorial_entity_version_install($is_syncing): void {
}

// Get the bundles the workflow is associated with.
$bundles = isset($corporate_workflow->get('type_settings')['entity_types']['node']) ? $corporate_workflow->get('type_settings')['entity_types']['node'] : [];
$bundles = $corporate_workflow->get('type_settings')['entity_types']['node'] ?? [];
if (!$bundles) {
return;
}
Expand Down
Loading

0 comments on commit c93eb92

Please sign in to comment.