Core and composer updates

This commit is contained in:
Rob Davies 2017-07-03 16:47:07 +01:00
parent a82634bb98
commit 62cac30480
1118 changed files with 21770 additions and 6306 deletions

View file

@ -20,16 +20,37 @@ use Drupal\workflows\WorkflowInterface;
* label_collection = @Translation("Workflows"),
* handlers = {
* "access" = "Drupal\workflows\WorkflowAccessControlHandler",
* "list_builder" = "Drupal\workflows\WorkflowListBuilder",
* "form" = {
* "add" = "Drupal\workflows\Form\WorkflowAddForm",
* "edit" = "Drupal\workflows\Form\WorkflowEditForm",
* "delete" = "Drupal\workflows\Form\WorkflowDeleteForm",
* "add-state" = "Drupal\workflows\Form\WorkflowStateAddForm",
* "edit-state" = "Drupal\workflows\Form\WorkflowStateEditForm",
* "delete-state" = "Drupal\workflows\Form\WorkflowStateDeleteForm",
* "add-transition" = "Drupal\workflows\Form\WorkflowTransitionAddForm",
* "edit-transition" = "Drupal\workflows\Form\WorkflowTransitionEditForm",
* "delete-transition" = "Drupal\workflows\Form\WorkflowTransitionDeleteForm",
* },
* "route_provider" = {
* "html" = "Drupal\Core\Entity\Routing\AdminHtmlRouteProvider",
* },
* }
* },
* config_prefix = "workflow",
* admin_permission = "administer workflows",
* entity_keys = {
* "id" = "id",
* "label" = "label",
* "uuid" = "uuid",
* },
* links = {
* "add-form" = "/admin/config/workflow/workflows/add",
* "edit-form" = "/admin/config/workflow/workflows/manage/{workflow}",
* "delete-form" = "/admin/config/workflow/workflows/manage/{workflow}/delete",
* "add-state-form" = "/admin/config/workflow/workflows/manage/{workflow}/add_state",
* "add-transition-form" = "/admin/config/workflow/workflows/manage/{workflow}/add_transition",
* "collection" = "/admin/config/workflow/workflows"
* },
* config_export = {
* "id",
* "label",
@ -243,14 +264,6 @@ class Workflow extends ConfigEntityBase implements WorkflowInterface, EntityWith
return $this;
}
/**
* {@inheritdoc}
*/
public function getInitialState() {
$ordered_states = $this->getStates();
return reset($ordered_states);
}
/**
* {@inheritdoc}
*/

View file

@ -145,4 +145,12 @@ abstract class WorkflowTypeBase extends PluginBase implements WorkflowTypeInterf
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getInitialState(WorkflowInterface $workflow) {
$ordered_states = $workflow->getStates();
return reset($ordered_states);
}
}

View file

