Commit 83e37783 authored by Pavan B S's avatar Pavan B S Committed by generalredneck

Issue #2870575 by Pavan B S: Convert module to use short array syntax (new coding standard)

parent 6b8f779b
......@@ -47,39 +47,39 @@ class ConfigurationForm extends ConfigFormBase {
public function buildForm(array $form, FormStateInterface $form_state, Request $request = NULL) {
$config = $this->config('views_natural_sort.settings');
// TODO: Change this to be handled by the transformation plugins.
$form['beginning_words_remove'] = array(
$form['beginning_words_remove'] = [
'#type' => 'textfield',
'#title' => 'Words to filter from the beginning of a phrase',
'#default_value' => implode(',', $config->get('transformation_settings.remove_beginning_words.settings')),
'#description' => $this->t('Commonly, the words "A", "The", and "An" are removed when sorting book titles if they appear at the beginning of the title. Those would be great candidates for this field. Separate words with a comma.'),
);
];
$form['words_remove'] = array(
$form['words_remove'] = [
'#type' => 'textfield',
'#title' => 'Words to filter from anywhere in a phrase',
'#default_value' => implode(',', $config->get('transformation_settings.remove_words.settings')),
'#description' => $this->t('Commonly used words like "of", "and", and "or" are removed when sorting book titles. Words you would like filtered go here. Separate words with a comma.'),
);
];
$form['symbols_remove'] = array(
$form['symbols_remove'] = [
'#type' => 'textfield',
'#title' => 'Symbols to filter from anywhere in a phrase',
'#default_value' => $config->get('transformation_settings.remove_symbols.settings'),
'#description' => $this->t('Most symbols are ignored when performing a sort naturally. Those symbols you want ignored go here. Do not use a separator. EX: &$".'),
);
$form['days_of_the_week_enabled'] = array(
];
$form['days_of_the_week_enabled'] = [
'#type' => 'checkbox',
'#title' => 'Sort days of the week and their abbreviations',
'#description' => "Checking this setting will allow sorting of days of the week in their proper order starting with the day of the week that is configurable by you and for each language.",
'#efault_value' => $config->get('transformation_settings.days_of_the_week.enabled'),
);
$form['rebuild_items_per_batch'] = array(
];
$form['rebuild_items_per_batch'] = [
'#type' => 'number',
'#title' => 'Items per Batch',
'#default_value' => $config->get('rebuild_items_per_batch'),
'#min' => 0,
'#description' => $this->t('The number of items a batch process will work through at a given time. Raising this number will make the batch go quicker, however, raising it too high can cause timeouts and/or memory limit errors.'),
);
];
$form['rebuild'] = [
'#type' => 'details',
'#title' => $this->t('Incase of Emergency'),
......
......@@ -20,14 +20,14 @@ class RemoveWords extends TransformationBase {
array_walk($words, 'preg_quote');
return preg_replace(
array(
[
'/\s(' . implode('|', $words) . ')\s+/iu',
'/^(' . implode('|', $words) . ')\s+/iu',
),
array(
],
[
' ',
'',
),
],
$string
);
}
......
......@@ -127,12 +127,12 @@ class BasicTest extends ViewsKernelTestBase {
$plugin = new \Drupal\views_natural_sort\Plugin\IndexRecordContentTransformation\RemoveSymbols([
'settings' => "#…\",'\\()[]«?!»¡¿",
], '', '');
$titles = array(
$titles = [
'Cuando… se abre, ¿dará algún tipo de señal?',
);
$expected = array(
];
$expected = [
'Cuando se abre dará algún tipo de señal',
);
];
foreach ($titles as $key => $title) {
$this->assertEqual($plugin->transform($title), $expected[$key]);
}
......
......@@ -56,14 +56,14 @@ function views_natural_sort_remove_words($string) {
array_walk($words, 'preg_quote');
return preg_replace(
array(
[
'/\s(' . implode('|', $words) . ')\s+/i',
'/^(' . implode('|', $words) . ')\s+/i',
),
array(
],
[
' ',
'',
),
],
$string
);
}
......@@ -158,9 +158,9 @@ function _views_natural_sort_number_transform_match_callback(array $match) {
// against a longer one that is identical in negative numbers. This is so
// that longer numbers are always LESS than sorter numbers that have
// identical beginnings. Ex: -3.05 and -3.05011.
$digits = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' ');
$intermediate = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k');
$rev_digits = array('9', '8', '7', '6', '5', '4', '3', '2', '1', '0', ':');
$digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' '];
$intermediate = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'];
$rev_digits = ['9', '8', '7', '6', '5', '4', '3', '2', '1', '0', ':'];
$encode = $match[1] . str_replace($intermediate, $rev_digits, str_replace($digits, $intermediate, $encode));
}
return $encode;
......
......@@ -11,46 +11,46 @@
*/
function views_natural_sort_schema() {
$schema['views_natural_sort'] = array(
$schema['views_natural_sort'] = [
'description' => t('Compressed titles for natural sorting.'),
'fields' => array(
'eid' => array(
'fields' => [
'eid' => [
'description' => t('Entity id'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'entity_type' => array(
],
'entity_type' => [
'description' => t('Entity Type'),
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => 'node',
),
'field' => array(
],
'field' => [
'description' => t('The field name. This will be title or some cck text field, etc.'),
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'delta' => array(
],
'delta' => [
'description' => t('The sequence number for this data item, used for multi-value fields'),
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'content' => array(
],
'content' => [
'description' => t('Filtered content used for sorting.'),
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array('eid', 'entity_type', 'field', 'delta'),
);
],
],
'primary key' => ['eid', 'entity_type', 'field', 'delta'],
];
return $schema;
}
......
......@@ -43,7 +43,7 @@ function views_natural_sort_module_implements_alter(&$implements, $hook) {
function views_natural_sort_views_natural_sort_get_entry_types() {
$service = Drupal::service('views_natural_sort.service');
$supported_entity_properties = $service->getViewsSupportedEntityProperties();
$entry_types = array();
$entry_types = [];
foreach ($supported_entity_properties as $entity_type => $properties) {
foreach ($properties as $property => $schema_info) {
$entry_types = new IndexRecordType($entity_type, $property);
......@@ -105,10 +105,10 @@ function views_natural_sort_entity_update(EntityInterface $entity) {
* This keeps our natural sort index clean.
*/
function views_natural_sort_entity_delete(EntityInterface $entity) {
views_natural_sort_remove($entry = array(
views_natural_sort_remove($entry = [
'eid' => $entity->id(),
'entity_type' => $entity->getEntityTypeId(),
));
]);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment