Commit 40f818bb authored by webchick's avatar webchick

Issue #2221755 by grom358, ianthomas_uk: Remove uses of deprecated Element functions.

parent be83ed2b
......@@ -5,6 +5,8 @@
* Helper functions and form handlers used for the authorize.php script.
*/
use Drupal\Core\Render\Element;
/**
* Form constructor for the file transfer authorization form.
*
......@@ -180,7 +182,7 @@ function _authorize_filetransfer_connection_settings_set_defaults(&$element, $ke
// there's a subarray of settings for the form key we're currently
// processing, pass in that subarray to the recursive call. Otherwise, just
// pass on the whole $defaults array.
foreach (element_children($element) as $child_key) {
foreach (Element::children($element) as $child_key) {
_authorize_filetransfer_connection_settings_set_defaults($element[$child_key], $child_key, ((isset($defaults[$key]) && is_array($defaults[$key])) ? $defaults[$key] : $defaults));
}
}
......
......@@ -3318,7 +3318,7 @@ function drupal_pre_render_link($element) {
*/
function drupal_pre_render_links($element) {
$element += array('#links' => array(), '#attached' => array());
foreach (element_children($element) as $key) {
foreach (Element::children($element) as $key) {
$child = &$element[$key];
// If the child has links which have not been printed yet and the user has
// access to it, merge its links in to the parent.
......@@ -3493,9 +3493,10 @@ function drupal_render_page($page) {
* #pre_render functions have been called, #printed is checked a second time
* in case a #pre_render function flags the element as printed.
* - The child elements of this element are sorted by weight using uasort() in
* element_children(). Since this is expensive, when passing already sorted
* elements to drupal_render(), for example from a database query, set
* $elements['#sorted'] = TRUE to avoid sorting them a second time.
* \Drupal\Core\Render\Element::children(). Since this is expensive, when
* passing already sorted elements to drupal_render(), for example from a
* database query, set $elements['#sorted'] = TRUE to avoid sorting them a
* second time.
* - The main render phase to produce #children for this element takes place:
* - If this element has #theme defined and #theme is an implemented theme
* hook/suggestion then _theme() is called and must render both the element
......@@ -3777,7 +3778,8 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
* The structured array whose children shall be rendered.
* @param array $children_keys
* (optional) If the keys of the element's children are already known, they
* can be passed in to save another run of element_children().
* can be passed in to save another run of
* \Drupal\Core\Render\Element::children().
*
* @return string
* The rendered HTML of all children of the element.
......@@ -3786,7 +3788,7 @@ function drupal_render(&$elements, $is_recursive_call = FALSE) {
*/
function drupal_render_children(&$element, $children_keys = NULL) {
if ($children_keys === NULL) {
$children_keys = element_children($element);
$children_keys = Element::children($element);
}
$output = '';
foreach ($children_keys as $key) {
......@@ -4154,7 +4156,7 @@ function drupal_render_collect_post_render_cache(array &$elements, array $callba
// Collect the #post_render_cache callbacks for all child elements, unless
// we've already collected them above by retrieving this element (and its
// children) from the render cache.
if (!$retrieved_from_cache && $children = element_children($elements)) {
if (!$retrieved_from_cache && $children = Element::children($elements)) {
foreach ($children as $child) {
$callbacks = drupal_render_collect_post_render_cache($elements[$child], $callbacks, FALSE);
}
......@@ -4186,7 +4188,7 @@ function drupal_render_collect_attached($elements, $return = FALSE) {
if (isset($elements['#attached'])) {
$attached = drupal_merge_attached($attached, $elements['#attached']);
}
if ($children = element_children($elements)) {
if ($children = Element::children($elements)) {
foreach ($children as $child) {
drupal_render_collect_attached($elements[$child]);
}
......@@ -4236,7 +4238,7 @@ function drupal_render_collect_cache_tags($element, $tags = array()) {
}
}
}
if ($children = element_children($element)) {
if ($children = Element::children($element)) {
foreach ($children as $child) {
$tags = drupal_render_collect_cache_tags($element[$child], $tags);
}
......
......@@ -12,6 +12,7 @@
use Drupal\Component\Utility\Xss;
use Drupal\Core\Database\Database;
use Drupal\Core\Language\Language;
use Drupal\Core\Render\Element;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Utility\Color;
use Symfony\Component\HttpFoundation\RedirectResponse;
......@@ -893,7 +894,7 @@ function form_process_select($element) {
*/
function template_preprocess_select(&$variables) {
$element = $variables['element'];
element_set_attributes($element, array('id', 'name', 'size'));
Element::setAttributes($element, array('id', 'name', 'size'));
_form_set_attributes($element, array('form-select'));
$variables['attributes'] = $element['#attributes'];
......@@ -1014,7 +1015,7 @@ function form_get_options($element, $key) {
*/
function template_preprocess_fieldset(&$variables) {
$element = $variables['element'];
element_set_attributes($element, array('id'));
Element::setAttributes($element, array('id'));
_form_set_attributes($element, array('form-wrapper'));
$variables['attributes'] = $element['#attributes'];
$variables['attributes']['class'][] = 'form-item';
......@@ -1103,7 +1104,7 @@ function template_preprocess_details(&$variables) {
*/
function form_pre_render_radio($element) {
$element['#attributes']['type'] = 'radio';
element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
Element::setAttributes($element, array('id', 'name', '#return_value' => 'value'));
if (isset($element['#return_value']) && $element['#value'] !== FALSE && $element['#value'] == $element['#return_value']) {
$element['#attributes']['checked'] = 'checked';
......@@ -1213,7 +1214,7 @@ function theme_date($variables) {
if (empty($element['attribute']['type'])) {
$element['attribute']['type'] = 'date';
}
element_set_attributes($element, array('id', 'name', 'type', 'min', 'max', 'step', 'value', 'size'));
Element::setAttributes($element, array('id', 'name', 'type', 'min', 'max', 'step', 'value', 'size'));
_form_set_attributes($element, array('form-' . $element['attribute']['type']));
return '<input' . new Attribute($element['#attributes']) . ' />';
......@@ -1280,7 +1281,7 @@ function form_process_radios($element) {
*/
function form_pre_render_checkbox($element) {
$element['#attributes']['type'] = 'checkbox';
element_set_attributes($element, array('id', 'name', '#return_value' => 'value'));
Element::setAttributes($element, array('id', 'name', '#return_value' => 'value'));
// Unchecked checkbox has #value of integer 0.
if (!empty($element['#checked'])) {
......@@ -1459,7 +1460,7 @@ function form_process_actions($element, &$form_state) {
*/
function form_pre_render_actions_dropbutton(array $element) {
$dropbuttons = array();
foreach (element_children($element, TRUE) as $key) {
foreach (Element::children($element, TRUE) as $key) {
if (isset($element[$key]['#dropbutton'])) {
$dropbutton = $element[$key]['#dropbutton'];
// If there is no dropbutton for this button group yet, create one.
......@@ -1604,7 +1605,7 @@ function theme_tableselect($variables) {
$header = $element['#header'];
if (!empty($element['#options'])) {
// Generate a table row for each selectable item in #options.
foreach (element_children($element) as $key) {
foreach (Element::children($element) as $key) {
$row = array();
$row['data'] = array();
......@@ -1776,7 +1777,7 @@ function form_process_table($element, &$form_state) {
// Create a checkbox or radio for each row in a way that the value of the
// tableselect element behaves as if it had been of #type checkboxes or
// radios.
foreach (element_children($element) as $key) {
foreach (Element::children($element) as $key) {
$row = &$element[$key];
// Prepare the element #parents for the tableselect form element.
// Their values have to be located in child keys (#tree is ignored), since
......@@ -1806,7 +1807,7 @@ function form_process_table($element, &$form_state) {
$title = $row['title']['#title'];
}
else {
foreach (element_children($row) as $column) {
foreach (Element::children($row) as $column) {
if (isset($row[$column]['#title'])) {
$title = $row[$column]['#title'];
break;
......@@ -2076,7 +2077,7 @@ function form_process_group(&$element, &$form_state) {
* The modified element.
*/
function form_pre_render_details($element) {
element_set_attributes($element, array('id'));
Element::setAttributes($element, array('id'));
// The .form-wrapper class is required for #states to treat details like
// containers.
......@@ -2091,7 +2092,7 @@ function form_pre_render_details($element) {
// Do not render optional details elements if there are no children.
if (isset($element['#parents'])) {
$group = implode('][', $element['#parents']);
if (!empty($element['#optional']) && !element_get_visible_children($element['#groups'][$group])) {
if (!empty($element['#optional']) && !Element::getVisibleChildren($element['#groups'][$group])) {
$element['#printed'] = TRUE;
}
}
......@@ -2117,7 +2118,7 @@ function form_pre_render_group($element) {
// Inject group member elements belonging to this group.
$parents = implode('][', $element['#parents']);
$children = element_children($element['#groups'][$parents]);
$children = Element::children($element['#groups'][$parents]);
if (!empty($children)) {
foreach ($children as $key) {
// Break references and indicate that the element should be rendered as
......@@ -2151,7 +2152,7 @@ function form_pre_render_group($element) {
}
// Otherwise, this element belongs to a group and the group exists, so we do
// not render it.
elseif (element_children($element['#groups'][$group])) {
elseif (Element::children($element['#groups'][$group])) {
$element['#printed'] = TRUE;
}
}
......@@ -2218,7 +2219,7 @@ function form_process_vertical_tabs($element, &$form_state) {
function form_pre_render_vertical_tabs($element) {
// Do not render the vertical tabs element if it is empty.
$group = implode('][', $element['#parents']);
if (!element_get_visible_children($element['group']['#groups'][$group])) {
if (!Element::getVisibleChildren($element['group']['#groups'][$group])) {
$element['#printed'] = TRUE;
}
return $element;
......@@ -2326,7 +2327,7 @@ function theme_input($variables) {
*/
function form_pre_render_button($element) {
$element['#attributes']['type'] = 'submit';
element_set_attributes($element, array('id', 'name', 'value'));
Element::setAttributes($element, array('id', 'name', 'value'));
$element['#attributes']['class'][] = 'button';
if (!empty($element['#button_type'])) {
......@@ -2357,7 +2358,7 @@ function form_pre_render_button($element) {
*/
function form_pre_render_image_button($element) {
$element['#attributes']['type'] = 'image';
element_set_attributes($element, array('id', 'name', 'value'));
Element::setAttributes($element, array('id', 'name', 'value'));
$element['#attributes']['src'] = file_create_url($element['#src']);
if (!empty($element['#title'])) {
......@@ -2391,7 +2392,7 @@ function form_pre_render_image_button($element) {
*/
function form_pre_render_hidden($element) {
$element['#attributes']['type'] = 'hidden';
element_set_attributes($element, array('name', 'value'));
Element::setAttributes($element, array('name', 'value'));
return $element;
}
......@@ -2409,7 +2410,7 @@ function form_pre_render_hidden($element) {
*/
function form_pre_render_textfield($element) {
$element['#attributes']['type'] = 'text';
element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
_form_set_attributes($element, array('form-text'));
return $element;
......@@ -2428,7 +2429,7 @@ function form_pre_render_textfield($element) {
*/
function form_pre_render_email($element) {
$element['#attributes']['type'] = 'email';
element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
_form_set_attributes($element, array('form-email'));
return $element;
......@@ -2461,7 +2462,7 @@ function form_validate_email(&$element, &$form_state) {
*/
function form_pre_render_tel($element) {
$element['#attributes']['type'] = 'tel';
element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
_form_set_attributes($element, array('form-tel'));
return $element;
......@@ -2480,7 +2481,7 @@ function form_pre_render_tel($element) {
*/
function form_pre_render_number($element) {
$element['#attributes']['type'] = 'number';
element_set_attributes($element, array('id', 'name', 'value', 'step', 'min', 'max', 'placeholder', 'size'));
Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max', 'placeholder', 'size'));
_form_set_attributes($element, array('form-number'));
return $element;
......@@ -2499,7 +2500,7 @@ function form_pre_render_number($element) {
*/
function form_pre_render_range($element) {
$element['#attributes']['type'] = 'range';
element_set_attributes($element, array('id', 'name', 'value', 'step', 'min', 'max'));
Element::setAttributes($element, array('id', 'name', 'value', 'step', 'min', 'max'));
_form_set_attributes($element, array('form-range'));
return $element;
......@@ -2588,7 +2589,7 @@ function form_type_range_value($element, $input = FALSE) {
*/
function form_pre_render_url($element) {
$element['#attributes']['type'] = 'url';
element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
_form_set_attributes($element, array('form-url'));
return $element;
......@@ -2607,7 +2608,7 @@ function form_pre_render_url($element) {
*/
function form_pre_render_search($element) {
$element['#attributes']['type'] = 'search';
element_set_attributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
Element::setAttributes($element, array('id', 'name', 'value', 'size', 'maxlength', 'placeholder'));
_form_set_attributes($element, array('form-search'));
return $element;
......@@ -2661,7 +2662,7 @@ function form_validate_color(&$element, &$form_state) {
*/
function form_pre_render_color($element) {
$element['#attributes']['type'] = 'color';
element_set_attributes($element, array('id', 'name', 'value'));
Element::setAttributes($element, array('id', 'name', 'value'));
_form_set_attributes($element, array('form-color'));
return $element;
......@@ -2682,7 +2683,7 @@ function template_preprocess_form(&$variables) {
if (isset($element['#action'])) {
$element['#attributes']['action'] = UrlHelper::stripDangerousProtocols($element['#action']);
}
element_set_attributes($element, array('method', 'id'));
Element::setAttributes($element, array('method', 'id'));
if (empty($element['#attributes']['accept-charset'])) {
$element['#attributes']['accept-charset'] = "UTF-8";
}
......@@ -2704,7 +2705,7 @@ function template_preprocess_form(&$variables) {
*/
function template_preprocess_textarea(&$variables) {
$element = $variables['element'];
element_set_attributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
Element::setAttributes($element, array('id', 'name', 'rows', 'cols', 'placeholder'));
_form_set_attributes($element, array('form-textarea'));
$variables['wrapper_attributes'] = new Attribute(array(
'class' => array('form-textarea-wrapper'),
......@@ -2733,7 +2734,7 @@ function template_preprocess_textarea(&$variables) {
*/
function form_pre_render_password($element) {
$element['#attributes']['type'] = 'password';
element_set_attributes($element, array('id', 'name', 'size', 'maxlength', 'placeholder'));
Element::setAttributes($element, array('id', 'name', 'size', 'maxlength', 'placeholder'));
_form_set_attributes($element, array('form-text'));
return $element;
......@@ -2782,7 +2783,7 @@ function form_process_weight($element) {
*/
function form_pre_render_file($element) {
$element['#attributes']['type'] = 'file';
element_set_attributes($element, array('id', 'name', 'size'));
Element::setAttributes($element, array('id', 'name', 'size'));
_form_set_attributes($element, array('form-file'));
return $element;
......
......@@ -8,6 +8,7 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Language\Language;
use Drupal\Core\Render\Element;
use Drupal\Core\Template\Attribute;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
......@@ -553,7 +554,7 @@ function menu_local_tasks($level = 0) {
function menu_primary_local_tasks() {
$links = menu_local_tasks(0);
// Do not display single tabs.
return count(element_get_visible_children($links['tabs'])) > 1 ? $links['tabs'] : '';
return count(Element::getVisibleChildren($links['tabs'])) > 1 ? $links['tabs'] : '';
}
/**
......@@ -562,7 +563,7 @@ function menu_primary_local_tasks() {
function menu_secondary_local_tasks() {
$links = menu_local_tasks(1);
// Do not display single tabs.
return count(element_get_visible_children($links['tabs'])) > 1 ? $links['tabs'] : '';
return count(Element::getVisibleChildren($links['tabs'])) > 1 ? $links['tabs'] : '';
}
/**
......
......@@ -1323,7 +1323,7 @@ function template_preprocess_image(&$variables) {
* @see drupal_attach_tabledrag()
*/
function drupal_pre_render_table(array $element) {
foreach (element_children($element) as $first) {
foreach (Element::children($element) as $first) {
$row = array('data' => array());
// Apply attributes of first-level elements as table row attributes.
if (isset($element[$first]['#attributes'])) {
......@@ -1332,7 +1332,7 @@ function drupal_pre_render_table(array $element) {
// Turn second-level elements into table row columns.
// @todo Do not render a cell for children of #type 'value'.
// @see http://drupal.org/node/1248940
foreach (element_children($element[$first]) as $second) {
foreach (Element::children($element[$first]) as $second) {
// Assign the element by reference, so any potential changes to the
// original element are taken over.
$column = array('data' => &$element[$first][$second]);
......@@ -1349,7 +1349,7 @@ function drupal_pre_render_table(array $element) {
}
// Take over $element['#id'] as HTML ID attribute, if not already set.
element_set_attributes($element, array('id'));
Element::setAttributes($element, array('id'));
// Add sticky headers, if applicable.
......@@ -1682,8 +1682,9 @@ function template_preprocess_item_list(&$variables) {
// child elements of the nested list, instead of #items. For
// convenience, we automatically move them into #items.
if (!isset($child['#items'])) {
// This is the same condition as in element_children(), which cannot
// be used here, since it triggers an error on string values.
// This is the same condition as in
// \Drupal\Core\Render\Element::children(), which cannot be used
// here, since it triggers an error on string values.
foreach ($child as $child_key => $child_value) {
if ($child_key[0] !== '#') {
$child['#items'][$child_key] = $child_value;
......@@ -2405,9 +2406,9 @@ function template_preprocess_field(&$variables, $hook) {
// We want other preprocess functions and the theme implementation to have
// fast access to the field item render arrays. The item render array keys
// (deltas) should always be numerically indexed starting from 0, and looping
// on those keys is faster than calling element_children() or looping on all
// keys within $element, since that requires traversal of all element
// properties.
// on those keys is faster than calling
// \Drupal\Core\Render\Element::children() or looping on all keys within
// $element, since that requires traversal of all element properties.
$variables['items'] = array();
$delta = 0;
while (!empty($element[$delta])) {
......
......@@ -39,7 +39,7 @@ public static function sortByWeightElement(array $a, array $b) {
/**
* Sorts a structured array by '#weight' property.
*
* Callback for uasort() within element_children().
* Callback for uasort() within \Drupal\Core\Render\Element::children().
*
* @param array $a
* First item for comparison. The compared items should be associative
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Form\FormBase;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Render\Element;
/**
* Base class for entity form controllers.
......@@ -186,7 +187,7 @@ protected function actionsElement(array $form, array &$form_state) {
}
$count = 0;
foreach (element_children($element) as $action) {
foreach (Element::children($element) as $action) {
$element[$action] += array(
'#type' => 'submit',
'#weight' => ++$count * 5,
......
......@@ -95,7 +95,7 @@ public static function children(array &$elements, $sort = FALSE) {
uasort($children, 'Drupal\Component\Utility\SortArray::sortByWeightProperty');
// Put the sorted children back into $elements in the correct order, to
// preserve sorting if the same element is passed through
// element_children() twice.
// \Drupal\Core\Render\Element::children() twice.
foreach ($children as $key => $child) {
unset($elements[$key]);
$elements[$key] = $child;
......
......@@ -6,6 +6,7 @@
*/
use Drupal\Component\Utility\String;
use Drupal\Core\Render\Element;
/**
* Prepares variables for aggregator item templates.
......@@ -86,7 +87,7 @@ function theme_aggregator_page_opml($variables) {
function template_preprocess_aggregator_summary_items(&$variables) {
$variables['title'] = String::checkPlain($variables['source']->label());
$summary_items = array();
foreach (element_children($variables['summary_items']) as $key) {
foreach (Element::children($variables['summary_items']) as $key) {
$summary_items[] = $variables['summary_items'][$key];
}
$variables['summary_list'] = array(
......
......@@ -5,6 +5,8 @@
* Administration page callbacks for the Book module.
*/
use Drupal\Core\Render\Element;
/**
* Returns HTML for a book administration form.
*
......@@ -23,7 +25,7 @@ function theme_book_admin_table($variables) {
$rows = array();
$destination = drupal_get_destination();
$access = \Drupal::currentUser()->hasPermission('administer nodes');
foreach (element_children($form) as $key) {
foreach (Element::children($form) as $key) {
$nid = $form[$key]['nid']['#value'];
$href = \Drupal::url('node.view', array('node' => $nid));
......
......@@ -8,6 +8,7 @@
use Drupal\book\BookManagerInterface;
use Drupal\Component\Utility\String;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Render\Element;
use Drupal\node\NodeInterface;
use Drupal\node\NodeTypeInterface;
use Drupal\Core\Language\Language;
......@@ -384,7 +385,7 @@ function template_preprocess_book_all_books_block(&$variables) {
// Remove all non-renderable elements.
$elements = $variables['book_menus'];
$variables['book_menus'] = array();
foreach (element_children($elements) as $index) {
foreach (Element::children($elements) as $index) {
$variables['book_menus'][$index] = $elements[$index];
}
}
......
......@@ -11,6 +11,7 @@
use Drupal\Component\Utility\Crypt;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Render\Element;
use Drupal\node\NodeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -97,7 +98,7 @@ public function submitForm(array &$form, array &$form_state) {
$order = array_flip(array_keys($form_state['input']['table']));
$form['table'] = array_merge($order, $form['table']);
foreach (element_children($form['table']) as $key) {
foreach (Element::children($form['table']) as $key) {
if ($form['table'][$key]['#item']) {
$row = $form['table'][$key];
$values = $form_state['values']['table'][$key];
......
......@@ -12,6 +12,7 @@
use Drupal\ckeditor\CKEditorPluginManager;
use Drupal\Core\Language\Language;
use Drupal\Core\Language\LanguageManager;
use Drupal\Core\Render\Element;
use Drupal\editor\Plugin\EditorBase;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\editor\Entity\Editor as EditorEntity;
......@@ -165,7 +166,7 @@ public function settingsForm(array $form, array &$form_state, EditorEntity $edit
),
);
$this->ckeditorPluginManager->injectPluginSettingsForm($form, $form_state, $editor);
if (count(element_children($form['plugins'])) === 0) {
if (count(Element::children($form['plugins'])) === 0) {
unset($form['plugins']);
unset($form['plugin_settings']);
}
......
......@@ -14,6 +14,7 @@
use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
use Drupal\Core\Render\Element;
use Drupal\Core\Url;
use Drupal\field\FieldInstanceConfigInterface;
use Drupal\field\FieldConfigInterface;
......@@ -1387,7 +1388,7 @@ function template_preprocess_comment(&$variables) {
}
// Helpful $content variable for templates.
foreach (element_children($variables['elements']) as $key) {
foreach (Element::children($variables['elements']) as $key) {
$variables['content'][$key] = $variables['elements'][$key];
}
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityViewBuilder;
use Drupal\Component\Utility\String;
use Drupal\Core\Render\Element;
/**
* Render controller for contact messages.
......@@ -44,7 +45,7 @@ public function view(EntityInterface $entity, $view_mode = 'full', $langcode = N
if ($view_mode == 'mail') {
// Convert field labels into headings.
// @todo Improve drupal_html_to_text() to convert DIVs correctly.
foreach (element_children($build) as $key) {
foreach (Element::children($build) as $key) {
if (isset($build[$key]['#label_display']) && $build[$key]['#label_display'] == 'above') {
$build[$key] += array('#prefix' => '');
$build[$key]['#prefix'] = $build[$key]['#title'] . ":\n";
......
......@@ -8,6 +8,7 @@
use Drupal\Component\Utility\String;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Render\Element;
use Drupal\field\Field as FieldService;
use Drupal\field\FieldInstanceConfigInterface;
......@@ -157,8 +158,8 @@ function _content_translation_preprocess_language_content_settings_table(&$varia
array_unshift($build['#header'], array('data' => t('Translatable'), 'class' => array('translatable')));
$rows = array();
foreach (element_children($element) as $bundle) {
$field_names = !empty($element[$bundle]['fields']) ? element_children($element[$bundle]['fields']) : array();
foreach (Element::children($element) as $bundle) {
$field_names = !empty($element[$bundle]['fields']) ? Element::children($element[$bundle]['fields']) : array();
if (!empty($element[$bundle]['translatable'])) {
$checkbox_id = $element[$bundle]['translatable']['#id'];
}
......@@ -213,7 +214,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia
if (!empty($element[$bundle]['columns'][$field_name])) {
$column_element = &$element[$bundle]['columns'][$field_name];
foreach (element_children($column_element) as $key) {
foreach (Element::children($column_element) as $key) {
$column_label = $column_element[$key]['#title'];
unset($column_element[$key]['#title']);
$rows[] = array(
......
......@@ -10,6 +10,7 @@
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\Language;
use Drupal\Core\Render\Element;
/**
* Base class for content translation controllers.
......@@ -292,7 +293,7 @@ public function entityFormSharedElements($element, $form_state, $form) {
$ignored_types = array_flip(array('actions', 'value', 'hidden', 'vertical_tabs', 'token', 'details'));
}
foreach (element_children($element) as $key) {
foreach (Element::children($element) as $key) {
if (!isset($element[$key]['#type'])) {
$this->entityFormSharedElements($element[$key], $form_state, $form);
}
......@@ -345,7 +346,7 @@ protected function addTranslatabilityClue(&$element) {
$element['#title'] .= $suffix;
}
// If the current element does not have a (valid) title, try child elements.
elseif ($children = element_children($element)) {
elseif ($children = Element::children($element)) {
foreach ($children as $delta) {
$this->addTranslatabilityClue($element[$delta], $suffix);
}
......
......@@ -13,6 +13,7 @@
use Drupal\Core\Entity\EntityChangedInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Render\Element;
use Drupal\entity\Entity\EntityFormDisplay;
use Drupal\user\TempStoreFactory;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -214,7 +215,7 @@ protected function simplify(array &$form, array &$form_state) {
// with per-delta elements. Skip single checkboxes, because their title is
// key to their UI. Also skip widgets with multiple subelements, because in
// that case, per-element labeling is informative.
$num_children = count(element_children($widget_element));
$num_children = count(Element::children($widget_element));
if ($num_children == 0 && $widget_element['#type'] != 'checkbox') {
$widget_element['#title_display'] = 'invisible';
}
......
......@@ -7,6 +7,7 @@
use Drupal\Component\Utility\Html;
use Drupal\Core\Entity\ContentEntityInterface;