Update to Drupal 8.2.6. For more information, see https://www.drupal.org/project/drupal/releases/8.2.6

This commit is contained in:
Pantheon Automation 2017-02-02 16:28:38 -08:00 committed by Greg Anderson
parent db56c09587
commit f1e72395cb
588 changed files with 26857 additions and 2777 deletions

View file

@ -66,13 +66,6 @@ views.argument.node_vid:
type: boolean
label: 'Exclude'
views.argument_default.node:
type: sequence
label: 'Content ID from URL'
sequence:
type: string
label: 'Nid'
views.field.node:
type: views_field
label: 'Node'

View file

@ -73,6 +73,11 @@ class NodePreviewForm extends FormBase {
$view_mode = $node->preview_view_mode;
$query_options = array('query' => array('uuid' => $node->uuid()));
$query = $this->getRequest()->query;
if ($query->has('destination')) {
$query_options['query']['destination'] = $query->get('destination');
}
$form['backlink'] = array(
'#type' => 'link',
'#title' => $this->t('Back to content editing'),
@ -80,9 +85,11 @@ class NodePreviewForm extends FormBase {
'#options' => array('attributes' => array('class' => array('node-preview-backlink'))) + $query_options,
);
$view_mode_options = $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle());
// Always show full as an option, even if the display is not enabled.
$view_mode_options = ['full' => $this->t('Full')] + $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle());
// Unset view modes that are not used in the front end.
unset($view_mode_options['default']);
unset($view_mode_options['rss']);
unset($view_mode_options['search_index']);
@ -116,10 +123,18 @@ class NodePreviewForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$form_state->setRedirect('entity.node.preview', array(
$route_parameters = [
'node_preview' => $form_state->getValue('uuid'),
'view_mode_id' => $form_state->getValue('view_mode'),
));
];
$options = [];
$query = $this->getRequest()->query;
if ($query->has('destination')) {
$options['query']['destination'] = $query->get('destination');
$query->remove('destination');
}
$form_state->setRedirect('entity.node.preview', $route_parameters, $options);
}
}

View file

@ -22,6 +22,9 @@ class NodeForm extends ContentEntityForm {
/**
* Whether this node has been previewed or not.
*
* @deprecated Scheduled for removal in Drupal 8.3.x. Use the form state
* property 'has_been_previewed' instead.
*/
protected $hasBeenPreviewed = FALSE;
@ -65,6 +68,8 @@ class NodeForm extends ContentEntityForm {
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
$this->hasBeenPreviewed = $form_state->get('has_been_previewed') ?: FALSE;
// Try to restore from temp store, this must be done before calling
// parent::form().
$store = $this->tempStoreFactory->get('node_preview');
@ -89,6 +94,7 @@ class NodeForm extends ContentEntityForm {
$this->entity = $preview->getFormObject()->getEntity();
$this->entity->in_preview = NULL;
$form_state->set('has_been_previewed', TRUE);
$this->hasBeenPreviewed = TRUE;
}
@ -231,7 +237,7 @@ class NodeForm extends ContentEntityForm {
$node = $this->entity;
$preview_mode = $node->type->entity->getPreviewMode();
$element['submit']['#access'] = $preview_mode != DRUPAL_REQUIRED || $this->hasBeenPreviewed;
$element['submit']['#access'] = $preview_mode != DRUPAL_REQUIRED || $form_state->get('has_been_previewed');
// If saving is an option, privileged users get dedicated form submit
// buttons to adjust the publishing status while saving in one go.
@ -338,10 +344,19 @@ class NodeForm extends ContentEntityForm {
$store = $this->tempStoreFactory->get('node_preview');
$this->entity->in_preview = TRUE;
$store->set($this->entity->uuid(), $form_state);
$form_state->setRedirect('entity.node.preview', array(
$route_parameters = [
'node_preview' => $this->entity->uuid(),
'view_mode_id' => 'default',
));
'view_mode_id' => 'full',
];
$options = [];
$query = $this->getRequest()->query;
if ($query->has('destination')) {
$options['query']['destination'] = $query->get('destination');
$query->remove('destination');
}
$form_state->setRedirect('entity.node.preview', $route_parameters, $options);
}
/**

View file

@ -6,6 +6,7 @@ use Drupal\comment\Tests\CommentTestTrait;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Language\LanguageInterface;
use Drupal\Core\Url;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
@ -195,7 +196,7 @@ class PagePreviewTest extends NodeTestBase {
->save();
$view_mode_edit = array('view_mode' => 'teaser');
$this->drupalPostForm('node/preview/' . $uuid . '/default', $view_mode_edit, t('Switch'));
$this->drupalPostForm('node/preview/' . $uuid . '/full', $view_mode_edit, t('Switch'));
$this->assertRaw('view-mode-teaser', 'View mode teaser class found.');
$this->assertNoText($edit[$body_key], 'Body not displayed.');
@ -292,6 +293,29 @@ class PagePreviewTest extends NodeTestBase {
$this->clickLink(t('Back to content editing'));
$this->assertRaw('edit-submit');
// Check that destination is remembered when clicking on preview. When going
// back to the edit form and clicking save, we should go back to the
// original destination, if set.
$destination = 'node';
$this->drupalPostForm($node->toUrl('edit-form'), [], t('Preview'), ['query' => ['destination' => $destination]]);
$parameters = ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'];
$options = ['absolute' => TRUE, 'query' => ['destination' => $destination]];
$this->assertUrl(Url::fromRoute('entity.node.preview', $parameters, $options));
$this->drupalPostForm(NULL, ['view_mode' => 'teaser'], t('Switch'));
$this->clickLink(t('Back to content editing'));
$this->drupalPostForm(NULL, [], t('Save'));
$this->assertUrl($destination);
// Check that preview page works as expected without a destination set.
$this->drupalPostForm($node->toUrl('edit-form'), [], t('Preview'));
$parameters = ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'];
$this->assertUrl(Url::fromRoute('entity.node.preview', $parameters, ['absolute' => TRUE]));
$this->drupalPostForm(NULL, ['view_mode' => 'teaser'], t('Switch'));
$this->clickLink(t('Back to content editing'));
$this->drupalPostForm(NULL, [], t('Save'));
$this->assertUrl($node->toUrl());
$this->assertResponse(200);
// Assert multiple items can be added and are not lost when previewing.
$test_image_1 = current($this->drupalGetTestFiles('image', 39325));
$edit_image_1['files[field_image_0][]'] = drupal_realpath($test_image_1->uri);
@ -418,7 +442,7 @@ class PagePreviewTest extends NodeTestBase {
/** @var \Drupal\Core\Controller\ControllerResolverInterface $controller_resolver */
$controller_resolver = \Drupal::service('controller_resolver');
$node_preview_controller = $controller_resolver->getControllerFromDefinition('\Drupal\node\Controller\NodePreviewController::view');
$node_preview_controller($node, 'default');
$node_preview_controller($node, 'full');
}
/**
@ -439,7 +463,7 @@ class PagePreviewTest extends NodeTestBase {
$edit2 = array($title_key => 'Another page title');
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit2, t('Preview'));
$this->assertUrl(\Drupal::url('entity.node.preview', ['node_preview' => $node->uuid(), 'view_mode_id' => 'default'], ['absolute' => TRUE]));
$this->assertUrl(\Drupal::url('entity.node.preview', ['node_preview' => $node->uuid(), 'view_mode_id' => 'full'], ['absolute' => TRUE]));
$this->assertText($edit2[$title_key]);
}