Skip to content
Snippets Groups Projects
Commit f36b0805 authored by Sascha Grossenbacher's avatar Sascha Grossenbacher
Browse files

Issue #3483218 by berdir: Drupal 11 compatibility

parent 960fd172
No related branches found
No related tags found
1 merge request!3Drupal 11 compatibility
Pipeline #322171 passed with warnings
Showing
with 15 additions and 253 deletions
......@@ -48,52 +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:
_PHPUNIT_CONCURRENT: 1
OPT_IN_TEST_PREVIOUS_MAJOR: 1
OPT_IN_TEST_PREVIOUS_MINOR: 1
......@@ -5,7 +5,6 @@
"license": "GPL-2.0+",
"require": {
"gathercontent/client": "^1.2",
"drupal/core": "^9.2 || ^10",
"drupal/migrate_tools": "^4 || ^5 || ^6"
},
"require-dev": {
......
name: Content Workflow (by Bynder)
description: 'Imports items from Content Workflow (by Bynder) to your Drupal CMS'
package: Content Workflow (Bynder)
core_version_requirement: ^9.2 || ^10
core_version_requirement: ^9.2 || ^10 || ^11
type: module
configure: content_workflow_bynder.admin_content_workflow_bynder
dependencies:
......
......@@ -9,7 +9,7 @@ use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\content_workflow_bynder\Entity\MappingInterface;
use Drupal\content_workflow_bynder\Plugin\migrate\source\contentWorkflowBynderMigrateSource;
use Drupal\content_workflow_bynder\Plugin\migrate\source\ContentWorkflowBynderMigrateSource;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\content_workflow_bynder\MigrateExecutable;
use Drupal\content_workflow_bynder\MigrateMessageCapture;
......@@ -73,9 +73,9 @@ function content_workflow_bynder_import_process($cwb_ids, array $import_options,
// limit the source directly as this is more efficient and sources
// may be multiplied to support repeatable components.
$source = $migration->getSourcePlugin();
if (!$source instanceof contentWorkflowBynderMigrateSource) {
$context['results']['messages'][] = (string) t('Migration source must be an instance of contentWorkflowBynderMigrateSource');
\Drupal::logger('content_workflow_bynder')->error('Migration source must be an instance of contentWorkflowBynderMigrateSource');
if (!$source instanceof ContentWorkflowBynderMigrateSource) {
$context['results']['messages'][] = (string) t('Migration source must be an instance of ContentWorkflowBynderMigrateSource');
\Drupal::logger('content_workflow_bynder')->error('Migration source must be an instance of ContentWorkflowBynderMigrateSource');
}
$source->setItemIds($cwb_ids);
......
name: Content Workflow UI (by Bynder)
description: 'Content Workflow (by Bynder) User Interface module'
package: Content Workflow (Bynder)
core_version_requirement: ^9.2 || ^10
core_version_requirement: ^9.2 || ^10 || ^11
type: module
dependencies:
- drupal:content_workflow_bynder
......
......@@ -85,6 +85,7 @@ class MappingListBuilder extends ConfigEntityListBuilder {
->getQuery();
$query_string = $this->request->query;
$headers = $this->buildHeader();
$entity_query->accessCheck(TRUE);
$entity_query->pager(100);
if ($query_string->has('order')) {
......
<?php
namespace Drupal\content_workflow_bynder_ui\Plugin\views\field;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\node\Plugin\views\field\Path;
use Drupal\views\ResultRow;
/**
* A handler to provide a field that is completely custom by the administrator.
*
* @ingroup views_field_handlers
*
* @ViewsField("content_link")
*/
class ContentLink extends Path {
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$nid = $this->getValue($values, 'nid');
if (is_numeric($nid)) {
$url = Url::fromRoute('entity.node.canonical', ['node' => $nid], ['absolute' => $this->options['absolute']]);
return Link::fromTextAndUrl($this->t('Open'), $url)->toRenderable();
}
else {
return $this->t('Not available');
}
}
}
<?php
namespace Drupal\content_workflow_bynder_ui\Plugin\views\field;
use Drupal\Core\Link;
use Drupal\Core\Url;
use Drupal\node\Plugin\views\field\Path;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
/**
* A handler to provide a field that is completely custom by the administrator.
*
* @ingroup views_field_handlers
*
* @ViewsField("content_workflow_bynder_content_link")
*/
class ContentWorkflowBynderContentLink extends Path {
/**
* {@inheritdoc}
*/
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this->additional_fields['cwb_id'] = 'cwb_id';
}
/**
* {@inheritdoc}
*/
public function render(ResultRow $values) {
$cwb_id = $this->getValue($values, 'cwb_id');
if (is_numeric($cwb_id)) {
$base_url = 'https://' . \Drupal::config('content_workflow_bynder.settings')
->get('content_workflow_bynder_urlkey') . '.content_workflow_bynder.com/item/';
$url = Url::fromUri($base_url . $cwb_id);
return Link::fromTextAndUrl($this->t('Open'), $url)->toRenderable();
}
else {
return $this->t('Not available');
}
}
}
<?php
/**
* @file
* Content Workflow Upload drush command.
*/
use Drupal\content_workflow_bynder\Entity\Operation;
use Drupal\content_workflow_bynder\Entity\OperationItem;
use Drupal\node\Entity\Node;
use Drush\Log\LogLevel;
/**
* Implements hook_drush_command().
*/
function content_workflow_bynder_upload_drush_command() {
$commands = [];
$commands['content_workflow_bynder-upload'] = [
'aliases' => ['cwb-u'],
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
'description' => dt('Upload changes to Content Workflow (Bynder)'),
'engines' => [
'outputformat' => [
'default' => 'table',
'pipe-format' => 'json',
'output-data-type' => 'format-table',
'field-labels' => [
'id' => dt('ID'),
'item_name' => dt('Item name'),
'node_status' => dt('Node status'),
'upload_status' => dt('Upload status'),
],
],
],
];
return $commands;
}
/**
* Implements drush_COMMAND().
*/
function drush_content_workflow_bynder_upload() {
$operation = Operation::create([
'type' => 'upload',
]);
$operation->save();
$node_ids = \Drupal::entityQuery('node')
->accessCheck(TRUE)
->condition('cwb_id', '', '<>')
->condition('cwb_mapping_id', '', '<>')
->execute();
$nodes = Node::loadMultiple($node_ids);
$operations = [];
foreach ($nodes as $node) {
$operations[] = [
'content_workflow_bynder_upload_process',
[
$node,
$operation->uuid(),
],
];
}
$batch = [
'title' => t('Uploading content ...'),
'operations' => $operations,
'finished' => 'content_workflow_bynder_drush_upload_finished',
'init_message' => t('Upload is starting ...'),
'progress_message' => t('Processed @current out of @total.'),
'error_message' => t('An error occurred during processing'),
'progressive' => TRUE,
];
batch_set($batch);
drush_backend_batch_process();
$mappings = [];
$operation_item_ids = \Drupal::entityQuery('content_workflow_bynder_operation_item')
->accessCheck(TRUE)
->condition('operation_uuid', $operation->uuid())
->execute();
if (!empty($operation_item_ids)) {
$operation_items = OperationItem::loadMultiple($operation_item_ids);
/** @var \Drupal\content_workflow_bynder\Entity\OperationItem $operation_item */
foreach ($operation_items as $operation_item) {
$mappings[$operation_item->id()] = [
'id' => $operation_item->id(),
'item_name' => $operation_item->item_name->value,
'node_status' => $operation_item->getItemStatus(),
'upload_status' => $operation_item->getStatus(),
];
}
}
return $mappings;
}
/**
* Batch process "finished" callback.
*/
function content_workflow_bynder_drush_upload_finished($success, $results, $operations) {
if ($success) {
drush_log(t('Upload finished'), LogLevel::OK);
}
else {
drush_set_error('content_workflow_bynder_upload_failed', t('Upload failed'));
}
}
name: Content Workflow (by Bynder) Upload
description: 'Content Workflow (by Bynder) Upload module'
package: Content Workflow (Bynder)
core_version_requirement: ^9.2 || ^10
core_version_requirement: ^9.2 || ^10 || ^11
type: module
dependencies:
- drupal:content_workflow_bynder
name: Content Workflow (by Bynder) Upload UI
description: 'Content Workflow (by Bynder) Upload User Interface module'
package: Content Workflow (Bynder)
core_version_requirement: ^9.2 || ^10
core_version_requirement: ^9.2 || ^10 || ^11
type: module
dependencies:
- drupal:content_workflow_bynder
......
......@@ -2,7 +2,6 @@
namespace Drupal\content_workflow_bynder;
use function GuzzleHttp\json_decode;
use GatherContent\GatherContentClient;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Pool;
......
......@@ -3,7 +3,7 @@
namespace Drupal\content_workflow_bynder;
use Drupal\content_workflow_bynder\Import\MenuCreator;
use Drupal\content_workflow_bynder\Plugin\migrate\source\contentWorkflowBynderMigrateSource;
use Drupal\content_workflow_bynder\Plugin\migrate\source\ContentWorkflowBynderMigrateSource;
use Drupal\migrate\Event\MigrateImportEvent;
use Drupal\migrate_tools\MigrateExecutable as MigrateExecutableBase;
use Drupal\migrate\MigrateMessageInterface;
......@@ -122,7 +122,7 @@ class MigrateExecutable extends MigrateExecutableBase {
$pluginDefinition = $migration->getPluginDefinition();
$source = $migration->getSourcePlugin();
if (!$source instanceof contentWorkflowBynderMigrateSource) {
if (!$source instanceof ContentWorkflowBynderMigrateSource) {
return;
}
......
......@@ -2,7 +2,6 @@ name: 'CWB Test'
description: 'Tests of import functionality.'
package: 'Testing'
type: module
core_version_requirement: ^9.2 || ^10
dependencies:
- content_workflow_bynder:content_workflow_bynder
- paragraph:paragraph
......
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