diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml
new file mode 100644
index 0000000..feeea58
--- /dev/null
+++ b/.github/workflows/push.yaml
@@ -0,0 +1,26 @@
+name: Check Code standards
+on: [push]
+jobs:
+ coding-standards:
+ name: PHP - Check Coding Standards
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout
+ uses: actions/checkout@v2
+
+ # https://github.com/shivammathur/setup-php#cache-composer-dependencies
+ - name: Get composer cache directory
+ id: composer-cache
+ run: echo "::set-output name=dir::$(composer config cache-files-dir)"
+ - name: Cache dependencies
+ uses: actions/cache@v2
+ with:
+ path: ${{ steps.composer-cache.outputs.dir }}
+ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
+ restore-keys: ${{ runner.os }}-composer-
+
+ - name: Install dependencies
+ run: composer install --no-interaction
+
+ - name: Check coding standards
+ run: composer run coding-standards-check --no-interaction
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..c97a7c5
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,38 @@
+# OS2Forms Forløb Change Log
+All notable changes to this project should be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/)
+and this project adheres to [Semantic Versioning](http://semver.org/).
+
+See ["how do I make a good changelog record?"](https://keepachangelog.com/en/1.0.0/#how)
+before starting to add changes.
+
+## [Unreleased]
+
+### Added
+- Github CI action for checking Drupal Coding standards with PHP Code Sniffer
+- Fixed coding standards issues
+
+
+## Example of change log record
+```
+## [x.x.x] Release name
+### Added
+- Description on added functionality.
+
+### Changed/Updated
+- Description on changed/updated functionality.
+
+### Deprecated
+- Description of soon-to-be removed features.
+
+### Removed
+- Description of removed features.
+
+### Fixed
+- Decription of bug fixes.
+
+### Security
+- Security in case of vulnerabilities.
+
+```
diff --git a/composer.json b/composer.json
index fa4ca03..4c22192 100644
--- a/composer.json
+++ b/composer.json
@@ -54,6 +54,10 @@
"webmozart/path-util": "^2.3",
"zaporylie/composer-drupal-optimizations": "^1.2"
},
+ "require-dev": {
+ "drupal/coder": "^8.3",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.1"
+ },
"extra": {
"composer-exit-on-patch-failure": true,
"patchLevel": {
@@ -80,5 +84,22 @@
"Duplicated attachments in emails generated by Webform: (https://www.drupal.org/project/smtp/issues/2995290)": "https://www.drupal.org/files/issues/2021-11-02/smtp-2995290-23.patch"
}
}
+ },
+ "scripts": {
+ "coding-standards-check/phpcs": [
+ "phpcs --standard=phpcs.xml.dist"
+ ],
+ "coding-standards-check": [
+ "@coding-standards-check/phpcs"
+ ],
+ "coding-standards-apply/phpcs": [
+ "phpcbf --standard=phpcs.xml.dist"
+ ],
+ "coding-standards-apply": [
+ "@coding-standards-apply/phpcs"
+ ]
+ },
+ "config": {
+ "sort-packages": true
}
}
diff --git a/css/gin-custom.css b/css/gin-custom.css
index 6f3b3db..396e450 100644
--- a/css/gin-custom.css
+++ b/css/gin-custom.css
@@ -1,3 +1,3 @@
.ui-dialog:not(.ui-dialog-off-canvas) {
- width: 70vw!important;
+ width: 70vw!important;
}
diff --git a/os2forms_forloeb.info.yml b/os2forms_forloeb.info.yml
index 13214e2..e29320f 100644
--- a/os2forms_forloeb.info.yml
+++ b/os2forms_forloeb.info.yml
@@ -6,51 +6,51 @@ core: 8.x
core_version_requirement: ^8 || ^9
dependencies:
- - admin_toolbar_tools
- - coc_forms_auto_export
- - config_entity_revisions
- - diff
- - entity_print
- - eu_cookie_compliance
- - events_logging
- - gin_toolbar
- - honeypot
- - libraries
- - maestro
- - mailsystem
- - masquerade
- - os2forms
- - os2forms_nemid
- - os2forms_dawa
- - os2forms_sbsys
- - os2web_simplesaml
- - pathauto
- - r4032login
- - redirect
- - smtp
- - system
- - switch_page_theme
- - token
- - ultimate_cron
- - user_default_page
- - webform
- - webform_ui
- - webform_access
- - webform_attachment
- - webform_composite
- - webform_embed
- - webform_entity_print
- - webform_entity_print_attachment
- - webform_migrate
- - webform_node_element
- - webform_remote_handlers
- - webform_rest
- - webform_revisions
- - webform_share
- - webform_scheduled_email
- - webform_submission_export_import
- - webform_submission_log
- - webform_templates
- - workflow_participants
+ - 'drupal:admin_toolbar_tools'
+ - 'drupal:coc_forms_auto_export'
+ - 'drupal:config_entity_revisions'
+ - 'drupal:diff'
+ - 'drupal:entity_print'
+ - 'drupal:eu_cookie_compliance'
+ - 'drupal:events_logging'
+ - 'drupal:gin_toolbar'
+ - 'drupal:honeypot'
+ - 'drupal:libraries'
+ - 'drupal:maestro'
+ - 'drupal:mailsystem'
+ - 'drupal:masquerade'
+ - 'drupal:os2forms'
+ - 'drupal:os2forms_nemid'
+ - 'drupal:os2forms_dawa'
+ - 'drupal:os2forms_sbsys'
+ - 'drupal:os2web_simplesaml'
+ - 'drupal:pathauto'
+ - 'drupal:r4032login'
+ - 'drupal:redirect'
+ - 'drupal:smtp'
+ - 'drupal:system'
+ - 'drupal:switch_page_theme'
+ - 'drupal:token'
+ - 'drupal:ultimate_cron'
+ - 'drupal:user_default_page'
+ - 'drupal:webform'
+ - 'drupal:webform_ui'
+ - 'drupal:webform_access'
+ - 'drupal:webform_attachment'
+ - 'drupal:webform_composite'
+ - 'drupal:webform_embed'
+ - 'drupal:webform_entity_print'
+ - 'drupal:webform_entity_print_attachment'
+ - 'drupal:webform_migrate'
+ - 'drupal:webform_node_element'
+ - 'drupal:webform_remote_handlers'
+ - 'drupal:webform_rest'
+ - 'drupal:webform_revisions'
+ - 'drupal:webform_share'
+ - 'drupal:webform_scheduled_email'
+ - 'drupal:webform_submission_export_import'
+ - 'drupal:webform_submission_log'
+ - 'drupal:webform_templates'
+ - 'drupal:workflow_participants'
'interface translation project': os2forms_forloeb
'interface translation server pattern': modules/contrib/os2forms_forloeb/translations/os2forms_forloeb.da.po
diff --git a/os2forms_forloeb.module b/os2forms_forloeb.module
index f0372c0..3296639 100644
--- a/os2forms_forloeb.module
+++ b/os2forms_forloeb.module
@@ -1,5 +1,12 @@
'select_assigned_user',
'#type' => 'entity_autocomplete',
'#target_type' => 'user',
'#default_value' => '',
'#selection_settings' => ['include_anonymous' => FALSE],
- '#title' => t('Assign for Review to'),
- );
+ '#title' => t('Assign for Review to'),
+ ];
- $form['queueID'] = array(
+ $form['queueID'] = [
'#type' => 'hidden',
'#title' => 'the queue ID in the event we need it in later processing',
'#default_value' => $queueID,
'#description' => ('queueID'),
- );
+ ];
- //overriding the default label "complete"
+ // Overriding the default label "complete".
$form['actions']['submit']['#value'] = t('Assign');
return $form;
}
-
/**
- * This is the submit handler for the Reassign for Approval form use in maestro workflows.
+ * Submit handler for The Reassign for Approval form.
+ *
+ * This is the submit handler for the Reassign for Approval form
+ * used in maestro workflows.
*/
function os2forms_forloeb_workflow_maestro_reassign_form_submit(&$form, &$form_state) {
$queueID = intval($form_state->getValue('queueID'));
$processID = MaestroEngine::getProcessIdFromQueueId($queueID);
- //Who was selected? Load their username, which is the user attribute that Maestro assigns tasks by.
+ // Who was selected? Load their username, which is the user attribute
+ // that Maestro assigns tasks by.
$reviewer_uid = $form_state->getValue('reviewer');
- $reviewer = User::load($reviewer_uid); // pass your uid
+ // Pass your uid.
+ $reviewer = User::load($reviewer_uid);
$reviewer_username = $reviewer->getAccountName();
- //add that user to our maestro process variable.
+ // Add that user to our maestro process variable.
MaestroEngine::setProcessVariable("assigned_to", $reviewer_username, $processID);
- //Provide some feedback
+ // Provide some feedback.
\Drupal::messenger()->addStatus("Content Reassigned");
-
}
/**
- * * Implements hook_maestro_batch_handlers().
- * *
- * * Array of function names and help text that will be displayed
- * * in the edit task form under the handler field.
- * */
+ * Implements hook_maestro_batch_handlers().
+ *
+ * Array of function names and help text that will be displayed
+ * in the edit task form under the handler field.
+ */
function os2forms_forloeb_maestro_batch_handlers() {
return [
'end_notification_batch_function' => t('Batch function to send out flow completion notification to initiator.'),
@@ -94,11 +101,13 @@ function os2forms_forloeb_maestro_batch_handlers() {
}
/**
- * * @param int $processID
- * * The Maestro process ID.
- * * @param int $queueID
- * * The Maestro queue ID.
- * */
+ * Finishing callback for batch handler.
+ *
+ * @param int $processID
+ * The Maestro process ID.
+ * @param int $queueID
+ * The Maestro queue ID.
+ */
function end_notification_batch_function($processID, $queueID) {
/*
@@ -116,7 +125,7 @@ function end_notification_batch_function($processID, $queueID) {
if ($sid) {
$webform_submission = WebformSubmission::load($sid);
- $webform = $webform_submission->getWebform();
+ $webform = $webform_submission->getWebform();
$handlers = $webform->getHandlers();
foreach ($handlers as $handler) {
@@ -131,27 +140,29 @@ function end_notification_batch_function($processID, $queueID) {
}
/**
- * Implements hook_ENTITY_TYPE_create()
+ * Implements hook_ENTITY_TYPE_create().
+ *
* Sets a global purge setting for all webform submissions to 30 days.
*/
function os2forms_forloeb_webform_create(WebformInterface $webform) {
- // Set purge of all users submissions.
- $webform->setSetting('purge', 'all');
- // Set purge of submissions more than 30 days old.
- if (empty($webform->getSetting('purge_days'))) {
- $webform->setSetting('purge_days', '30');
- }
+ // Set purge of all users submissions.
+ $webform->setSetting('purge', 'all');
+ // Set purge of submissions more than 30 days old.
+ if (empty($webform->getSetting('purge_days'))) {
+ $webform->setSetting('purge_days', '30');
+ }
}
/**
- * Implements hook_ENTITY_TYPE_presave()
+ * Implements hook_ENTITY_TYPE_presave().
+ *
* Update webform specific submissions purge settings.
*/
function os2forms_forloeb_webform_presave(WebformInterface $webform) {
- // Add a purge time frame if not set.
- if (empty($webform->getSetting('purge_days'))) {
- $webform->setSetting('purge_days', 30);
- }
+ // Add a purge time frame if not set.
+ if (empty($webform->getSetting('purge_days'))) {
+ $webform->setSetting('purge_days', 30);
+ }
}
/**
@@ -203,8 +214,7 @@ function os2forms_forloeb_spv_fetch_entity_username($uniqueWebformIdentifier, $w
}
/**
- * Returns array of custom task-types for OS2forms
- *
+ * Returns array of custom task-types for OS2forms.
*/
function os2forms_forloeb_get_custom_task_types() {
return ['MaestroWebformMultiple', 'MaestroWebformInherit'];
@@ -216,8 +226,8 @@ function os2forms_forloeb_get_custom_task_types() {
* This has been copied from
* maestro/maestro_webform/maestro_webform.module with a minimal but
* necessary change. See https://www.drupal.org/project/maestro/issues/3243510
- * When that issue has been fixed, this hook implementation can be safely deleted.
- *
+ * When that issue has been fixed, this hook implementation
+ * can be safely deleted.
*/
function os2forms_forloeb_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$queueID = intval(\Drupal::request()->query->get('queueid', 0));
@@ -225,19 +235,20 @@ function os2forms_forloeb_form_alter(&$form, FormStateInterface $form_state, $fo
// Both these keys need to exist.
if ($isMaestro && $queueID) {
$templateTask = MaestroEngine::getTemplateTaskByQueueID($queueID);
- // Get array of custom task-types
+ // Get array of custom task-types.
$os2forms_forloeb_custom_task_types = os2forms_forloeb_get_custom_task_types();
- // We only care about custom Task-types defined in os2forms_forloeb_get_custom_task_types()
+ // We only care about custom Task-types
+ // defined in os2forms_forloeb_get_custom_task_types()
if ($templateTask && in_array($templateTask['tasktype'], $os2forms_forloeb_custom_task_types)) {
$storage = $form_state->getStorage();
if ($storage && array_key_exists('form_display', $storage)) {
- $webformTypes = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple();
$thisForm = $storage['form_display']->get('bundle');
$targetEntityType = $storage['form_display']->get('targetEntityType');
if ($isMaestro == 1 &&
$targetEntityType == 'webform_submission' &&
$templateTask['data']['webform_machine_name'] == $thisForm) {
- // We now know this is a webform submission. We are going to add in our own form fields here.
+ // We now know this is a webform submission.
+ // We are going to add in our own form fields here.
$form['maestro'] = [
'#tree' => TRUE,
];
@@ -268,8 +279,11 @@ function os2forms_forloeb_form_alter(&$form, FormStateInterface $form_state, $fo
}
}
+/**
+ * Implements hook_preprocess_page().
+ */
function os2forms_forloeb_preprocess_page(&$variables) {
- $variables['#attached']['library'][] = 'os2forms_forloeb/os2forms_forloeb';
+ $variables['#attached']['library'][] = 'os2forms_forloeb/os2forms_forloeb';
}
/**
@@ -304,9 +318,10 @@ function os2forms_forloeb_tokens($type, array $tokens, array $data, array $optio
/**
* Implements hook_entity_access().
+ *
* Allows requests with tokens to view the entity.
*/
-function os2forms_forloeb_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) {
+function os2forms_forloeb_entity_access(EntityInterface $entity, $operation, AccountInterface $account) {
if ($operation == 'update' && $entity instanceof WebformSubmission) {
$token = \Drupal::request()->query->get('os2forms-forloeb-ws-token');
if ($token && $token === $entity->getToken()) {
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
new file mode 100644
index 0000000..6b8023d
--- /dev/null
+++ b/phpcs.xml.dist
@@ -0,0 +1,16 @@
+
+
+ OS2Forms forloeb PHP Code Sniffer configuration
+
+ .
+ vendor/
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Controller/ForloebTaskConsoleController.php b/src/Controller/ForloebTaskConsoleController.php
index 0666915..8f9d7b7 100644
--- a/src/Controller/ForloebTaskConsoleController.php
+++ b/src/Controller/ForloebTaskConsoleController.php
@@ -12,9 +12,10 @@
use Drupal\Core\StringTranslation\PluralTranslatableMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
+use Symfony\Component\HttpFoundation\RequestStack;
/**
- * Class ForloebTaskConsoleController.
+ * Controller for Forloeb task console.
*/
class ForloebTaskConsoleController extends ControllerBase {
@@ -32,17 +33,27 @@ class ForloebTaskConsoleController extends ControllerBase {
*/
protected $entityTypeManager;
+ /**
+ * The request stack.
+ *
+ * @var \Symfony\Component\HttpFoundation\RequestStack
+ */
+ protected $requestStack;
+
/**
* Constructs update status data.
*
- * @param \Drupal\os2forms_forloeb\ForloebTaskConsole $forloebTaskConsole
+ * @param \Drupal\os2forms_forloeb\ForloebTaskConsole $forloeb_task_console
* Forloeb task console Service.
- * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
+ * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The Entity type manager.
+ * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
+ * The request stack used to retrieve the current request.
*/
- public function __construct(ForloebTaskConsole $forloeb_task_console, EntityTypeManagerInterface $entity_type_manager) {
+ public function __construct(ForloebTaskConsole $forloeb_task_console, EntityTypeManagerInterface $entity_type_manager, RequestStack $request_stack) {
$this->forloebTaskConsole = $forloeb_task_console;
$this->entityTypeManager = $entity_type_manager;
+ $this->requestStack = $request_stack;
}
/**
@@ -51,7 +62,8 @@ public function __construct(ForloebTaskConsole $forloeb_task_console, EntityType
public static function create(ContainerInterface $container) {
return new static(
$container->get('os2forms_forloeb.task_console'),
- $container->get('entity_type.manager')
+ $container->get('entity_type.manager'),
+ $container->get('request_stack')
);
}
@@ -60,20 +72,20 @@ public static function create(ContainerInterface $container) {
*
* In case it's not possible to define task, redirects to task console.
*
- * @return RedirectResponse
+ * @return \Symfony\Component\HttpFoundation\RedirectResponse
* Redirect object.
*/
public function execute() {
$redirect_to = Url::fromRoute('maestro_taskconsole.taskconsole');
// Check webform submission token.
- $token = \Drupal::request()->query->get('os2forms-forloeb-ws-token', '');
+ $token = $this->requestStack->getCurrentRequest()->query->get('os2forms-forloeb-ws-token', '');
if ($token) {
$queueRecord = $this->forloebTaskConsole->getQueueIdByWebformSubmissionToken($token);
}
else {
// For empty token there is user last task from taskconsole queue.
- $queueIDs = MaestroEngine::getAssignedTaskQueueIds(\Drupal::currentUser()->id());
+ $queueIDs = MaestroEngine::getAssignedTaskQueueIds($this->currentUser()->id());
$queueRecord = count($queueIDs) ? $this->entityTypeManager->getStorage('maestro_queue')->load(end($queueIDs)) : NULL;
// In case there are more than 1 task warning message will be shown.
@@ -81,7 +93,7 @@ public function execute() {
$this->messenger()->addWarning($this->t('You have @amount @tasks available for you. See list of the all tasks on taskconsole', [
':tasksonsole' => Url::fromRoute('maestro_taskconsole.taskconsole')->toString(),
'@amount' => count($queueIDs),
- '@tasks' => new PluralTranslatableMarkup(count($queueIDs), 'task','tasks'),
+ '@tasks' => new PluralTranslatableMarkup(count($queueIDs), 'task', 'tasks'),
]));
}
}
@@ -95,7 +107,7 @@ public function execute() {
$handler = $queueRecord->handler->getString();
$query_options = [
'queueid' => $queueRecord->id(),
- 'modal' => 'notmodal'
+ 'modal' => 'notmodal',
];
// As inspiration MaestroTaskConsoleController::getTasks() method was used.
@@ -109,7 +121,9 @@ public function execute() {
}
elseif ($queueRecord->is_interactive->getString() == '1' && empty($handler)) {
- // Handler is empty. If this is an interactive task and has no handler, we're still OK. This is an interactive function that uses a default handler then.
+ // Handler is empty.
+ // If this is an interactive task and has no handler, we're still OK.
+ // This is an interactive function that uses a default handler then.
$handler_type = 'function';
}
else {
@@ -118,7 +132,7 @@ public function execute() {
switch ($handler_type) {
case 'external':
- $redirect_to = Url::fromUri($handler, ['query' => $query_options]);
+ $redirect_to = Url::fromUri($handler, ['query' => $query_options]);
break;
case 'internal':
diff --git a/src/ForloebTaskConsole.php b/src/ForloebTaskConsole.php
index ef7340c..710bf2e 100644
--- a/src/ForloebTaskConsole.php
+++ b/src/ForloebTaskConsole.php
@@ -1,16 +1,13 @@
logger = $logger;
}
-
/**
* Gets MaestroQueue record by webforms submission token.
*
* @param string $token
+ * Webform submission token.
*
* @return \Drupal\maestro\Entity\MaestroQueue|null
* Returns MaestroQueue entity or NULL
@@ -51,7 +48,7 @@ public function __construct(EntityTypeManagerInterface $entity_type_manager, Log
* @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException
*/
public function getQueueIdByWebformSubmissionToken($token = '') {
- /** @var WebformSubmission $webform_submission */
+ /** @var \Drupal\webform\Entity\WebformSubmission $webform_submission */
$webform_submissions = $this->entityTypeManager->getStorage('webform_submission')->loadByProperties(['token' => $token]);
if (empty($webform_submissions)) {
@@ -60,8 +57,11 @@ public function getQueueIdByWebformSubmissionToken($token = '') {
}
$webform_submission = reset($webform_submissions);
- /** @var MaestroEntityIdentifiers $maestro_entity_identifier */
- $maestro_entity_identifiers = $this->entityTypeManager->getStorage('maestro_entity_identifiers')->loadByProperties(['entity_type' => 'webform_submission', 'entity_id' => $webform_submission->id(),]);
+ /** @var \Drupal\maestro\Entity\MaestroEntityIdentifiers $maestro_entity_identifier */
+ $maestro_entity_identifiers = $this->entityTypeManager->getStorage('maestro_entity_identifiers')->loadByProperties([
+ 'entity_type' => 'webform_submission',
+ 'entity_id' => $webform_submission->id(),
+ ]);
$maestro_entity_identifier = reset($maestro_entity_identifiers);
$processIDs = $maestro_entity_identifier->process_id->referencedEntities();
if (empty($processIDs)) {
@@ -70,7 +70,10 @@ public function getQueueIdByWebformSubmissionToken($token = '') {
}
$processID = reset($processIDs);
- $maestro_queues = $this->entityTypeManager->getStorage('maestro_queue')->loadByProperties(['process_id' => $processID->id(), 'task_class_name' => 'MaestroWebformInherit',]);
+ $maestro_queues = $this->entityTypeManager->getStorage('maestro_queue')->loadByProperties([
+ 'process_id' => $processID->id(),
+ 'task_class_name' => 'MaestroWebformInherit',
+ ]);
if (empty($maestro_queues)) {
$this->logger->warning($this->t('Maestro queue with task_class_name: MaestroWebformInherit and process_id: @process_id not found', ['@process_id' => $processID->id()]));
return NULL;
diff --git a/src/Plugin/EngineTasks/MaestroSelectContentTask.php b/src/Plugin/EngineTasks/MaestroSelectContentTask.php
index 1f24e7a..e2affa3 100644
--- a/src/Plugin/EngineTasks/MaestroSelectContentTask.php
+++ b/src/Plugin/EngineTasks/MaestroSelectContentTask.php
@@ -53,7 +53,7 @@ public function isInteractive() {
* {@inheritDoc}
*/
public function shortDescription() {
- return t('Create or Select a Content Item');
+ return $this->t('Create or Select a Content Item');
}
/**
@@ -84,11 +84,11 @@ public function getTaskColours() {
*/
public function getTaskEditForm(array $task, $templateMachineName) {
$form = [
- '#markup' => t('Select a Content Item.'),
+ '#markup' => $this->t('Select a Content Item.'),
];
$content_type_options = [
- 'all' => t('All Content Types'),
+ 'all' => $this->t('All Content Types'),
];
$content_types_objs = $types = \Drupal::entityTypeManager()
->getStorage('node_type')
@@ -112,7 +112,7 @@ public function getTaskEditForm(array $task, $templateMachineName) {
'#type' => 'textfield',
'#title' => $this->t('Give this piece of content a unique identifier'),
'#description' => $this->t('This identifier is stored along with its ID to allow you to recall it when filled in.'),
- '#default_value' => isset($task['data']['unique_id']) ? $task['data']['unique_id'] : '',
+ '#default_value' => $task['data']['unique_id'] ?? '',
'#required' => TRUE,
];
@@ -120,7 +120,7 @@ public function getTaskEditForm(array $task, $templateMachineName) {
'#type' => 'textfield',
'#title' => $this->t('Return Path'),
'#description' => $this->t('You can specify where your return path should go upon task completion.'),
- '#default_value' => isset($task['data']['redirect_to']) ? $task['data']['redirect_to'] : '/taskconsole',
+ '#default_value' => $task['data']['redirect_to'] ?? '/taskconsole',
'#required' => TRUE,
];
@@ -128,7 +128,7 @@ public function getTaskEditForm(array $task, $templateMachineName) {
'#type' => 'select',
'#title' => $this->t('Task presentation'),
'#description' => $this->t('Should this task be shown as a modal or full screen task.'),
- '#default_value' => isset($task['data']['modal']) ? $task['data']['modal'] : 'notmodal',
+ '#default_value' => $task['data']['modal'] ?? 'notmodal',
'#options' => [
'modal' => $this->t('Modal'),
'notmodal' => $this->t('Full Page'),
@@ -196,11 +196,11 @@ public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {
'#id' => 'webform',
'#type' => 'radios',
'#options' => [
- 0 => t('Choose an Existing self-service page'),
- 1 => t('Create a New self-service page'),
+ 0 => $this->t('Choose an Existing self-service page'),
+ 1 => $this->t('Create a New self-service page'),
],
'#default_value' => 0,
- '#title' => t('Create or Select a self-service page'),
+ '#title' => $this->t('Create or Select a self-service page'),
'#required' => TRUE,
];
@@ -218,7 +218,7 @@ public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {
'#id' => 'existing_webform',
'#type' => 'select',
'#options' => $webforms,
- '#title' => t('Choose an Existing self-service page'),
+ '#title' => $this->t('Choose an Existing self-service page'),
'#validated' => TRUE,
'#prefix' => '
',
'#suffix' => '
',
@@ -380,7 +380,7 @@ public function performValidityCheck(array &$validation_failure_tasks, array &$v
$validation_failure_tasks[] = [
'taskID' => $task['id'],
'taskLabel' => $task['label'],
- 'reason' => t('The Interactive Task has not been set up properly. The "Task Presentation" option is missing and thus the engine will be unable to execute this task.'),
+ 'reason' => $this->t('The Interactive Task has not been set up properly. The "Task Presentation" option is missing and thus the engine will be unable to execute this task.'),
];
}
@@ -390,7 +390,7 @@ public function performValidityCheck(array &$validation_failure_tasks, array &$v
$validation_failure_tasks[] = [
'taskID' => $task['id'],
'taskLabel' => $task['label'],
- 'reason' => t('The Interactive Task has not been set up properly. The Interactive Task requires assignments to actors, roles or other assignment options.'),
+ 'reason' => $this->t('The Interactive Task has not been set up properly. The Interactive Task requires assignments to actors, roles or other assignment options.'),
];
}
@@ -398,7 +398,7 @@ public function performValidityCheck(array &$validation_failure_tasks, array &$v
$validation_failure_tasks[] = [
'taskID' => $task['id'],
'taskLabel' => $task['label'],
- 'reason' => t('The Content Type Task has not been set up properly. The "unique identifier" option is missing and thus the engine will be unable to execute this task.'),
+ 'reason' => $this->t('The Content Type Task has not been set up properly. The "unique identifier" option is missing and thus the engine will be unable to execute this task.'),
];
}
}
diff --git a/src/Plugin/EngineTasks/MaestroWebformInheritTask.php b/src/Plugin/EngineTasks/MaestroWebformInheritTask.php
index ecdceaf..83dbdb9 100644
--- a/src/Plugin/EngineTasks/MaestroWebformInheritTask.php
+++ b/src/Plugin/EngineTasks/MaestroWebformInheritTask.php
@@ -9,10 +9,6 @@
use Drupal\maestro\Form\MaestroExecuteInteractive;
use Drupal\maestro\Engine\MaestroEngine;
use Drupal\Core\Form\FormStateInterface;
-use Drupal\webform\Entity\Webform;
-use Drupal\Core\Ajax\AjaxResponse;
-use Drupal\Core\Ajax\ReplaceCommand;
-use Drupal\Core\Messenger;
use Symfony\Component\HttpFoundation\RedirectResponse;
/**
@@ -45,7 +41,7 @@ public function __construct(array $configuration = NULL) {
* {@inheritDoc}
*/
public function shortDescription() {
- return t('Webform with Inherited submission');
+ return $this->t('Webform with Inherited submission');
}
/**
@@ -69,7 +65,7 @@ public function getPluginId() {
*/
public function getTaskEditForm(array $task, $templateMachineName) {
- // We call the parent, as we need to add a field to the inherited form
+ // We call the parent, as we need to add a field to the inherited form.
$form = parent::getTaskEditForm($task, $templateMachineName);
$form['inherit_webform_unique_id'] = [
'#type' => 'textfield',
@@ -86,7 +82,7 @@ public function getTaskEditForm(array $task, $templateMachineName) {
*/
public function prepareTaskForSave(array &$form, FormStateInterface $form_state, array &$task) {
- // Inherit from parent
+ // Inherit from parent.
parent::prepareTaskForSave($form, $form_state, $task);
// Add custom field(s) to the inherited prepareTaskForSave method.
$task['data']['inherit_webform_unique_id'] = $form_state->getValue('inherit_webform_unique_id');
@@ -102,7 +98,7 @@ public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {
$taskMachineName = MaestroEngine::getTaskIdFromQueueId($this->queueID);
$task = MaestroEngine::getTemplateTaskByID($templateMachineName, $taskMachineName);
- // Get user input from 'inherit_webform_unique_id'
+ // Get user input from 'inherit_webform_unique_id'.
$webformInheritID = $task['data']['inherit_webform_unique_id'];
// Load its corresponding webform submission.
@@ -134,10 +130,11 @@ public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {
// Create submission.
$new_submission = WebformSubmission::create($values);
- // Submit the webform submission
+ // Submit the webform submission.
$submission = WebformSubmissionForm::submitWebformSubmission($new_submission);
- // WebformSubmissionForm::submitWebformSubmission returns an array if the submission is not valid.
+ // WebformSubmissionForm::submitWebformSubmission returns an array
+ // if the submission is not valid.
if (is_array($submission)) {
\Drupal::logger('os2forms_forloeb')->error(
"Can't create new submission: " . json_encode($submission)
@@ -166,4 +163,5 @@ public function getExecutableForm($modal, MaestroExecuteInteractive $parent) {
return $form;
}
+
}
diff --git a/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php b/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php
index d6a55f8..6c33d25 100644
--- a/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php
+++ b/src/Plugin/EngineTasks/MaestroWebformMultipleTask.php
@@ -38,7 +38,7 @@ public function __construct(array $configuration = NULL) {
* {@inheritDoc}
*/
public function shortDescription() {
- return t('Webform task with Multiple Submissions');
+ return $this->t('Webform task with Multiple Submissions');
}
/**