@ -105,14 +105,6 @@ interface WorkflowInterface extends ConfigEntityInterface {
*/
public function deleteState($state_id);
/**
* Gets the initial state for the workflow.
*
* @return \Drupal\workflows\StateInterface
* The initial state.
*/
public function getInitialState();
/**
* Adds a transition to the workflow.
*

View file

@ -93,6 +93,17 @@ interface WorkflowTypeInterface extends PluginInspectionInterface, DerivativeIns
*/
public function deleteTransition($transition_id);
/**
* Gets the initial state for the workflow.
*
* @param \Drupal\workflows\WorkflowInterface $workflow
* The workflow entity.
*
* @return \Drupal\workflows\StateInterface
* The initial state.
*/
public function getInitialState(WorkflowInterface $workflow);
/**
* Builds a form to be added to the Workflow state edit form.
*

View file

@ -170,11 +170,11 @@ class WorkflowUiTest extends BrowserTestBase {
// Ensure that weight changes the state ordering.
$workflow = $workflow_storage->loadUnchanged('test');
$this->assertEquals('published', $workflow->getInitialState()->id());
$this->assertEquals('published', $workflow->getTypePlugin()->getInitialState($workflow)->id());
$this->drupalGet('admin/config/workflow/workflows/manage/test');
$this->submitForm(['states[draft][weight]' => '-1'], 'Save');
$workflow = $workflow_storage->loadUnchanged('test');
$this->assertEquals('draft', $workflow->getInitialState()->id());
$this->assertEquals('draft', $workflow->getTypePlugin()->getInitialState($workflow)->id());
// This will take us to the list of workflows, so we need to edit the
// workflow again.

View file

@ -257,25 +257,6 @@ class WorkflowTest extends UnitTestCase {
$workflow->deleteState('draft');
}
/**
* @covers ::getInitialState
*/
public function testGetInitialState() {
$workflow = new Workflow(['id' => 'test', 'type' => 'test_type'], 'workflow');
// By default states are ordered in the order added.
$workflow
->addState('draft', 'Draft')
->addState('published', 'Published')
->addState('archived', 'Archived');
$this->assertEquals('draft', $workflow->getInitialState()->id());
// Make published the first state.
$workflow->setStateWeight('published', -1);
$this->assertEquals('published', $workflow->getInitialState()->id());
}
/**
* @covers ::addTransition
* @covers ::hasTransition

View file

@ -7,17 +7,6 @@
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\workflows\Form\WorkflowAddForm;
use Drupal\workflows\Form\WorkflowEditForm;
use Drupal\workflows\Form\WorkflowDeleteForm;
use Drupal\workflows\Form\WorkflowStateAddForm;
use Drupal\workflows\Form\WorkflowStateEditForm;
use Drupal\workflows\Form\WorkflowStateDeleteForm;
use Drupal\workflows\Form\WorkflowTransitionAddForm;
use Drupal\workflows\Form\WorkflowTransitionEditForm;
use Drupal\workflows\Form\WorkflowTransitionDeleteForm;
use Drupal\workflows\WorkflowListBuilder;
/**
* Implements hook_help().
*/
@ -31,28 +20,3 @@ function workflows_help($route_name, RouteMatchInterface $route_match) {
return $output;
}
}
/**
* Implements hook_entity_type_build().
*/
function workflows_entity_type_build(array &$entity_types) {
/** @var $entity_types \Drupal\Core\Entity\EntityTypeInterface[] */
$entity_types['workflow']
->setFormClass('add', WorkflowAddForm::class)
->setFormClass('edit', WorkflowEditForm::class)
->setFormClass('delete', WorkflowDeleteForm::class)
->setFormClass('add-state', WorkflowStateAddForm::class)
->setFormClass('edit-state', WorkflowStateEditForm::class)
->setFormClass('delete-state', WorkflowStateDeleteForm::class)
->setFormClass('add-transition', WorkflowTransitionAddForm::class)
->setFormClass('edit-transition', WorkflowTransitionEditForm::class)
->setFormClass('delete-transition', WorkflowTransitionDeleteForm::class)
->setListBuilderClass(WorkflowListBuilder::class)
->set('admin_permission', 'administer workflows')
->setLinkTemplate('add-form', '/admin/config/workflow/workflows/add')
->setLinkTemplate('edit-form', '/admin/config/workflow/workflows/manage/{workflow}')
->setLinkTemplate('delete-form', '/admin/config/workflow/workflows/manage/{workflow}/delete')
->setLinkTemplate('add-state-form', '/admin/config/workflow/workflows/manage/{workflow}/add_state')
->setLinkTemplate('add-transition-form', '/admin/config/workflow/workflows/manage/{workflow}/add_transition')
->setLinkTemplate('collection', '/admin/config/workflow/workflows');
}

View file

@ -1,4 +1,4 @@
'administer workflows':
administer workflows:
title: 'Administer workflows'
description: 'Create and edit workflows.'
'restrict access': TRUE
restrict access: TRUE