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

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -122,4 +122,40 @@ class Checkboxes extends FormElement {
}
}
/**
* Determines which checkboxes were checked when a form is submitted.
*
* @param array $input
* An array returned by the FormAPI for a set of checkboxes.
*
* @return array
* An array of keys that were checked.
*/
public static function getCheckedCheckboxes(array $input) {
// Browsers do not include unchecked options in a form submission. The
// FormAPI tries to normalize this to keep checkboxes consistent with other
// form elements. Checkboxes show up as an array in the form of option_id =>
// option_id|0, where integer 0 is an unchecked option.
//
// @see \Drupal\Core\Render\Element\Checkboxes::valueCallback()
// @see https://www.w3.org/TR/html401/interact/forms.html#checkbox
$checked = array_filter($input, function($value) {
return $value !== 0;
});
return array_keys($checked);
}
/**
* Determines if all checkboxes in a set are unchecked.
*
* @param array $input
* An array returned by the FormAPI for a set of checkboxes.
*
* @return bool
* TRUE if all options are unchecked. FALSE otherwise.
*/
public static function detectEmptyCheckboxes(array $input) {
return empty(static::getCheckedCheckboxes($input));
}
}

View file

@ -18,7 +18,7 @@ use Drupal\Core\Render\Element;
* Usage example:
* @code
* $form['quantity'] = array(
* '#type' => 'number',
* '#type' => 'range',
* '#title' => $this->t('Quantity'),
* );
* @endcode

View file

@ -45,12 +45,15 @@ class StatusMessages extends RenderElement {
* The updated renderable array containing the placeholder.
*/
public static function generatePlaceholder(array $element) {
$element['messages_placeholder'] = [
$element = [
'#lazy_builder' => [get_class() . '::renderMessages', [$element['#display']]],
'#create_placeholder' => TRUE,
];
return $element;
// Directly create a placeholder as we need this to be placeholdered
// regardless if this is a POST or GET request.
// @todo remove this when https://www.drupal.org/node/2367555 lands.
return \Drupal::service('render_placeholder_generator')->createPlaceholder($element);
}
/**

View file

@ -54,7 +54,7 @@ class PageDisplayVariantSelectionEvent extends Event implements RefinableCacheab
/**
* Constructs the page display variant plugin selection event.
*
* @param string
* @param string $plugin_id
* The ID of the page display variant plugin to use by default.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match, for context.

View file

@ -10,8 +10,6 @@ namespace Drupal\Core\Render;
* @see \Drupal\Core\Render\RendererInterface
* @see \Drupal\Core\Render\Renderer
* @see \Drupal\Core\Render\BubbleableMetadata
*
* @internal
*/
class RenderContext extends \SplStack {

View file

@ -365,11 +365,6 @@ class Renderer implements RendererInterface {
$elements['#lazy_builder_built'] = TRUE;
}
// All render elements support #markup and #plain_text.
if (!empty($elements['#markup']) || !empty($elements['#plain_text'])) {
$elements = $this->ensureMarkupIsSafe($elements);
}
// Make any final changes to the element before it is rendered. This means
// that the $element or the children can be altered or corrected before the
// element is rendered into the final text.
@ -382,6 +377,11 @@ class Renderer implements RendererInterface {
}
}
// All render elements support #markup and #plain_text.
if (!empty($elements['#markup']) || !empty($elements['#plain_text'])) {
$elements = $this->ensureMarkupIsSafe($elements);
}
// Defaults for bubbleable rendering metadata.
$elements['#cache']['tags'] = isset($elements['#cache']['tags']) ? $elements['#cache']['tags'] : array();
$elements['#cache']['max-age'] = isset($elements['#cache']['max-age']) ? $elements['#cache']['max-age'] : Cache::PERMANENT;
@ -733,7 +733,7 @@ class Renderer implements RendererInterface {
*
* @see \Drupal\Component\Utility\Html::escape()
* @see \Drupal\Component\Utility\Xss::filter()
* @see \Drupal\Component\Utility\Xss::adminFilter()
* @see \Drupal\Component\Utility\Xss::filterAdmin()
*/
protected function ensureMarkupIsSafe(array $elements) {
if (empty($elements['#markup']) && empty($elements['#plain_text'])) {

View file

@ -555,7 +555,7 @@ function hook_form_system_theme_settings_alter(&$form, \Drupal\Core\Form\FormSta
* The name of the theme hook.
*/
function hook_preprocess(&$variables, $hook) {
static $hooks;
static $hooks;
// Add contextual links to the variables, if the user has permission.