Issue #2092095 by tstoeckler, ParisLiakos: Remove \Drupal\Component\Utility\MapArray.
parent
53068d078f
commit
78b48c89ad
|
@ -16,7 +16,6 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
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\Attribute;
|
|||
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 @@ class DefaultPluginBag extends PluginBag {
|
|||
$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;
|
||||
}
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
<?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 @@ class FieldableDatabaseStorageController extends FieldableEntityStorageControlle
|
|||
|
||||
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 @@ class ProjectInfo {
|
|||
'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 @@ class OpmlFeedAdd extends FormBase {
|
|||
* {@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 @@ class AggregatorFeedBlock extends BlockBase implements ContainerFactoryPluginInt
|
|||
'#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 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
|
|||
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 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
|
|||
'#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 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
|
|||
$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 @@ class CategoryAutocompleteTest extends UnitTestCase {
|
|||
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 @@ class ConfigSingleExportForm extends FormBase {
|
|||
}, $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 @@ class DateHelper {
|
|||
$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 @@ class DateHelper {
|
|||
$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\DependencyInjection\ContainerInterface;
|
|||
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 @@ class EditController extends ControllerBase {
|
|||
// 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 @@ class SelectionBase implements SelectionInterface {
|
|||
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 @@ class EntityReference extends Fields {
|
|||
// 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 @@ class Field extends FieldPluginBase {
|
|||
$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 @@ class Field extends FieldPluginBase {
|
|||
}
|
||||
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 @@ class Field extends FieldPluginBase {
|
|||
// 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 @@ class Field extends FieldPluginBase {
|
|||
'#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 @@ abstract class DisplayOverviewBase extends OverviewBase {
|
|||
$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 @@ abstract class DisplayOverviewBase extends OverviewBase {
|
|||
'#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 @@ abstract class DisplayOverviewBase extends OverviewBase {
|
|||
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 @@ abstract class DisplayOverviewBase extends OverviewBase {
|
|||
'#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 @@ namespace Drupal\field_ui;
|
|||
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\Form\FormBase;
|
||||
use Drupal\Core\Render\Element;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
|
@ -157,7 +158,8 @@ abstract class OverviewBase extends FormBase {
|
|||
$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 @@ class ForumSettingsForm extends ConfigFormBase {
|
|||
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 @@ abstract class ForumBlockBase extends BlockBase {
|
|||
* 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 @@ class ConfigurableLanguageManager extends LanguageManager implements Configurabl
|
|||
// 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 @@ class Variable extends Drupal6SqlBase {
|
|||
* {@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 @@ class NodeTypeFormController extends EntityFormController {
|
|||
|
||||
$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 @@ class NodeSearch extends ConfigurableSearchPluginBase implements AccessibleInter
|
|||
);
|
||||
|
||||
// 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 @@ class Node extends ArgumentValidatorPluginBase {
|
|||
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),
|
||||
'#access' => (\Drupal::config('system.site')->get('page.front') == 'node'),
|
||||
'#description' => t('The maximum number of posts displayed on overview pages such as the front page.'),
|
||||
);
|
||||
|
|
|
@ -44,10 +44,11 @@ class NumberDecimalFormatter extends DefaultNumberFormatter {
|
|||
'#default_value' => $this->getSetting('decimal_separator'),
|
||||
'#weight' => 5,
|
||||
);
|
||||
$range = range(0, 10);
|
||||
$elements['scale'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Scale', array(), array('decimal places')),
|
||||
'#options' => drupal_map_assoc(range(0, 10)),
|
||||
'#options' => array_combine($range, $range),
|
||||
'#default_value' => $this->getSetting('scale'),
|
||||
'#description' => t('The number of digits to the right of the decimal.'),
|
||||
'#weight' => 6,
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Drupal\number\Plugin\Field\FieldType;
|
|||
|
||||
use Drupal\Core\Field\FieldDefinitionInterface;
|
||||
use Drupal\Core\TypedData\DataDefinition;
|
||||
use Drupal\Component\Utility\MapArray;
|
||||
|
||||
/**
|
||||
* Plugin implementation of the 'number_decimal' field type.
|
||||
|
@ -67,18 +66,20 @@ class DecimalItem extends NumberItemBase {
|
|||
$element = array();
|
||||
$settings = $this->getSettings();
|
||||
|
||||
$range = range(10, 32);
|
||||
$element['precision'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Precision'),
|
||||
'#options' => MapArray::copyValuesToKeys(range(10, 32)),
|
||||
'#options' => array_combine($range, $range),
|
||||
'#default_value' => $settings['precision'],
|
||||
'#description' => t('The total number of digits to store in the database, including those to the right of the decimal.'),
|
||||
'#disabled' => $has_data,
|
||||
);
|
||||
$range = range(0, 10);
|
||||
$element['scale'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Scale', array(), array('decimal places')),
|
||||
'#options' => MapArray::copyValuesToKeys(range(0, 10)),
|
||||
'#options' => array_combine($range, $range),
|
||||
'#default_value' => $settings['scale'],
|
||||
'#description' => t('The number of digits to the right of the decimal.'),
|
||||
'#disabled' => $has_data,
|
||||
|
|
|
@ -30,11 +30,12 @@ function options_test_allowed_values_callback(FieldDefinitionInterface $field_de
|
|||
*/
|
||||
function options_test_dynamic_values_callback(FieldDefinitionInterface $field_definition, EntityInterface $entity, &$cacheable) {
|
||||
$cacheable = FALSE;
|
||||
// We need the values of the entity as keys.
|
||||
return drupal_map_assoc(array(
|
||||
$values = array(
|
||||
$entity->label(),
|
||||
$entity->url(),
|
||||
$entity->uuid(),
|
||||
$entity->bundle(),
|
||||
));
|
||||
);
|
||||
// We need the values of the entity as keys.
|
||||
return array_combine($values, $values);
|
||||
}
|
||||
|
|
|
@ -95,7 +95,7 @@ class Serializer extends StylePluginBase {
|
|||
'#type' => 'checkboxes',
|
||||
'#title' => t('Accepted request formats'),
|
||||
'#description' => t('Request formats that will be allowed in responses. If none are selected all formats will be allowed.'),
|
||||
'#options' => drupal_map_assoc($this->formats),
|
||||
'#options' => array_combine($this->formats, $this->formats),
|
||||
'#default_value' => $this->options['formats'],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\search;
|
||||
|
||||
use Drupal\Component\Utility\MapArray;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Config\Entity\DraggableListController;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
@ -167,7 +166,8 @@ class SearchPageListController extends DraggableListController implements FormIn
|
|||
'#submit' => array(array($this, 'searchAdminReindexSubmit')),
|
||||
);
|
||||
|
||||
$items = MapArray::copyValuesToKeys(array(10, 20, 50, 100, 200, 500));
|
||||
$items = array(10, 20, 50, 100, 200, 500);
|
||||
$items = array_combine($items, $items);
|
||||
|
||||
// Indexing throttle:
|
||||
$form['indexing_throttle'] = array(
|
||||
|
|
|
@ -79,7 +79,8 @@ class StatisticsPopularBlock extends BlockBase {
|
|||
*/
|
||||
public function blockForm($form, &$form_state) {
|
||||
// Popular content block settings.
|
||||
$numbers = array('0' => t('Disabled')) + drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40));
|
||||
$numbers = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30, 40);
|
||||
$numbers = array('0' => t('Disabled')) + array_combine($numbers, $numbers);
|
||||
$form['statistics_block_top_day_num'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t("Number of day's top views to display"),
|
||||
|
|
|
@ -96,12 +96,13 @@ class CronForm extends ConfigFormBase {
|
|||
'#type' => 'details',
|
||||
'#open' => TRUE,
|
||||
);
|
||||
$options = array(3600, 10800, 21600, 43200, 86400, 604800);
|
||||
$form['cron']['cron_safe_threshold'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Run cron every'),
|
||||
'#description' => t('More information about setting up scheduled tasks can be found by <a href="@url">reading the cron tutorial on drupal.org</a>.', array('@url' => url('http://drupal.org/cron'))),
|
||||
'#default_value' => $config->get('threshold.autorun'),
|
||||
'#options' => array(0 => t('Never')) + drupal_map_assoc(array(3600, 10800, 21600, 43200, 86400, 604800), 'format_interval'),
|
||||
'#options' => array(0 => t('Never')) + array_map('format_interval', array_combine($options, $options)),
|
||||
);
|
||||
|
||||
return parent::buildForm($form, $form_state);
|
||||
|
|
|
@ -80,7 +80,8 @@ class PerformanceForm extends ConfigFormBase {
|
|||
'#open' => TRUE,
|
||||
);
|
||||
|
||||
$period = drupal_map_assoc(array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400), 'format_interval');
|
||||
$period = array(0, 60, 180, 300, 600, 900, 1800, 2700, 3600, 10800, 21600, 32400, 43200, 86400);
|
||||
$period = array_map('format_interval', array_combine($period, $period));
|
||||
$period[0] = '<' . t('none') . '>';
|
||||
$form['caching']['page_cache_maximum_age'] = array(
|
||||
'#type' => 'select',
|
||||
|
|
|
@ -32,11 +32,12 @@ class RssFeedsForm extends ConfigFormBase {
|
|||
'#default_value' => $rss_config->get('channel.description'),
|
||||
'#description' => t('Description of your site, included in each feed.')
|
||||
);
|
||||
$options = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30);
|
||||
$form['feed_default_items'] = array(
|
||||
'#type' => 'select',
|
||||
'#title' => t('Number of items in each feed'),
|
||||
'#default_value' => $rss_config->get('items.limit'),
|
||||
'#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)),
|
||||
'#options' => array_combine($options, $options),
|
||||
'#description' => t('Default number of items to include in each feed.')
|
||||
);
|
||||
$form['feed_item_length'] = array(
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\system\Tests\Entity;
|
||||
|
||||
use Drupal\Component\Utility\MapArray;
|
||||
use Drupal\Core\Language\Language;
|
||||
use Drupal\entity_test\Entity\EntityTestMulRev;
|
||||
|
||||
|
@ -495,7 +494,7 @@ class EntityTranslationTest extends EntityLanguageTestBase {
|
|||
$controller = $this->entityManager->getViewBuilder($entity_type);
|
||||
$build = $controller->view($entity);
|
||||
$this->assertEqual($build['label']['#markup'], $values[$current_langcode]['name'], 'By default the entity is rendered in the current language.');
|
||||
$langcodes = MapArray::copyValuesToKeys($this->langcodes);
|
||||
$langcodes = array_combine($this->langcodes, $this->langcodes);
|
||||
// We have no translation for the $langcode2 langauge, hence the expected
|
||||
// result is the topmost existing translation, that is $langcode.
|
||||
$langcodes[$langcode2] = $langcode;
|
||||
|
|
|
@ -54,7 +54,7 @@ function entity_test_entity_types($filter = NULL) {
|
|||
$types[] = 'entity_test_rev';
|
||||
}
|
||||
$types[] = 'entity_test_mulrev';
|
||||
return drupal_map_assoc($types);
|
||||
return array_combine($types, $types);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -140,7 +140,7 @@ function form_test_validate_form_validate(&$form, &$form_state) {
|
|||
* @deprecated Use \Drupal\form_test\validateRequiredForm()
|
||||
*/
|
||||
function form_test_validate_required_form($form, &$form_state) {
|
||||
$options = drupal_map_assoc(array('foo', 'bar'));
|
||||
$options = array('foo' => 'foo', 'bar' => 'bar');
|
||||
$validate = array('form_test_validate_required_form_element_validate');
|
||||
|
||||
$form['textfield'] = array(
|
||||
|
@ -882,7 +882,7 @@ function form_test_select($form, &$form_state) {
|
|||
|
||||
$base = array(
|
||||
'#type' => 'select',
|
||||
'#options' => drupal_map_assoc(array('one', 'two', 'three')),
|
||||
'#options' => array('one' => 'one', 'two' => 'two', 'three' => 'three'),
|
||||
);
|
||||
|
||||
$form['select'] = $base + array(
|
||||
|
|
|
@ -9,7 +9,6 @@ namespace Drupal\plugin_test\Plugin;
|
|||
|
||||
use Drupal\Component\Plugin\PluginBag;
|
||||
use Drupal\Component\Plugin\PluginManagerInterface;
|
||||
use Drupal\Component\Utility\MapArray;
|
||||
|
||||
/**
|
||||
* Defines a plugin bag which uses fruit plugins.
|
||||
|
@ -32,7 +31,8 @@ class TestPluginBag extends PluginBag {
|
|||
public function __construct(PluginManagerInterface $manager) {
|
||||
$this->manager = $manager;
|
||||
|
||||
$this->instanceIDs = MapArray::copyValuesToKeys(array_keys($this->manager->getDefinitions()));
|
||||
$instance_ids = array_keys($this->manager->getDefinitions());
|
||||
$this->instanceIDs = array_combine($instance_ids, $instance_ids);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -67,7 +67,7 @@ class UserSelection extends SelectionBase {
|
|||
'#type' => 'checkboxes',
|
||||
'#title' => t('Restrict to the selected roles'),
|
||||
'#required' => TRUE,
|
||||
'#options' => array_diff_key(user_role_names(TRUE), drupal_map_assoc(array(DRUPAL_AUTHENTICATED_RID))),
|
||||
'#options' => array_diff_key(user_role_names(TRUE), array(DRUPAL_AUTHENTICATED_RID => DRUPAL_AUTHENTICATED_RID)),
|
||||
'#default_value' => $selection_handler_settings['filter']['role'],
|
||||
);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\views\EventSubscriber;
|
||||
|
||||
use Drupal\Component\Utility\MapArray;
|
||||
use Drupal\Core\Page\HtmlPage;
|
||||
use Drupal\Core\Entity\EntityManagerInterface;
|
||||
use Drupal\Core\KeyValueStore\StateInterface;
|
||||
|
@ -104,7 +103,7 @@ class RouteSubscriber extends RouteSubscriberBase {
|
|||
$id = $view->storage->id();
|
||||
$this->viewsDisplayPairs[] = $id . '.' . $display_id;
|
||||
}
|
||||
$this->viewsDisplayPairs = MapArray::copyValuesToKeys($this->viewsDisplayPairs);
|
||||
$this->viewsDisplayPairs = array_combine($this->viewsDisplayPairs, $this->viewsDisplayPairs);
|
||||
}
|
||||
return $this->viewsDisplayPairs;
|
||||
}
|
||||
|
|
|
@ -284,7 +284,7 @@ class String extends ArgumentPluginBase {
|
|||
* Override for specific title lookups.
|
||||
*/
|
||||
public function titleQuery() {
|
||||
return drupal_map_assoc($this->value, '\Drupal\Component\Utility\String::checkPlain');
|
||||
return array_map('\Drupal\Component\Utility\String::checkPlain', array_combine($this->value, $this->value));
|
||||
}
|
||||
|
||||
public function summaryName($data) {
|
||||
|
|
|
@ -40,7 +40,7 @@ class Time extends CachePluginBase {
|
|||
public function buildOptionsForm(&$form, &$form_state) {
|
||||
parent::buildOptionsForm($form, $form_state);
|
||||
$options = array(60, 300, 1800, 3600, 21600, 518400);
|
||||
$options = drupal_map_assoc($options, 'format_interval');
|
||||
$options = array_map('format_interval', array_combine($options, $options));
|
||||
$options = array(-1 => t('Never cache')) + $options + array('custom' => t('Custom'));
|
||||
|
||||
$form['results_lifespan'] = array(
|
||||
|
|
|
@ -860,7 +860,7 @@ abstract class WizardPluginBase extends PluginBase implements WizardInterface {
|
|||
$handler = $table_data[$bundle_key]['filter']['id'];
|
||||
$handler_definition = Views::pluginManager('filter')->getDefinition($handler);
|
||||
if ($handler == 'in_operator' || is_subclass_of($handler_definition['class'], 'Drupal\\views\\Plugin\\views\\filter\\InOperator')) {
|
||||
$value = drupal_map_assoc(array($form_state['values']['show']['type']));
|
||||
$value = array($form_state['values']['show']['type'] => $form_state['values']['show']['type']);
|
||||
}
|
||||
// Otherwise, use just a single value.
|
||||
else {
|
||||
|
|
|
@ -192,7 +192,8 @@ class DefaultViewsTest extends ViewTestBase {
|
|||
$view = views_get_view('archive');
|
||||
$view->setDisplay('page_1');
|
||||
$this->executeView($view);
|
||||
$column_map = drupal_map_assoc(array('nid', 'created_year_month', 'num_records'));
|
||||
$columns = array('nid', 'created_year_month', 'num_records');
|
||||
$column_map = array_combine($columns, $columns);
|
||||
// Create time of additional nodes created in the setup method.
|
||||
$created_year_month = date('Ym', REQUEST_TIME - 3600);
|
||||
$expected_result = array(
|
||||
|
|
|
@ -95,7 +95,7 @@ class FilterEntityBundleTest extends ViewTestBase {
|
|||
// Test each bundle type.
|
||||
$view->initDisplay();
|
||||
$filters = $view->display_handler->getOption('filters');
|
||||
$filters['type']['value'] = drupal_map_assoc(array($key));
|
||||
$filters['type']['value'] = array($key => $key);
|
||||
$view->display_handler->setOption('filters', $filters);
|
||||
$this->executeView($view);
|
||||
|
||||
|
@ -107,7 +107,7 @@ class FilterEntityBundleTest extends ViewTestBase {
|
|||
// Test an invalid bundle type to make sure we have no results.
|
||||
$view->initDisplay();
|
||||
$filters = $view->display_handler->getOption('filters');
|
||||
$filters['type']['value'] = drupal_map_assoc(array('type_3'));
|
||||
$filters['type']['value'] = array('type_3' => 'type_3');
|
||||
$view->display_handler->setOption('filters', $filters);
|
||||
$this->executeView($view);
|
||||
|
||||
|
|
|
@ -309,7 +309,7 @@ class ViewExecutableTest extends ViewUnitTestBase {
|
|||
$this->assertIdentical(spl_object_hash($view->getResponse()), spl_object_hash($new_response), 'New response object correctly set.');
|
||||
|
||||
// Test the generateHandlerId() method.
|
||||
$test_ids = drupal_map_assoc(array('test', 'test_1'));
|
||||
$test_ids = array('test' => 'test', 'test_1' => 'test_1');
|
||||
$this->assertEqual($view->generateHandlerId('new', $test_ids), 'new');
|
||||
$this->assertEqual($view->generateHandlerId('test', $test_ids), 'test_2');
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
namespace Drupal\views;
|
||||
|
||||
use Drupal\Component\Utility\MapArray;
|
||||
use Drupal\Component\Utility\String;
|
||||
|
||||
/**
|
||||
|
@ -150,7 +149,7 @@ class Views {
|
|||
public static function getEnabledDisplayExtenders() {
|
||||
$enabled = array_filter((array) \Drupal::config('views.settings')->get('display_extenders'));
|
||||
|
||||
return MapArray::copyValuesToKeys($enabled);
|
||||
return array_combine($enabled, $enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -398,10 +398,11 @@ function template_preprocess_views_view_summary(&$variables) {
|
|||
$url_options['query'] = $view->exposed_raw_input;
|
||||
}
|
||||
|
||||
$active_urls = drupal_map_assoc(array(
|
||||
$active_urls = array(
|
||||
url(current_path(), array('alias' => TRUE)), // force system path
|
||||
url(current_path()), // could be an alias
|
||||
));
|
||||
);
|
||||
$active_urls = array_combine($active_urls, $active_urls);
|
||||
|
||||
// Collect all arguments foreach row, to be able to alter them for example
|
||||
// by the validator. This is not done per single argument value, because this
|
||||
|
@ -456,12 +457,13 @@ function template_preprocess_views_view_summary_unformatted(&$variables) {
|
|||
}
|
||||
|
||||
$count = 0;
|
||||
$active_urls = drupal_map_assoc(array(
|
||||
$active_urls = array(
|
||||
// Force system path.
|
||||
url(current_path(), array('alias' => TRUE)),
|
||||
// Could be an alias.
|
||||
url(current_path()),
|
||||
));
|
||||
);
|
||||
$active_urls = array_combine($active_urls, $active_urls);
|
||||
|
||||
// Collect all arguments for each row, to be able to alter them for example
|
||||
// by the validator. This is not done per single argument value, because
|
||||
|
|
|
@ -1,105 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\Component\Utility\MapArrayTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\Component\Utility;
|
||||
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Component\Utility\MapArray;
|
||||
|
||||
/**
|
||||
* Tests the MapArray system.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\MapArray
|
||||
*/
|
||||
class MapArrayTest extends UnitTestCase {
|
||||
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'MapArray test',
|
||||
'description' => 'Test that the MapArray functions work properly.',
|
||||
'group' => 'Bootstrap',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests MapArray::copyValuesToKey() input against expected output.
|
||||
*
|
||||
* @dataProvider providerCopyValuesToKey
|
||||
*
|
||||
* @param array $input
|
||||
* The input array for the MapArray::copyValuesToKey() method.
|
||||
* @param array $expected
|
||||
* The expected output from calling the method.
|
||||
* @param callable $callable
|
||||
* The optional callable.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\MapArray::copyValuesToKey()
|
||||
* @see \Drupal\Tests\Component\Utility\MapArrayTest::providerCopyValuesToKey()
|
||||
*/
|
||||
public function testCopyValuesToKey(array $input, array $expected, $callable = NULL) {
|
||||
$output = MapArray::copyValuesToKeys($input, $callable);
|
||||
$this->assertEquals($expected, $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for MapArray::copyValuesToKey().
|
||||
*
|
||||
* @return array
|
||||
* An array of tests, matching the parameter inputs for testCopyValuesToKey.
|
||||
*
|
||||
* @see \Drupal\Component\Utility\MapArray::copyValuesToKey()
|
||||
* @see \Drupal\Tests\Component\Utility\MapArrayTest::testCopyValuesToKey()
|
||||
*/
|
||||
public function providerCopyValuesToKey() {
|
||||
// Test an empty array.
|
||||
$tests[] = array(
|
||||
array(),
|
||||
array()
|
||||
);
|
||||
|
||||
// Tests the creation of an associative array.
|
||||
$tests[] = array(
|
||||
array('foobar'),
|
||||
array('foobar' => 'foobar')
|
||||
);
|
||||
|
||||
// Tests overwriting indexes with their value.
|
||||
$tests[] = array(
|
||||
array('foo' => 'bar'),
|
||||
array('bar' => 'bar')
|
||||
);
|
||||
|
||||
// Tests using the callback function.
|
||||
$tests[] = array(
|
||||
array(1, 2, 3, 4, 5),
|
||||
array(
|
||||
1 => 2,
|
||||
2 => 4,
|
||||
3 => 6,
|
||||
4 => 8,
|
||||
5 => 10,
|
||||
),
|
||||
'Drupal\Tests\Component\Utility\MapArrayTest::providerCopyValuesToKeyCallback',
|
||||
);
|
||||
|
||||
return $tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback for a test in providerCopyValuesToKey(), which doubles the value.
|
||||
*
|
||||
* @param int $n
|
||||
* The value passed in from array_map().
|
||||
*
|
||||
* @return int
|
||||
* The doubled integer value.
|
||||
*/
|
||||
public static function providerCopyValuesToKeyCallback($n) {
|
||||
return $n * 2;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue