updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
@@ -11,6 +11,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Form for adding workflows.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowAddForm extends EntityForm {
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@ use Drupal\Core\Url;
|
||||
|
||||
/**
|
||||
* Builds the form to delete Workflow entities.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowDeleteForm extends EntityConfirmFormBase {
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* The form for editing workflows.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowEditForm extends EntityForm {
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class WorkflowStateAddForm.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowStateAddForm extends EntityForm {
|
||||
|
||||
@@ -60,10 +62,9 @@ class WorkflowStateAddForm extends EntityForm {
|
||||
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Label'),
|
||||
'#title' => $this->t('State label'),
|
||||
'#maxlength' => 255,
|
||||
'#default_value' => '',
|
||||
'#description' => $this->t('Label for the state.'),
|
||||
'#required' => TRUE,
|
||||
];
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Builds the form to delete states from Workflow entities.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowStateDeleteForm extends ConfirmFormBase {
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class WorkflowStateEditForm.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowStateEditForm extends EntityForm {
|
||||
|
||||
@@ -77,10 +79,9 @@ class WorkflowStateEditForm extends EntityForm {
|
||||
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Label'),
|
||||
'#title' => $this->t('State label'),
|
||||
'#maxlength' => 255,
|
||||
'#default_value' => $state->label(),
|
||||
'#description' => $this->t('Label for the state.'),
|
||||
'#required' => TRUE,
|
||||
];
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class WorkflowTransitionAddForm.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowTransitionAddForm extends EntityForm {
|
||||
|
||||
@@ -61,10 +63,9 @@ class WorkflowTransitionAddForm extends EntityForm {
|
||||
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Label'),
|
||||
'#title' => $this->t('Transition label'),
|
||||
'#maxlength' => 255,
|
||||
'#default_value' => '',
|
||||
'#description' => $this->t('Label for the transition.'),
|
||||
'#required' => TRUE,
|
||||
];
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Builds the form to delete transitions from Workflow entities.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowTransitionDeleteForm extends ConfirmFormBase {
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Class WorkflowTransitionEditForm.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
class WorkflowTransitionEditForm extends EntityForm {
|
||||
|
||||
@@ -78,10 +80,9 @@ class WorkflowTransitionEditForm extends EntityForm {
|
||||
|
||||
$form['label'] = [
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Label'),
|
||||
'#title' => $this->t('Transition label'),
|
||||
'#maxlength' => 255,
|
||||
'#default_value' => $transition->label(),
|
||||
'#description' => $this->t('Label for the transition.'),
|
||||
'#required' => TRUE,
|
||||
];
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ use Drupal\Core\Plugin\PluginWithFormsTrait;
|
||||
use Drupal\workflows\State;
|
||||
use Drupal\workflows\StateInterface;
|
||||
use Drupal\workflows\Transition;
|
||||
use Drupal\workflows\TransitionInterface;
|
||||
use Drupal\workflows\WorkflowInterface;
|
||||
use Drupal\workflows\WorkflowTypeInterface;
|
||||
|
||||
@@ -177,7 +178,11 @@ abstract class WorkflowTypeBase extends PluginBase implements WorkflowTypeInterf
|
||||
*/
|
||||
public function setStateWeight($state_id, $weight) {
|
||||
if (!$this->hasState($state_id)) {
|
||||
throw new \InvalidArgumentException("The state '$state_id' does not exist in workflow.'");
|
||||
throw new \InvalidArgumentException("The state '$state_id' does not exist in workflow.");
|
||||
}
|
||||
if (!is_numeric($weight)) {
|
||||
$label = $this->getState($state_id)->label();
|
||||
throw new \InvalidArgumentException("The weight '$weight' must be numeric for state '$label'.");
|
||||
}
|
||||
$this->configuration['states'][$state_id]['weight'] = $weight;
|
||||
return $this;
|
||||
@@ -328,7 +333,7 @@ abstract class WorkflowTypeBase extends PluginBase implements WorkflowTypeInterf
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getTransitionsForState($state_id, $direction = 'from') {
|
||||
public function getTransitionsForState($state_id, $direction = TransitionInterface::DIRECTION_FROM) {
|
||||
$transition_ids = array_keys(array_filter($this->configuration['transitions'], function ($transition) use ($state_id, $direction) {
|
||||
return in_array($state_id, (array) $transition[$direction], TRUE);
|
||||
}));
|
||||
@@ -389,7 +394,11 @@ abstract class WorkflowTypeBase extends PluginBase implements WorkflowTypeInterf
|
||||
*/
|
||||
public function setTransitionWeight($transition_id, $weight) {
|
||||
if (!$this->hasTransition($transition_id)) {
|
||||
throw new \InvalidArgumentException("The transition '$transition_id' does not exist in workflow.'");
|
||||
throw new \InvalidArgumentException("The transition '$transition_id' does not exist in workflow.");
|
||||
}
|
||||
if (!is_numeric($weight)) {
|
||||
$label = $this->getTransition($transition_id)->label();
|
||||
throw new \InvalidArgumentException("The weight '$weight' must be numeric for transition '$label'.");
|
||||
}
|
||||
$this->configuration['transitions'][$transition_id]['weight'] = $weight;
|
||||
return $this;
|
||||
|
||||
@@ -18,6 +18,16 @@ interface TransitionInterface {
|
||||
*/
|
||||
const PLUGIN_FORM_KEY = 'transition';
|
||||
|
||||
/**
|
||||
* The transition direction from.
|
||||
*/
|
||||
const DIRECTION_FROM = 'from';
|
||||
|
||||
/**
|
||||
* The transition direction to.
|
||||
*/
|
||||
const DIRECTION_TO = 'to';
|
||||
|
||||
/**
|
||||
* Gets the transition's ID.
|
||||
*
|
||||
|
||||
@@ -93,7 +93,7 @@ class WorkflowListBuilder extends ConfigEntityListBuilder {
|
||||
$build = parent::render();
|
||||
$workflow_types_count = count($this->workflowTypeManager->getDefinitions());
|
||||
if ($workflow_types_count === 0) {
|
||||
$build['table']['#empty'] = $this->t('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the Content Moderation module provides a workflow type that enables workflows for content entities.');
|
||||
$build['table']['#empty'] = $this->t('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the <a href=":content-moderation">Content Moderation</a> module provides a workflow type that enables workflows for content entities.', [':content-moderation' => '/admin/modules#module-content-moderation']);
|
||||
}
|
||||
return $build;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ interface WorkflowTypeInterface extends PluginWithFormsInterface, DerivativeInsp
|
||||
* A list of state IDs to get. If NULL then all states will be returned.
|
||||
*
|
||||
* @return \Drupal\workflows\StateInterface[]
|
||||
* An array of workflow states.
|
||||
* An array of workflow states, keyed by state IDs.
|
||||
*
|
||||
* @throws \InvalidArgumentException
|
||||
* Thrown if $state_ids contains a state ID that does not exist.
|
||||
@@ -248,13 +248,17 @@ interface WorkflowTypeInterface extends PluginWithFormsInterface, DerivativeInsp
|
||||
* @param $state_id
|
||||
* The state to get transitions for.
|
||||
* @param string $direction
|
||||
* (optional) The direction of the transition. Defaults to 'from'. Possible
|
||||
* values are: 'from' and 'to'.
|
||||
* (optional) The direction of the transition, defaults to
|
||||
* TransitionInterface::DIRECTION_FROM. Possible values are:
|
||||
* TransitionInterface::DIRECTION_FROM or TransitionInterface::DIRECTION_TO.
|
||||
*
|
||||
* @return array
|
||||
* The transition IDs for a state for the provided direction.
|
||||
*
|
||||
* @see \Drupal\workflows\TransitionInterface::DIRECTION_FROM
|
||||
* @see \Drupal\workflows\TransitionInterface::DIRECTION_TO
|
||||
*/
|
||||
public function getTransitionsForState($state_id, $direction = 'from');
|
||||
public function getTransitionsForState($state_id, $direction = TransitionInterface::DIRECTION_FROM);
|
||||
|
||||
/**
|
||||
* Gets a transition from state to state.
|
||||
|
||||
+3
-3
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- workflows
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457825
|
||||
|
||||
@@ -7,8 +7,8 @@ package: Testing
|
||||
dependencies:
|
||||
- workflows
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457825
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\workflows\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class WorkflowXmlAnonTest extends WorkflowResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\workflows\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class WorkflowXmlBasicAuthTest extends WorkflowResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\workflows\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class WorkflowXmlCookieTest extends WorkflowResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
@@ -38,6 +38,7 @@ class WorkflowUiNoTypeTest extends BrowserTestBase {
|
||||
|
||||
$this->drupalGet('admin/config/workflow/workflows');
|
||||
$this->assertSession()->pageTextContains('There are no workflow types available. In order to create workflows you need to install a module that provides a workflow type. For example, the Content Moderation module provides a workflow type that enables workflows for content entities.');
|
||||
$this->assertSession()->linkExists('Content Moderation');
|
||||
$this->assertSession()->pageTextNotContains('Add workflow');
|
||||
|
||||
$this->container->get('module_installer')->install(['workflow_type_test']);
|
||||
|
||||
@@ -225,6 +225,16 @@ class WorkflowTest extends UnitTestCase {
|
||||
$workflow->getTypePlugin()->setStateWeight('draft', 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setStateWeight
|
||||
*/
|
||||
public function testSetStateWeightNonNumericException() {
|
||||
$this->setExpectedException(\InvalidArgumentException::class, "The weight 'foo' must be numeric for state 'Published'.");
|
||||
$workflow = new Workflow(['id' => 'test', 'type' => 'test_type'], 'workflow');
|
||||
$workflow->getTypePlugin()->addState('published', 'Published');
|
||||
$workflow->getTypePlugin()->setStateWeight('published', 'foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::deleteState
|
||||
*/
|
||||
@@ -556,6 +566,17 @@ class WorkflowTest extends UnitTestCase {
|
||||
$workflow->getTypePlugin()->setTransitionWeight('draft-published', 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setTransitionWeight
|
||||
*/
|
||||
public function testSetTransitionWeightNonNumericException() {
|
||||
$this->setExpectedException(\InvalidArgumentException::class, "The weight 'foo' must be numeric for transition 'Publish'.");
|
||||
$workflow = new Workflow(['id' => 'test', 'type' => 'test_type'], 'workflow');
|
||||
$workflow->getTypePlugin()->addState('published', 'Published');
|
||||
$workflow->getTypePlugin()->addTransition('publish', 'Publish', [], 'published');
|
||||
$workflow->getTypePlugin()->setTransitionWeight('publish', 'foo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers ::setTransitionFromStates
|
||||
*/
|
||||
|
||||
@@ -6,8 +6,8 @@ description: 'Provides UI and API for managing workflows. This module can be use
|
||||
package: Core
|
||||
configure: entity.workflow.collection
|
||||
|
||||
# Information added by Drupal.org packaging script on 2018-01-03
|
||||
version: '8.4.4'
|
||||
# Information added by Drupal.org packaging script on 2018-03-07
|
||||
version: '8.5.0'
|
||||
core: '8.x'
|
||||
project: 'drupal'
|
||||
datestamp: 1515021228
|
||||
datestamp: 1520457825
|
||||
|
||||
Reference in New Issue
Block a user