Popravilo nastavitve stanja moderacije. #59

Merged
g1smo merged 11 commits from urednikovanje-lio into master 2024-04-11 21:56:08 +02:00
33 changed files with 228 additions and 201 deletions

2
.gitignore vendored
View File

@ -7,6 +7,8 @@
# Ignore configuration files that may contain sensitive information # Ignore configuration files that may contain sensitive information
/web/sites/*/settings.local.php /web/sites/*/settings.local.php
# Ignore ddev settings
/web/sites/*/settings.ddev.php
# Ignore paths that may contain user-generated content # Ignore paths that may contain user-generated content
/web/sites/*/files /web/sites/*/files

View File

@ -24,6 +24,10 @@ Sajt je dostopen preko naslova: https://yufu-manifest.ddev.site/
Lahko pa napišemo tudi `ddev launch` Lahko pa napišemo tudi `ddev launch`
v `web/sites/default/settings.local.php` dodamo vrstico, ki vključi services nastavitve, ki omogočijo CORS:
`$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/default/yufu.services.yml';`
### Postavitev (vuejs) "prednjegadela" ### Postavitev (vuejs) "prednjegadela"
Najprej gremo v podfolder `nuxt` in namestimo odvisne javascript pakete: Najprej gremo v podfolder `nuxt` in namestimo odvisne javascript pakete:

View File

@ -20,11 +20,11 @@
"drupal/cer": "^5.0@beta", "drupal/cer": "^5.0@beta",
"drupal/config_ignore": "^3.1", "drupal/config_ignore": "^3.1",
"drupal/content_as_config": "^1.0", "drupal/content_as_config": "^1.0",
"drupal/content_moderation_notifications": "^3.6",
"drupal/core-composer-scaffold": "^10.0", "drupal/core-composer-scaffold": "^10.0",
"drupal/core-project-message": "^10.0", "drupal/core-project-message": "^10.0",
"drupal/core-recommended": "^10.0",
"drupal/diff": "^1.1",
"drupal/core-recommended": "^10.2.4", "drupal/core-recommended": "^10.2.4",
"drupal/diff": "^1.1",
"drupal/gin": "^3.0@RC", "drupal/gin": "^3.0@RC",
"drupal/gin_toolbar": "^1.0@RC", "drupal/gin_toolbar": "^1.0@RC",
"drupal/jsonapi_menu_items": "^1.2", "drupal/jsonapi_menu_items": "^1.2",

120
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "1e4c156c402a50481a77ff4b24a87020", "content-hash": "39f3d592b41324eb32edb9388cc9682b",
"packages": [ "packages": [
{ {
"name": "asm89/stack-cors", "name": "asm89/stack-cors",
@ -1446,6 +1446,58 @@
"issues": "https://www.drupal.org/project/issues/content_as_config" "issues": "https://www.drupal.org/project/issues/content_as_config"
} }
}, },
{
"name": "drupal/content_moderation_notifications",
"version": "3.6.0",
"source": {
"type": "git",
"url": "https://git.drupalcode.org/project/content_moderation_notifications.git",
"reference": "8.x-3.6"
},
"dist": {
"type": "zip",
"url": "https://ftp.drupal.org/files/projects/content_moderation_notifications-8.x-3.6.zip",
"reference": "8.x-3.6",
"shasum": "f475721b95de8d0520053d3101c35c48ea22f61c"
},
"require": {
"drupal/core": "^9 || ^10"
},
"require-dev": {
"drupal/token": "^1.0"
},
"type": "drupal-module",
"extra": {
"drupal": {
"version": "8.x-3.6",
"datestamp": "1695836640",
"security-coverage": {
"status": "covered",
"message": "Covered by Drupal's security advisory policy"
}
}
},
"notification-url": "https://packages.drupal.org/8/downloads",
"license": [
"GPL-2.0+"
],
"authors": [
{
"name": "jhedstrom",
"homepage": "https://www.drupal.org/user/208732"
},
{
"name": "Rob Holmes",
"homepage": "https://www.drupal.org/user/1774034"
}
],
"description": "Manage notifications for content moderation transitions.",
"homepage": "https://www.drupal.org/project/content_moderation_notifications",
"support": {
"source": "https://git.drupalcode.org/project/content_moderation_notifications",
"issues": "https://www.drupal.org/project/issues/content_moderation_notifications"
}
},
{ {
"name": "drupal/core", "name": "drupal/core",
"version": "10.2.4", "version": "10.2.4",
@ -2567,72 +2619,6 @@
], ],
"time": "2023-10-06T06:47:41+00:00" "time": "2023-10-06T06:47:41+00:00"
}, },
{
"name": "enlightn/security-checker",
"version": "v1.11.0",
"source": {
"type": "git",
"url": "https://github.com/enlightn/security-checker.git",
"reference": "68df5c7256c84b428bf8fcff0d249de06ce362d2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/enlightn/security-checker/zipball/68df5c7256c84b428bf8fcff0d249de06ce362d2",
"reference": "68df5c7256c84b428bf8fcff0d249de06ce362d2",
"shasum": ""
},
"require": {
"ext-json": "*",
"guzzlehttp/guzzle": "^6.3|^7.0",
"php": ">=5.6",
"symfony/console": "^3.4|^4|^5|^6|^7",
"symfony/finder": "^3|^4|^5|^6|^7",
"symfony/process": "^3.4|^4|^5|^6|^7",
"symfony/yaml": "^3.4|^4|^5|^6|^7"
},
"require-dev": {
"ext-zip": "*",
"friendsofphp/php-cs-fixer": "^2.18|^3.0",
"phpunit/phpunit": "^5.5|^6|^7|^8|^9"
},
"bin": [
"security-checker"
],
"type": "library",
"autoload": {
"psr-4": {
"Enlightn\\SecurityChecker\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Paras Malhotra",
"email": "paras@laravel-enlightn.com"
},
{
"name": "Miguel Piedrafita",
"email": "soy@miguelpiedrafita.com"
}
],
"description": "A PHP dependency vulnerabilities scanner based on the Security Advisories Database.",
"keywords": [
"package",
"php",
"scanner",
"security",
"security advisories",
"vulnerability scanner"
],
"support": {
"issues": "https://github.com/enlightn/security-checker/issues",
"source": "https://github.com/enlightn/security-checker/tree/v1.11.0"
},
"time": "2023-11-17T07:53:29+00:00"
},
{ {
"name": "ezyang/htmlpurifier", "name": "ezyang/htmlpurifier",
"version": "v4.17.0", "version": "v4.17.0",

View File

@ -0,0 +1,19 @@
uuid: ef0653bf-ad20-4659-bb94-9273264eb15b
langcode: en
status: true
dependencies: { }
id: nov_osnutek
workflow: concept_workflow
transitions:
create_new_draft: create_new_draft
roles:
editor: editor
maska: maska
author: false
site_mail: false
emails: ''
subject: '[YUFU] New draft of [node:original:title]'
body:
value: "New draft pending moderation: [node:title] ([node:nid]) by [node:author:mail].\r\n\r\n[node:url]/revisions/view/[node:original:vid]/[node:vid]/visual_inline\r\n\r\n[node:body]"
format: plain_text
label: 'Nov osnutek'

View File

@ -0,0 +1,18 @@
uuid: c048753b-259e-4210-8e53-031ae5cbae0f
langcode: en
status: true
dependencies: { }
id: spremembe_sprejete
workflow: concept_workflow
transitions:
publish: publish
roles:
editor: editor
author: true
site_mail: false
emails: ''
subject: '[YUFU] Changes approved'
body:
value: 'Proposed changes to [node:title] ([node:url]) by [node:author:mail] were approved.'
format: plain_text
label: 'Spremembe sprejete'

View File

@ -14,6 +14,7 @@ module:
config_translation: 0 config_translation: 0
content_as_config: 0 content_as_config: 0
content_moderation: 0 content_moderation: 0
content_moderation_notifications: 0
contextual: 0 contextual: 0
datetime: 0 datetime: 0
dblog: 0 dblog: 0

View File

@ -0,0 +1,2 @@
settings:
label: 'RSS feed'

View File

@ -0,0 +1 @@
label: RSS

View File

@ -12,6 +12,7 @@ display:
name: name:
label: Autor label: Autor
status: status:
label: Status
settings: settings:
format_custom_true: Objavljeno format_custom_true: Objavljeno
changed: changed:
@ -25,6 +26,9 @@ display:
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
sort_asc_label: Uzlazno sort_asc_label: Uzlazno
sort_desc_label: Silazno sort_desc_label: Silazno
empty:
area_text_custom:
content: 'Na voljo ni nobene vsebine.'
filters: filters:
title: title:
expose: expose:
@ -33,6 +37,8 @@ display:
expose: expose:
label: 'Vrsta sadržaja' label: 'Vrsta sadržaja'
status: status:
expose:
label: Status
group_info: group_info:
group_items: group_items:
1: 1:

View File

@ -12,6 +12,7 @@ display:
uid: uid:
label: Autor label: Autor
status: status:
label: Status
settings: settings:
format_custom_true: Objavljeno format_custom_true: Objavljeno
changed: changed:

View File

@ -36,6 +36,7 @@ display:
delete_media: delete_media:
text: Ukloni text: Ukloni
widget: widget:
display_title: Widget
display_options: display_options:
arguments: arguments:
bundle: bundle:

View File

@ -7,18 +7,12 @@ display:
fields: fields:
title: title:
label: Naziv label: Naziv
separator: ', '
type: type:
label: 'Vrsta sadržaja' label: 'Vrsta sadržaja'
separator: ', '
name: name:
label: Autor label: Autor
separator: ', '
moderation_state:
separator: ', '
changed: changed:
label: Osvježeno label: Osvježeno
separator: ', '
operations: operations:
label: Operacije label: Operacije
exposed_form: exposed_form:

View File

@ -0,0 +1,2 @@
settings:
label: 'RSS feed'

View File

@ -0,0 +1 @@
label: RSS

View File

@ -15,10 +15,10 @@ display:
exposed_form: exposed_form:
options: options:
submit_button: Primjeni submit_button: Primjeni
reset_button_label: Poništi reset_button_label: Ponastavi
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
sort_asc_label: Uzlazno sort_asc_label: Naraščajoče
sort_desc_label: Silazno sort_desc_label: Padajoče
empty: empty:
area_text_custom: area_text_custom:
content: 'There are no custom blocks available.' content: 'There are no custom blocks available.'

View File

@ -27,10 +27,10 @@ display:
exposed_form: exposed_form:
options: options:
submit_button: Počisti submit_button: Počisti
reset_button_label: Poništi reset_button_label: Ponastavi
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
sort_asc_label: Uzlazno sort_asc_label: Naraščajoče
sort_desc_label: Silazno sort_desc_label: Padajoče
empty: empty:
area_text_custom: area_text_custom:
content: 'Nema dostupnih komentara.' content: 'Nema dostupnih komentara.'

View File

@ -12,6 +12,7 @@ display:
uid: uid:
label: Avtor label: Avtor
status: status:
label: Status
settings: settings:
format_custom_true: Objavljeno format_custom_true: Objavljeno
changed: changed:
@ -21,10 +22,10 @@ display:
exposed_form: exposed_form:
options: options:
submit_button: Počisti submit_button: Počisti
reset_button_label: Poništi reset_button_label: Ponastavi
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
sort_asc_label: Uzlazno sort_asc_label: Naraščajoče
sort_desc_label: Silazno sort_desc_label: Padajoče
filters: filters:
bundle: bundle:
expose: expose:

View File

@ -8,10 +8,10 @@ display:
action_title: Akcija action_title: Akcija
exposed_form: exposed_form:
options: options:
reset_button_label: Poništi reset_button_label: Ponastavi
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
sort_asc_label: Uzlazno sort_asc_label: Naraščajoče
sort_desc_label: Silazno sort_desc_label: Padajoče
filters: filters:
status: status:
group_info: group_info:
@ -36,6 +36,7 @@ display:
delete_media: delete_media:
text: Ukloni text: Ukloni
widget: widget:
display_title: Widget
display_options: display_options:
arguments: arguments:
bundle: bundle:

View File

@ -7,18 +7,10 @@ display:
fields: fields:
title: title:
label: Naslov label: Naslov
separator: ', '
type:
label: 'Tip vsebin'
separator: ', '
name: name:
label: Avtor label: Avtor
separator: ', '
moderation_state:
separator: ', '
changed: changed:
label: Posodobljeno label: Posodobljeno
separator: ', '
operations: operations:
label: Operacije label: Operacije
exposed_form: exposed_form:
@ -32,9 +24,6 @@ display:
title: title:
expose: expose:
label: Naslov label: Naslov
type:
expose:
label: ''
langcode: langcode:
expose: expose:
label: Jezik label: Jezik

View File

@ -6,10 +6,10 @@ display:
exposed_form: exposed_form:
options: options:
submit_button: Primjeni submit_button: Primjeni
reset_button_label: Poništi reset_button_label: Ponastavi
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
sort_asc_label: Uzlazno sort_asc_label: Naraščajoče
sort_desc_label: Silazno sort_desc_label: Padajoče
arguments: arguments:
tid: tid:
exception: exception:

View File

@ -0,0 +1,2 @@
settings:
label: 'RSS feed'

View File

@ -0,0 +1 @@
label: RSS

View File

@ -12,6 +12,7 @@ display:
name: name:
label: Autor label: Autor
status: status:
label: Status
settings: settings:
format_custom_true: Objavljeno format_custom_true: Objavljeno
changed: changed:
@ -25,6 +26,9 @@ display:
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
sort_asc_label: Uzlazno sort_asc_label: Uzlazno
sort_desc_label: Silazno sort_desc_label: Silazno
empty:
area_text_custom:
content: 'Na voljo ni nobene vsebine.'
filters: filters:
title: title:
expose: expose:
@ -33,6 +37,8 @@ display:
expose: expose:
label: 'Vrsta sadržaja' label: 'Vrsta sadržaja'
status: status:
expose:
label: Status
group_info: group_info:
group_items: group_items:
1: 1:

View File

@ -12,6 +12,7 @@ display:
uid: uid:
label: Autor label: Autor
status: status:
label: Status
settings: settings:
format_custom_true: Objavljeno format_custom_true: Objavljeno
changed: changed:

View File

@ -36,6 +36,7 @@ display:
delete_media: delete_media:
text: Ukloni text: Ukloni
widget: widget:
display_title: Widget
display_options: display_options:
arguments: arguments:
bundle: bundle:

View File

@ -7,18 +7,12 @@ display:
fields: fields:
title: title:
label: Naziv label: Naziv
separator: ', '
type: type:
label: 'Vrsta sadržaja' label: 'Vrsta sadržaja'
separator: ', '
name: name:
label: Autor label: Autor
separator: ', '
moderation_state:
separator: ', '
changed: changed:
label: Osvježeno label: Osvježeno
separator: ', '
operations: operations:
label: Operacije label: Operacije
exposed_form: exposed_form:

View File

@ -371,11 +371,11 @@ display:
options: options:
submit_button: Počisti submit_button: Počisti
reset_button: true reset_button: true
reset_button_label: Poništi reset_button_label: Ponastavi
exposed_sorts_label: 'Rasporedi po' exposed_sorts_label: 'Rasporedi po'
expose_sort_order: true expose_sort_order: true
sort_asc_label: Uzlazno sort_asc_label: Naraščajoče
sort_desc_label: Silazno sort_desc_label: Padajoče
access: access:
type: perm type: perm
options: options:

View File

@ -57,39 +57,39 @@ function yufu_admin_mail($key, &$message, $params) {
/** /**
* Implements hook_ENTITY_TYPE_presave(). * Implements hook_ENTITY_TYPE_presave().
*/ */
function yufu_admin_node_presave(EntityInterface $entity) { // function yufu_admin_node_presave(EntityInterface $entity) {

Ostanek?

Ostanek?
if ($entity instanceOf NodeInterface && $entity->bundle() == 'concept') { // if ($entity instanceOf NodeInterface && $entity->bundle() == 'concept') {
// Get transition: concept_drafted, concept_approved, concept_rejected. // // Get transition: concept_drafted, concept_approved, concept_rejected.
if ($entity->isNew()) { // if ($entity->isNew()) {
$transition = 'concept_drafted'; // $transition = 'concept_drafted';
} // }
else { // else {
$transition = _yufu_admin_get_node_transition($entity); // $transition = _yufu_admin_get_node_transition($entity);
} // }
switch ($transition) { // switch ($transition) {
case 'stay_draft': // case 'stay_draft':
case 'concept_drafted': // case 'concept_drafted':
// Send email to editors. // // Send email to editors.
$params = _yufu_admin_concept_drafted_mail($entity); // $params = _yufu_admin_concept_drafted_mail($entity);
$result = _yufu_admin_send_email($transition, $params['to'], $params); // $result = _yufu_admin_send_email($transition, $params['to'], $params);
_yufu_admin_status_message($result['result'], $transition, $entity, $params['to']); // _yufu_admin_status_message($result['result'], $transition, $entity, $params['to']);
break; // break;
case 'concept_approved': // case 'concept_approved':
// Send email to revision creator (user). // // Send email to revision creator (user).
// @TODO Maybe notify other editors. // // @TODO Maybe notify other editors.
$params = _yufu_admin_concept_approved_get_message($entity); // $params = _yufu_admin_concept_approved_get_message($entity);
$result = _yufu_admin_send_email($transition, $params['to'], $params); // $result = _yufu_admin_send_email($transition, $params['to'], $params);
_yufu_admin_status_message($result['result'], $transition, $entity, $params['to']); // _yufu_admin_status_message($result['result'], $transition, $entity, $params['to']);
break; // break;
case 'concept_rejectd': // case 'concept_rejectd':
// Send email to revision creator (user). // // Send email to revision creator (user).
// This transition happens on revision delete. // // This transition happens on revision delete.
// Curently it is dead. // // Curently it is dead.
// @TODO https://git.kompot.si/yufu/manifest/issues/45 // // @TODO https://git.kompot.si/yufu/manifest/issues/45
break; // break;
} // }
} // }
} //}
/** /**
* Compare original node moderation state with current state. * Compare original node moderation state with current state.
@ -130,13 +130,13 @@ function _yufu_admin_concept_drafted_mail(NodeInterface $node) {
if ($node->isNew()) { if ($node->isNew()) {
$params['message'] = t('New concept created: @title - @url', [ $params['message'] = t('New concept created: @title - @url', [
'@title' => $node->getTitle(), '@title' => $node->getTitle(),
'@url' => !$node->isNew() ? $node?->toUrl()?->toString() : '', '@url' => '',
]); ]);
} }
else { else {
$params['message'] = t('New changes to concept proposed: @title - @url', [ $params['message'] = t('New changes to concept proposed: @title - @url', [
'@title' => $node->getTitle(), '@title' => $node->getTitle(),
'@url' => !$node->isNew() ? $node?->toUrl()?->toString() : '', '@url' => $node?->toUrl()?->toString(),
]); ]);
} }
$params['node_title'] = $node->getTitle(); $params['node_title'] = $node->getTitle();
@ -276,3 +276,15 @@ function _yufu_admin_get_all_pioneer_emails() {
// @TODO: Think it through if it is really needed. // @TODO: Think it through if it is really needed.
return []; return [];
} }

Ostanek?

Ostanek?
/**
* Invoke hook_content_moderation_notification_mail_data_alter().
*/
// function yufu_admin_content_moderation_notification_mail_data_alter(EntityInterface $entity, array &$data) {
// // Add an extra email address to the list.
// if ($entity instanceOf NodeInterface) {
// if ($email = _yufu_admin_get_pioneer_email($entity)) {
// $data['to'][] = $email;
// }
// }
// }

