Commit 78b48c89 authored by catch's avatar catch

Issue #2092095 by tstoeckler, ParisLiakos: Remove \Drupal\Component\Utility\MapArray.

parent 53068d07
......@@ -16,7 +16,6 @@
use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Exception\ParseException;
use Drupal\Component\PhpStorage\PhpStorageFactory;
use Drupal\Component\Utility\MapArray;
use Drupal\Component\Utility\NestedArray;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\Core\Routing\GeneratorNotInitializedException;
......@@ -1290,15 +1289,6 @@ function l($text, $path, array $options = array()) {
return '<a href="' . $url . '"' . $attributes . '>' . $text . '</a>';
}
/**
* Forms an associative array from a linear array.
*
* @see \Drupal\Component\Utility\MapArray::copyValuesToKeys()
*/
function drupal_map_assoc($array, $callable = NULL) {
return MapArray::copyValuesToKeys($array, $callable);
}
/**
* Attempts to set the PHP maximum execution time.
*
......
......@@ -559,7 +559,7 @@ function form_type_checkboxes_value($element, $input = FALSE) {
unset($input[$key]);
}
}
return drupal_map_assoc($input);
return array_combine($input, $input);
}
else {
return array();
......@@ -588,10 +588,11 @@ function form_type_table_value(array $element, $input = FALSE) {
// @todo D8: Remove this inconsistency.
if ($input === FALSE) {
$element += array('#default_value' => array());
return drupal_map_assoc(array_keys(array_filter($element['#default_value'])));
$value = array_keys(array_filter($element['#default_value']));
return array_combine($value, $value);
}
else {
return is_array($input) ? drupal_map_assoc($input) : array();
return is_array($input) ? array_combine($input, $input) : array();
}
}
}
......@@ -666,7 +667,7 @@ function form_type_tableselect_value($element, $input = FALSE) {
return $value;
}
else {
return is_array($input) ? drupal_map_assoc($input) : array();
return is_array($input) ? array_combine($input, $input) : array();
}
}
}
......@@ -711,7 +712,7 @@ function form_type_select_value($element, $input = FALSE) {
// unselected. A disabled multi-select always submits NULL, and the
// default value should be used.
if (empty($element['#disabled'])) {
return (is_array($input)) ? drupal_map_assoc($input) : array();
return (is_array($input)) ? array_combine($input, $input) : array();
}
else {
return (isset($element['#default_value']) && is_array($element['#default_value'])) ? $element['#default_value'] : array();
......
......@@ -17,7 +17,6 @@
use Drupal\Core\Template\RenderWrapper;
use Drupal\Core\Theme\ThemeSettings;
use Drupal\Component\Utility\NestedArray;
use Drupal\Component\Utility\MapArray;
use Drupal\Core\Render\Element;
/**
......@@ -1291,10 +1290,11 @@ function template_preprocess_links(&$variables) {
// Use the array key as class name.
$li_attributes['class'][] = drupal_html_class($key);
$keys = array('title', 'href', 'route_name', 'route_parameters');
$link_element = array(
'#type' => 'link',
'#title' => $link['title'],
'#options' => array_diff_key($link, MapArray::copyValuesToKeys(array('title', 'href', 'route_name', 'route_parameters'))),
'#options' => array_diff_key($link, array_combine($keys, $keys)),
'#href' => $link['href'],
'#route_name' => $link['route_name'],
'#route_parameters' => $link['route_parameters'],
......
......@@ -434,7 +434,7 @@ function update_get_update_list() {
continue;
}
$updates = drupal_map_assoc($updates);
$updates = array_combine($updates, $updates);
foreach (array_keys($updates) as $update) {
if ($update == \Drupal::CORE_MINIMUM_SCHEMA_VERSION) {
$ret[$module]['warning'] = '<em>' . $module . '</em> module cannot be updated. It contains an update numbered as ' . \Drupal::CORE_MINIMUM_SCHEMA_VERSION . ' which is reserved for the earliest installation of a module in Drupal ' . \Drupal::CORE_COMPATIBILITY . ', before any updates. In order to update <em>' . $module . '</em> module, you will need to install a version of the module with valid updates.';
......
......@@ -8,7 +8,6 @@
namespace Drupal\Component\Plugin;
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
use Drupal\Component\Utility\MapArray;
/**
* Provides a default plugin bag for a plugin type.
......@@ -63,7 +62,8 @@ public function __construct(PluginManagerInterface $manager, array $configuratio
$this->configurations = $configurations;
if (!empty($configurations)) {
$this->instanceIDs = MapArray::copyValuesToKeys(array_keys($configurations));
$instance_ids = array_keys($configurations);
$this->instanceIDs = array_combine($instance_ids, $instance_ids);
// Store the original order of the instance IDs for export.
$this->originalOrder = $this->instanceIDs;
}
......
<?php
/**
* @file
* Contains \Drupal\Component\Utility\MapArray.
*/
namespace Drupal\Component\Utility;
/**
* Provides generic array mapping helper methods.
*/
class MapArray {
/**
* Forms an associative array from a linear array.
*
* This function walks through the provided array and constructs an associative
* array out of it. The keys of the resulting array will be the values of the
* input array. The values will be the same as the keys unless a function is
* specified, in which case the output of the function is used for the values
* instead.
*
* @param array $array
* A linear array.
* @param callable $callback
* A name of a function to apply to all values before output.
*
* @return array
* An associative array.
*/
public static function copyValuesToKeys(array $array, $callable = NULL) {
// array_combine() fails with empty arrays:
// http://bugs.php.net/bug.php?id=34857.
if (!empty($array)) {
$array = array_combine($array, $array);
}
if (is_callable($callable)) {
$array = array_map($callable, $array);
}
return $array;
}
}
......@@ -410,7 +410,8 @@ protected function buildQuery($ids, $revision_id = FALSE) {
if ($this->revisionTable) {
// Add all fields from the {entity_revision} table.
$entity_revision_fields = drupal_map_assoc(drupal_schema_fields_sql($this->entityType->getRevisionTable()));
$entity_revision_fields = drupal_schema_fields_sql($this->entityType->getRevisionTable());
$entity_revision_fields = array_combine($entity_revision_fields, $entity_revision_fields);
// The ID field is provided by entity, so remove it.
unset($entity_revision_fields[$this->idKey]);
......
......@@ -224,7 +224,7 @@ function filterProjectInfo($info, $additional_whitelist = array()) {
'version',
);
$whitelist = array_merge($whitelist, $additional_whitelist);
return array_intersect_key($info, drupal_map_assoc($whitelist));
return array_intersect_key($info, array_combine($whitelist, $whitelist));
}
}
......@@ -23,7 +23,8 @@ class FeedFormController extends ContentEntityFormController {
*/
public function form(array $form, array &$form_state) {
$feed = $this->entity;
$period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
$intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
$period = array_map('format_interval', array_combine($intervals, $intervals));
$period[AGGREGATOR_CLEAR_NEVER] = $this->t('Never');
$form['title'] = array(
......
......@@ -80,8 +80,8 @@ public function getFormId() {
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
$period = drupal_map_assoc(array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200,
64800, 86400, 172800, 259200, 604800, 1209600, 2419200), 'format_interval');
$intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
$period = array_map('format_interval', array_combine($intervals, $intervals));
$form['upload'] = array(
'#type' => 'file',
......
......@@ -108,11 +108,12 @@ public function blockForm($form, &$form_state) {
'#default_value' => $this->configuration['feed'],
'#options' => $options,
);
$range = range(2, 20);
$form['block_count'] = array(
'#type' => 'select',
'#title' => t('Number of news items in block'),
'#default_value' => $this->configuration['block_count'],
'#options' => drupal_map_assoc(range(2, 20)),
'#options' => array_combine($range, $range),
);
return $form;
}
......
......@@ -72,8 +72,12 @@ public static function create(ContainerInterface $container, array $configuratio
public function buildConfigurationForm(array $form, array &$form_state) {
$processors = $this->configuration['processors'];
$info = $this->getPluginDefinition();
$items = drupal_map_assoc(array(3, 5, 10, 15, 20, 25), array($this, 'formatItems'));
$period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval');
$counts = array(3, 5, 10, 15, 20, 25);
$items = array_map(function ($count) {
return format_plural($count, '1 item', '@count items');
}, array_combine($counts, $counts));
$intervals = array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800);
$period = array_map('format_interval', array_combine($intervals, $intervals));
$period[AGGREGATOR_CLEAR_NEVER] = t('Never');
$form['processors'][$info['id']] = array();
......@@ -103,11 +107,16 @@ public function buildConfigurationForm(array $form, array &$form_state) {
'#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))),
);
$lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000);
$options = array_map(function($length) {
return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');
}, array_combine($lengths, $lengths));
$form['processors'][$info['id']]['aggregator_teaser_length'] = array(
'#type' => 'select',
'#title' => t('Length of trimmed description'),
'#default_value' => $this->configuration['items']['teaser_length'],
'#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), array($this, 'formatCharacters')),
'#options' => $options,
'#description' => t('The maximum number of characters used in the trimmed version of content.'),
);
return $form;
......@@ -233,32 +242,4 @@ public function setConfiguration(array $configuration) {
$config->save();
}
/**
* Helper function for drupal_map_assoc.
*
* @param int $count
* Items count.
*
* @return string
* A string that is plural-formatted as "@count items".
*/
protected function formatItems($count) {
return format_plural($count, '1 item', '@count items');
}
/**
* Creates display text for teaser length option values.
*
* Callback for drupal_map_assoc() within settingsForm().
*
* @param int $length
* The desired length of teaser text, in bytes.
*
* @return string
* A translated string explaining the teaser string length.
*/
protected function formatCharacters($length) {
return ($length == 0) ? t('Unlimited') : format_plural($length, '1 character', '@count characters');
}
}
......@@ -8,7 +8,6 @@
namespace Drupal\block\Tests;
use Drupal\block\Controller\CategoryAutocompleteController;
use Drupal\Component\Utility\MapArray;
use Drupal\Component\Utility\String;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
......@@ -63,7 +62,7 @@ public function setUp() {
public function testAutocompleteSuggestions($string, $suggestions) {
$suggestions = array_map(function ($suggestion) {
return String::checkPlain($suggestion);
}, MapArray::copyValuesToKeys($suggestions));
}, array_combine($suggestions, $suggestions));
$result = $this->autocompleteController->autocomplete(new Request(array('q' => $string)));
$this->assertSame($suggestions, json_decode($result->getContent(), TRUE));
}
......
......@@ -843,7 +843,7 @@ function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) {
if ($form['#field']->getType() == 'comment') {
// We only support posting one comment at the time so it doesn't make sense
// to let the site builder choose anything else.
$form['field']['cardinality_container']['cardinality']['#options'] = drupal_map_assoc(array(1));
$form['field']['cardinality_container']['cardinality']['#options'] = array(1 => 1);
$form['field']['cardinality_container']['#access'] = FALSE;
}
}
......@@ -1531,7 +1531,8 @@ function template_preprocess_comment_wrapper(&$variables) {
* Returns an array of "comments per page" values that users can select from.
*/
function _comment_per_page() {
return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
$comments_per_page = array(10, 30, 50, 70, 90, 150, 200, 250, 300);
return array_combine($comments_per_page, $comments_per_page);
}
/**
......
......@@ -7,7 +7,6 @@
namespace Drupal\config\Form;
use Drupal\Component\Utility\MapArray;
use Drupal\Core\Config\StorageInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityTypeInterface;
......@@ -182,7 +181,8 @@ protected function findConfiguration($config_type) {
}, $this->definitions);
// Find all config, and then filter our anything matching a config prefix.
$names = MapArray::copyValuesToKeys($this->configStorage->listAll());
$names = $this->configStorage->listAll();
$names = array_combine($names, $names);
foreach ($names as $config_name) {
foreach ($config_prefixes as $config_prefix) {
if (strpos($config_name, $config_prefix) === 0) {
......
......@@ -292,7 +292,8 @@ public static function years($min = 0, $max = 0, $required = FALSE) {
$max = intval(date('Y', REQUEST_TIME) + 3);
}
$none = array('' => '');
$range = drupal_map_assoc(range($min, $max));
$range = range($min, $max);
$range = array_combine($range, $range);
return !$required ? $none + $range : $range;
}
......@@ -323,7 +324,8 @@ public static function days($required = FALSE, $month = NULL, $year = NULL) {
$max = 31;
}
$none = array('' => '');
$range = drupal_map_assoc(range(1, $max));
$range = range(1, $max);
$range = array_combine($range, $range);
return !$required ? $none + $range : $range;
}
......
......@@ -11,7 +11,6 @@
* @see watchdog()
*/
use Drupal\Component\Utility\MapArray;
use Drupal\Core\Database\Database;
/**
......@@ -123,7 +122,7 @@ function _dblog_get_message_types() {
$types[] = $object->type;
}
return MapArray::copyValuesToKeys($types);
return array_combine($types, $types);
}
/**
......@@ -155,11 +154,12 @@ function dblog_watchdog(array $log_entry) {
* Implements hook_form_FORM_ID_alter() for system_logging_settings().
*/
function dblog_form_system_logging_settings_alter(&$form, $form_state) {
$row_limits = array(100, 1000, 10000, 100000, 1000000);
$form['dblog_row_limit'] = array(
'#type' => 'select',
'#title' => t('Database log messages to keep'),
'#default_value' => \Drupal::config('dblog.settings')->get('row_limit'),
'#options' => array(0 => t('All')) + drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)),
'#options' => array(0 => t('All')) + array_combine($row_limits, $row_limits),
'#description' => t('The maximum number of messages to keep in the database log. Requires a <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status')))
);
......
......@@ -12,7 +12,6 @@
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Drupal\Component\Utility\MapArray;
use Drupal\Core\Ajax\AjaxResponse;
use Drupal\Core\Entity\EntityInterface;
use Drupal\field\FieldInfo;
......@@ -221,7 +220,7 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
// Re-render the updated field for other view modes (i.e. for other
// instances of the same logical field on the user's page).
$other_view_mode_ids = $request->request->get('other_view_modes') ?: array();
$other_view_modes = MapArray::copyValuesToKeys($other_view_mode_ids, $render_field_in_view_mode);
$other_view_modes = array_map($render_field_in_view_mode, array_combine($other_view_mode_ids, $other_view_mode_ids));
$response->addCommand(new FieldFormSavedCommand($output, $other_view_modes));
}
......
......@@ -104,7 +104,8 @@ public static function settingsForm(FieldDefinitionInterface $field_definition)
if ($target_type_info->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface')) {
// @todo Use Entity::getFieldDefinitions() when all entity types are
// converted to the new Field API.
$fields = drupal_map_assoc(drupal_schema_fields_sql($entity_type->getBaseTable()));
$fields = drupal_schema_fields_sql($entity_type->getBaseTable());
$fields = array_combine($fields, $fields);
foreach (field_info_instances($target_type) as $bundle_instances) {
foreach ($bundle_instances as $instance_name => $instance) {
foreach ($instance->getField()->getColumns() as $column_name => $column_info) {
......
......@@ -52,7 +52,8 @@ public function preRender($row) {
// Force all fields to be inline by default.
if (empty($this->options['inline'])) {
$fields = $this->view->getHandlers('field', $this->displayHandler->display['id']);
$this->options['inline'] = drupal_map_assoc(array_keys($fields));
$names = array_keys($fields);
$this->options['inline'] = array_combine($names, $names);
}
return parent::preRender($row);
......
......@@ -7,7 +7,6 @@
namespace Drupal\field\Plugin\views\field;
use Drupal\Component\Utility\MapArray;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface;
......@@ -414,7 +413,7 @@ public function buildOptionsForm(&$form, &$form_state) {
$form['click_sort_column'] = array(
'#type' => 'select',
'#title' => t('Column used for click sorting'),
'#options' => drupal_map_assoc($column_names),
'#options' => array_combine($column_names, $column_names),
'#default_value' => $this->options['click_sort_column'],
'#description' => t('Used by Style: Table to determine the actual column to click sort the field on. The default is usually fine.'),
);
......@@ -500,7 +499,8 @@ function multiple_options_form(&$form, &$form_state) {
}
else {
$type = 'select';
$options = drupal_map_assoc(range(1, $field->getCardinality()));
$range = range(1, $field->getCardinality());
$options = array_combine($range, $range);
$size = 1;
}
$form['multi_type'] = array(
......@@ -599,9 +599,10 @@ public function buildGroupByForm(&$form, &$form_state) {
// With "field API" fields, the column target of the grouping function
// and any additional grouping columns must be specified.
$field_columns = array_keys($this->field_info->getColumns());
$group_columns = array(
'entity_id' => t('Entity ID'),
) + MapArray::copyValuesToKeys(array_keys($this->field_info->getColumns()), 'ucfirst');
) + array_map('ucfirst', array_combine($field_columns, $field_columns));
$form['group_column'] = array(
'#type' => 'select',
......@@ -611,8 +612,11 @@ public function buildGroupByForm(&$form, &$form_state) {
'#options' => $group_columns,
);
$options = MapArray::copyValuesToKeys(array('bundle', 'language', 'entity_type'), 'ucfirst');
$options = array(
'bundle' => 'Bundle',
'language' => 'Language',
'entity_type' => 'Entity_type',
);
// Add on defined fields, noting that they're prefixed with the field name.
$form['group_columns'] = array(
'#type' => 'checkboxes',
......
......@@ -258,6 +258,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent
$display_options = $entity_display->getComponent($field_name);
$label = $field_definition->getLabel();
$regions = array_keys($this->getRegions());
$field_row = array(
'#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
'#row_type' => 'field',
......@@ -282,7 +283,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent
'#type' => 'select',
'#title' => $this->t('Label display for @title', array('@title' => $label)),
'#title_display' => 'invisible',
'#options' => drupal_map_assoc(array_keys($this->getRegions())),
'#options' => array_combine($regions, $regions),
'#empty_value' => '',
'#attributes' => array('class' => array('field-parent')),
'#parents' => array('fields', $field_name, 'parent'),
......@@ -432,6 +433,7 @@ protected function buildFieldRow(FieldDefinitionInterface $field_definition, Ent
protected function buildExtraFieldRow($field_id, $extra_field, EntityDisplayInterface $entity_display) {
$display_options = $entity_display->getComponent($field_id);
$regions = array_keys($this->getRegions());
$extra_field_row = array(
'#attributes' => array('class' => array('draggable', 'tabledrag-leaf')),
'#row_type' => 'extra_field',
......@@ -453,7 +455,7 @@ protected function buildExtraFieldRow($field_id, $extra_field, EntityDisplayInte
'#type' => 'select',
'#title' => $this->t('Parents for @title', array('@title' => $extra_field['label'])),
'#title_display' => 'invisible',
'#options' => drupal_map_assoc(array_keys($this->getRegions())),
'#options' => array_combine($regions, $regions),
'#empty_value' => '',
'#attributes' => array('class' => array('field-parent')),
'#parents' => array('fields', $field_id, 'parent'),
......
......@@ -9,6 +9,7 @@
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Render\Element;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
......@@ -157,7 +158,8 @@ public function tablePreRender($elements) {
$trees = array_fill_keys(array_keys($regions), $tree);
$parents = array();
$list = drupal_map_assoc(element_children($elements));
$children = Element::children($elements);
$list = array_combine($children, $children);
// Iterate on rows until we can build a known tree path for all of them.
while ($list) {
......
......@@ -27,20 +27,20 @@ public function getFormId() {
public function buildForm(array $form, array &$form_state) {
$config = $this->configFactory->get('forum.settings');
$number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500));
$options = array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500);
$form['forum_hot_topic'] = array(
'#type' => 'select',
'#title' => $this->t('Hot topic threshold'),
'#default_value' => $config->get('topics.hot_threshold'),
'#options' => $number,
'#options' => array_combine($options, $options),
'#description' => $this->t('The number of replies a topic must have to be considered "hot".'),
);
$number = drupal_map_assoc(array(10, 25, 50, 75, 100));
$options = array(10, 25, 50, 75, 100);
$form['forum_per_page'] = array(
'#type' => 'select',
'#title' => $this->t('Topics per page'),
'#default_value' => $config->get('topics.page_limit'),
'#options' => $number,
'#options' => array_combine($options, $options),
'#description' => $this->t('Default number of forum topics displayed per page.'),
);
$forder = array(
......
......@@ -39,11 +39,12 @@ public function access(AccountInterface $account) {
* Overrides \Drupal\block\BlockBase::blockForm().
*/
public function blockForm($form, &$form_state) {
$range = range(2, 20);
$form['block_count'] = array(
'#type' => 'select',
'#title' => t('Number of topics'),
'#default_value' => $this->configuration['block_count'],
'#options' => drupal_map_assoc(range(2, 20)),
'#options' => array_combine($range, $range),
);
return $form;
}
......
......@@ -8,7 +8,6 @@
namespace Drupal\language;
use Drupal\Component\PhpStorage\PhpStorageFactory;
use Drupal\Component\Utility\MapArray;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Language\Language;
......@@ -323,7 +322,7 @@ public function getFallbackCandidates($langcode = NULL, array $context = array()
// at the end.
$candidates = array_keys($this->getLanguages());
$candidates[] = Language::LANGCODE_NOT_SPECIFIED;
$candidates = MapArray::copyValuesToKeys($candidates);
$candidates = array_combine($candidates, $candidates);
// The first candidate should always be the desired language if specified.
if (!empty($langcode)) {
......
......@@ -73,7 +73,7 @@ function locale_translation_get_projects($project_names = array()) {
// Return the requested project names or all projects.
if ($project_names) {
return array_intersect_key($projects, drupal_map_assoc($project_names));
return array_intersect_key($projects, array_combine($project_names, $project_names));
}
return $projects;
}
......
......@@ -46,7 +46,7 @@ public function count() {
* {@inheritdoc}
*/
public function fields() {
return drupal_map_assoc($this->variables);
return array_combine($this->variables, $this->variables);
}
/**
......
......@@ -8,7 +8,6 @@
namespace Drupal\node;
use Drupal\Core\Entity\EntityFormController;
use Drupal\Component\Utility\MapArray;
use Drupal\Component\Utility\String;
/**
......@@ -32,7 +31,8 @@ public function form(array $form, array &$form_state) {
$node_settings = $type->getModuleSettings('node');
// Prepare node options to be used for 'checkboxes' form element.
$node_settings['options'] = MapArray::copyValuesToKeys(array_keys(array_filter($node_settings['options'])));
$keys = array_keys(array_filter($node_settings['options']));
$node_settings['options'] = array_combine($keys, $keys);
$form['name'] = array(
'#title' => t('Name'),
'#type' => 'textfield',
......
......@@ -559,7 +559,8 @@ public function buildConfigurationForm(array $form, array &$form_state) {
);
// Note: reversed to reflect that higher number = higher ranking.
$options = drupal_map_assoc(range(0, 10));
$range = range(0, 10);
$options = array_combine($range, $range);
foreach ($this->getRankings() as $var => $values) {
$form['content_ranking']['factors']["rankings_$var"] = array(
'#title' => $values['title'],
......
......@@ -113,7 +113,7 @@ public function validateArgument($argument) {
return FALSE;
}
$test = drupal_map_assoc($nids->value);
$test = array_combine($nids->value, $nids->value);
$titles = array();
$nodes = node_load_multiple($nids->value);
......
......@@ -1264,11 +1264,12 @@ function node_view_multiple($nodes, $view_mode = 'teaser', $langcode = NULL) {
* @see node_form_system_site_information_settings_form_submit()
*/
function node_form_system_site_information_settings_form_alter(&$form, &$form_state, $form_id) {
$options = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30);
$form['front_page']['default_nodes_main'] = array(
'#type' => 'select',
'#title' => t('Number of posts on front page'),
'#default_value' => \Drupal::config('node.settings')->get('items_per_page'),
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
'#options' => array_combine($options, $options),