Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EWPP-3035: Setting onBehalfOf value. #200

Open
wants to merge 2 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"mikey179/vfsstream": "^1.6.10",
"openeuropa/behat-transformation-context": "dev-master",
"openeuropa/code-review": "2.x-dev",
"openeuropa/epoetry-client": "dev-master",
"openeuropa/epoetry-client": "1.x-dev",
"openeuropa/oe_multilingual": "dev-master",
"openeuropa/oe_editorial": "dev-master",
"openeuropa/task-runner-drupal-project-symlink": "1.x-dev",
Expand All @@ -58,7 +58,6 @@
},
"_readme": [
"Patching TMGMT to ensure that when a new translation is saved onto the entity, it doesn't create a new revision",
"Autoload for OpenEuropa\\EPoetry\\Tests\\ temporarily until we stop using the Mock authentication.",
"Patching core event dispatcher for 9.4.x to prevent indiscriminate calls to stopPropagation. Can be removed when we go to D10. See https://www.drupal.org/project/drupal/issues/3319791.",
"Requireding symfony propery-access and propery-info for the ePoetry mock for the serializer that uses them.",
"Requiring minimum versions of php-soap/psr18-transport and symfony/serializer for the epoetry client which needs them for lowest dependencies.",
Expand Down Expand Up @@ -87,7 +86,6 @@
"autoload": {
"psr-4": {
"Drupal\\oe_translation\\": "./src/",
"OpenEuropa\\EPoetry\\Tests\\": "./vendor/openeuropa/epoetry-client/tests/",
"Symfony\\Component\\PropertyInfo\\": "./vendor/symfony/property-info/",
"Symfony\\Component\\PropertyAccess\\": "./vendor/symfony/property-access/"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ function oe_translation_corporate_workflow_theme($existing, $type, $theme, $path
* Implements hook_ENTITY_TYPE_presave().
*/
function oe_translation_corporate_workflow_node_presave(EntityInterface $entity): void {
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = \Drupal::service('content_moderation.moderation_information')->getWorkflowForEntity($entity);
if (!$workflow || $workflow->id() !== 'oe_corporate_workflow') {
// We only care about content using the corporate workflow.
return;
}

if (isset($entity->translation_drop) && $entity->translation_drop === TRUE && $entity->moderation_state->value === 'validated') {
foreach ($entity->getTranslationLanguages(FALSE) as $langcode => $language) {
$entity->removeTranslation($langcode);
Expand Down Expand Up @@ -73,6 +80,13 @@ function oe_translation_corporate_workflow_node_presave(EntityInterface $entity)
* Implements hook_ENTITY_TYPE_view_alter() for the Node entity.
*/
function oe_translation_corporate_workflow_node_view_alter(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display): void {
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = \Drupal::service('content_moderation.moderation_information')->getWorkflowForEntity($entity);
if (!$workflow || $workflow->id() !== 'oe_corporate_workflow') {
// We only care about content using the corporate workflow.
return;
}

// If we are rendering a translation, we should hide the content moderation
// block because the workflow needs to be controlled from the source entity.
if ($entity->isDefaultTranslation()) {
Expand Down Expand Up @@ -189,6 +203,13 @@ function oe_translation_corporate_workflow_form_content_moderation_entity_modera
return;
}

/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = \Drupal::service('content_moderation.moderation_information')->getWorkflowForEntity($entity);
if (!$workflow || $workflow->id() !== 'oe_corporate_workflow') {
// We only care about content using the corporate workflow.
return;
}

$current_state = $entity->moderation_state->value;
$form['translation_drop_wrapper'] = [
'#type' => 'container',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ protected function createNewRequestAccess(ContentEntityInterface $entity): Acces
$statuses = [
TranslationRequestRemoteInterface::STATUS_REQUEST_TRANSLATED,
TranslationRequestRemoteInterface::STATUS_REQUEST_FINISHED,
TranslationRequestRemoteInterface::STATUS_REQUEST_FAILED_FINISHED,
];
$requests = $this->providerManager->getExistingTranslationRequests($entity, FALSE, $statuses);
if ($requests) {
Expand Down Expand Up @@ -129,6 +130,7 @@ protected function createNewRequestAccess(ContentEntityInterface $entity): Acces
$statuses = [
TranslationRequestRemoteInterface::STATUS_REQUEST_TRANSLATED,
TranslationRequestRemoteInterface::STATUS_REQUEST_FINISHED,
TranslationRequestRemoteInterface::STATUS_REQUEST_FAILED_FINISHED,
];
$requests = $this->providerManager->getExistingTranslationRequests($entity, FALSE, $statuses);
if ($requests) {
Expand Down Expand Up @@ -296,6 +298,7 @@ protected function createNewRequestAccessForPublished(ContentEntityInterface $en
$statuses = [
TranslationRequestRemoteInterface::STATUS_REQUEST_TRANSLATED,
TranslationRequestRemoteInterface::STATUS_REQUEST_FINISHED,
TranslationRequestRemoteInterface::STATUS_REQUEST_FAILED_FINISHED,
];
$requests = $this->providerManager->getExistingTranslationRequests($entity, TRUE, $statuses);
if (!$requests) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ oe_translation_remote.remote_translation_provider.plugin.epoetry:
site_id:
type: string
label: The site ID
on_behalf:
type: string
label: On behalf of
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
oe_translation_epoetry_mock.settings:
type: config_object
label: 'OpenEuropa Translation ePoetry Mock settings'
mapping:
endpoint:
type: string
label: 'Endpoint'
notifications_endpoint:
type: string
label: 'Notifications endpoint'
notifications_username:
type: string
label: 'Notifications username'
notifications_password:
type: string
label: 'Notifications password'
application_name:
type: string
label: 'Application name'

This file was deleted.

Loading