View File

@ -8,10 +8,10 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\TypedData\Exception\MissingDataException; use Drupal\Core\TypedData\Exception\MissingDataException;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
use Drupal\rest\Plugin\ResourceBase; use Drupal\rest\Plugin\ResourceBase;
use Drupal\rest\ResourceResponse;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
@ -100,7 +100,7 @@ class AddConcept extends ResourceBase {
* @param \Symfony\Component\HttpFoundation\Request; * @param \Symfony\Component\HttpFoundation\Request;
* Post request. * Post request.
* *
* @return \Drupal\rest\ResourceResponse * @return \Symfony\Component\HttpFoundation\JsonResponse
* Returns rest resource. * Returns rest resource.
*/ */
public function post(Request $request) { public function post(Request $request) {
@ -123,11 +123,15 @@ class AddConcept extends ResourceBase {
$concept->setRevisionUserId($uid); $concept->setRevisionUserId($uid);
$concept->set('title', $data['title']); $concept->set('title', $data['title']);
$concept->set('body', $data['text'] ?? $concept->body->value); $concept->set('body', $data['text'] ?? $concept->body->value);
if ($uid) {
$uids = $concept->get('uid')->getValue();
$uids[] = ['target_id' => $uid];
$concept->set('uid', array_reverse($uids));
}
$concept->isDefaultRevision(FALSE); $concept->isDefaultRevision(FALSE);
$concept->setRevisionLogMessage('New revision by concept endpoint.'); $concept->setRevisionLogMessage('New revision by concept endpoint.');
$concept->moderation_state->target_id = 'draft'; $concept->set('moderation_state', 'draft');
$concept->set('status', 0); $concept->set('status', 0);
$concept->setUnpublished();
$concept->save(); $concept->save();
$this->logger->notice('New concept @title revision @revid created by uid @uid.', [ $this->logger->notice('New concept @title revision @revid created by uid @uid.', [
'@title' => $concept->getTitle(), '@title' => $concept->getTitle(),
@ -163,7 +167,7 @@ class AddConcept extends ResourceBase {
'revision_uid' => $concept->getRevisionUserId(), 'revision_uid' => $concept->getRevisionUserId(),
'uid' => $concept->uid->target_id, 'uid' => $concept->uid->target_id,
]; ];
$response = new ResourceResponse($response_status); $response = new JsonResponse($response_status);
return $response; return $response;
} }
@ -182,7 +186,8 @@ class AddConcept extends ResourceBase {
return NULL; return NULL;
} }
$node_storage = $this->entityTypeManager->getStorage('node'); $node_storage = $this->entityTypeManager->getStorage('node');
if ($concept = end($node_storage->loadByProperties(['uuid' => $uuid]))) { $concepts = $node_storage->loadByProperties(['uuid' => $uuid]);
if ($concept = end($concepts)) {
return $concept; return $concept;
} }
return NULL; return NULL;

View File

@ -1,6 +1,28 @@
<?php <?php
use Drupal\Core\Entity\EntityInterface;
use Drupal\node\NodeInterface;
/** /**
* @file * @file
* Primary module hooks for Yufu Concept module. * Primary module hooks for Yufu Concept module.
*/ */
/**
* Implements hook_entity_update().
*/
function yufu_concept_node_presave(EntityInterface $entity) {
if ($entity instanceOf NodeInterface && $entity->bundle() == 'concept') {
$transition = \Drupal::service('content_moderation_notifications.notification_information')->getTransition($entity);
if ($transition->id() == 'publish') {
if ($user = $entity->uid->entity) {
if (!$user->status->value) {
$user->set('status', 1);
$user->addRole('editor');
$user->save();
}
}
}
}
}

View File

@ -1,50 +0,0 @@
<?php
$host = "db";
$port = 3306;
$driver = "mysql";
// If DDEV_PHP_VERSION is not set but IS_DDEV_PROJECT *is*, it means we're running (drush) on the host,
// so use the host-side bind port on docker IP
if (empty(getenv('DDEV_PHP_VERSION') && getenv('IS_DDEV_PROJECT') == 'true')) {
$host = "127.0.0.1";
$port = 32786;
}
$databases['default']['default'] = array(
'database' => "db",
'username' => "db",
'password' => "db",
'host' => $host,
'driver' => $driver,
'port' => $port,
'prefix' => "",
);
$settings['hash_salt'] = 'kShGqBypYstnMBJYmaRocqYLQcvBTMgvGbLQkdODVMavjRUyDhgBFcSAideqnFoM';
// This will prevent Drupal from setting read-only permissions on sites/default.
$settings['skip_permissions_hardening'] = TRUE;
// This will ensure the site can only be accessed through the intended host
// names. Additional host patterns can be added for custom configurations.
$settings['trusted_host_patterns'] = ['.*'];
// Don't use Symfony's APCLoader. ddev includes APCu; Composer's APCu loader has
// better performance.
$settings['class_loader_auto_detect'] = FALSE;
// Set $settings['config_sync_directory'] if not set in settings.php.
if (empty($settings['config_sync_directory'])) {
$settings['config_sync_directory'] = 'sites/default/files/sync';
}
// Override drupal/symfony_mailer default config to use Mailhog
$config['symfony_mailer.mailer_transport.sendmail']['plugin'] = 'smtp';
$config['symfony_mailer.mailer_transport.sendmail']['configuration']['user']='';
$config['symfony_mailer.mailer_transport.sendmail']['configuration']['pass']='';
$config['symfony_mailer.mailer_transport.sendmail']['configuration']['host']='localhost';
$config['symfony_mailer.mailer_transport.sendmail']['configuration']['port']='1025';
// Deveopment services (for CORS)
$settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';

View File

@ -0,0 +1,4 @@
services:
cors.config:
enabled: true