Skip to content
Snippets Groups Projects
Commit 30c2ef3d authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #2919482: phpcs

parent 0f2d6d8f
No related branches found
No related tags found
No related merge requests found
......@@ -29,8 +29,11 @@ class WorkflowTransitionElement extends FormElement {
* This function is referenced in the Annotation for this class.
*
* @param array $element
* The element.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state.
* @param array $complete_form
* The form.
*
* @return array
* The Workflow element
......@@ -50,7 +53,9 @@ class WorkflowTransitionElement extends FormElement {
* @param array $element
* Reference to the form element.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state.
* @param array $complete_form
* The form.
*
* @return array
* The form element $element.
......@@ -177,12 +182,13 @@ class WorkflowTransitionElement extends FormElement {
'#value' => $transition,
];
// $entity may be empty in VBO.
if ($entity) {
// Decide if we show either a widget or a formatter.
// Add a state formatter before the rest of the form,
// when transition is scheduled or widget is hidden.
// Also no widget if the only option is the current sid.
if ((!$show_widget) || $transition->isScheduled() || $transition->isExecuted()) {
if ($entity) { // may be empty in VBO.
$element['workflow_current_state'] = workflow_state_formatter($entity, $field_name, $current_sid);
// Set a proper weight, which works for Workflow Options in select list AND action buttons.
$element['workflow_current_state']['#weight'] = -0.005;
......@@ -231,7 +237,7 @@ class WorkflowTransitionElement extends FormElement {
// It may be replaced later if 'Action buttons' are chosen.
// The help text is not available for container. Let's add it to the
// State box. N.B. it is empty on Workflow Tab, Node View page.
$help_text = isset($element['#description']) ? $element['#description'] : '';
$help_text = $element['#description'] ?? '';
unset($element['#description']);
// This overrides BaseFieldDefinition. @todo Apply for form and widget.
// @todo Repair $workflow->'name_as_title': no container if no details (schedule/comment).
......@@ -398,9 +404,13 @@ class WorkflowTransitionElement extends FormElement {
* - parameter 3 is not $form_state (from Form), but an $item array (from Widget).
*
* @param \Drupal\Core\Entity\EntityInterface $transition
* The transition object.
* @param array $form
* The form.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The form state.
* @param array $item
* The field item.
*
* @return \Drupal\workflow\Entity\WorkflowTransitionInterface
* A new Transition object.
......@@ -551,14 +561,14 @@ class WorkflowTransitionElement extends FormElement {
'#process' => [
[$class, 'processTransition'],
[$class, 'processAjaxForm'],
// array($class, 'processGroup'),
// [$class, 'processGroup'],
],
'#element_validate' => [
[$class, 'validateTransition'],
],
'#pre_render' => [
[$class, 'preRenderTransition'],
// array($class, 'preRenderGroup'),
// [$class, 'preRenderGroup'],
],
// '#theme' => 'input__checkbox',
// '#theme' => 'input__textfield',
......
......@@ -527,7 +527,7 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface {
if (!$this->defaultSettingsMerged && !array_key_exists($key, $this->options)) {
$this->mergeDefaults();
}
return isset($this->options[$key]) ? $this->options[$key] : NULL;
return $this->options[$key] ?? NULL;
}
/**
......
......@@ -59,9 +59,33 @@ class WorkflowConfigTransition extends ConfigEntityBase implements WorkflowConfi
/**
* Transition data.
*/
/**
* The Transition ID.
*
* @var string
*/
public $id;
/**
* The From State ID.
*
* @var string
*/
public $from_sid;
/**
* The To State ID.
*
* @var string
*/
public $to_sid;
/**
* The list of roles that are allowed to use this Transition.
*
* @var array
*/
public $roles = [];
/**
......
......@@ -49,22 +49,34 @@ interface WorkflowConfigTransitionInterface {
public function getWorkflowId();
/**
* @return WorkflowState
* Returns the 'from' State object.
*
* @return \Drupal\workflow\Entity\WorkflowState
* A WorkflowState object.
*/
public function getFromState();
/**
* @return WorkflowState
* Returns the 'to' State object.
*
* @return \Drupal\workflow\Entity\WorkflowState
* A WorkflowState object.
*/
public function getToState();
/**
* @return string
* Returns the 'from' State ID.
*
* @return int
* A WorkflowState ID.
*/
public function getFromSid();
/**
* @return string
* Returns the 'from' State object.
*
* @return int
* A WorkflowState ID.
*/
public function getToSid();
......@@ -72,6 +84,7 @@ interface WorkflowConfigTransitionInterface {
* Determines if the State changes by this Transition.
*
* @return bool
* TRUE if the From and To state ID's are different.
*/
public function hasStateChange();
......
......@@ -45,6 +45,7 @@ interface WorkflowInterface {
* Create a new state for this workflow.
*
* @param string $sid
* The new state ID.
* @param bool $save
* Indicator if the new state must be saved. Normally, the new State is
* saved directly in the database. This is because you can use States only
......@@ -58,11 +59,17 @@ interface WorkflowInterface {
/**
* Gets the initial state for a newly created entity.
*
* @return \Drupal\workflow\Entity\WorkflowState
* The intial state.
*/
public function getCreationState();
/**
* Gets the ID of the initial state for a newly created entity.
*
* @return string
* The ID of the state.
*/
public function getCreationSid();
......@@ -75,8 +82,11 @@ interface WorkflowInterface {
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity at hand. May be NULL (E.g., on a Field settings page).
* @param string $field_name
* The field name.
* @param \Drupal\Core\Session\AccountInterface $user
* The user account.
* @param bool $force
* Indicator to force the transition.
*
* @return string
* A State ID.
......@@ -89,8 +99,11 @@ interface WorkflowInterface {
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity at hand.
* @param string $field_name
* The field name.
* @param \Drupal\Core\Session\AccountInterface $user
* The user account.
* @param bool $force
* Indicator to force the transition.
*
* @return string
* A State ID.
......@@ -108,6 +121,7 @@ interface WorkflowInterface {
* - FALSE = only Active states, not Creation;
* - 'CREATION' = only Active states, including Creation.
* @param bool $reset
* An option to refresh all caches.
*
* @return \Drupal\workflow\Entity\WorkflowState[]
* An array of WorkflowState objects.
......@@ -129,10 +143,14 @@ interface WorkflowInterface {
* Creates a Transition for this workflow.
*
* @param string $from_sid
* The From State ID.
* @param string $to_sid
* The To State ID.
* @param array $values
* The list of new values.
*
* @return \Drupal\workflow\Entity\WorkflowConfigTransitionInterface
* The created Transition.
*/
public function createTransition($from_sid, $to_sid, array $values = []);
......@@ -147,24 +165,37 @@ interface WorkflowInterface {
* Loads all allowed ConfigTransitions for this workflow.
*
* @param array|null $ids
* Array of Transitions IDs. If NULL, show all transitions.
* An array of Transition IDs. If NULL, show all transitions.
* @param array $conditions
* $conditions['from_sid']: if provided, a 'from' State ID.
* $conditions['to_sid']: if provided, a 'to' state ID.
*
* @return \Drupal\workflow\Entity\WorkflowConfigTransition[]
* A list of Config Transitions.
*/
public function getTransitions(array $ids = NULL, array $conditions = []);
/**
* Loads all allowed ConfigTransitions for this workflow, filtered by ID.
*
* @param int $tid
* Transition ID.
*
* @return \Drupal\workflow\Entity\WorkflowConfigTransition[]
* A list of Config Transitions.
*/
public function getTransitionsById($tid);
/**
* Get a specific transition.
*
* @param string $from_sid
* The From State ID.
* @param string $to_sid
* The To State ID.
*
* @return \Drupal\workflow\Entity\WorkflowConfigTransition[]
* A list of Config Transitions.
*/
public function getTransitionsByStateId($from_sid, $to_sid);
......
......@@ -336,7 +336,7 @@ class WorkflowTransition extends ContentEntityBase implements WorkflowTransition
$query->sort('hid', 'DESC');
}
$ids = $query->execute();
$transitions = self::loadMultiple($ids);
$transitions = $ids ? self::loadMultiple($ids) : [];
return $transitions;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment