Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -29,7 +29,7 @@ class OptionsDefaultFormatter extends FormatterBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
$elements = [];
|
||||
|
||||
// Only collect allowed options if there are actually items to display.
|
||||
if ($items->count()) {
|
||||
|
@ -44,10 +44,10 @@ class OptionsDefaultFormatter extends FormatterBase {
|
|||
// If the stored value is in the current set of allowed values, display
|
||||
// the associated label, otherwise just display the raw value.
|
||||
$output = isset($options[$value]) ? $options[$value] : $value;
|
||||
$elements[$delta] = array(
|
||||
$elements[$delta] = [
|
||||
'#markup' => $output,
|
||||
'#allowed_tags' => FieldFilteredMarkup::allowedTags(),
|
||||
);
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ class OptionsKeyFormatter extends FormatterBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = array();
|
||||
$elements = [];
|
||||
|
||||
foreach ($items as $delta => $item) {
|
||||
$elements[$delta] = array(
|
||||
$elements[$delta] = [
|
||||
'#markup' => $item->value,
|
||||
'#allowed_tags' => FieldFilteredMarkup::allowedTags(),
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
return $elements;
|
||||
|
|
|
@ -34,16 +34,16 @@ class ListFloatItem extends ListItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function schema(FieldStorageDefinitionInterface $field_definition) {
|
||||
return array(
|
||||
'columns' => array(
|
||||
'value' => array(
|
||||
return [
|
||||
'columns' => [
|
||||
'value' => [
|
||||
'type' => 'float',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'value' => array('value'),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
'value' => ['value'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ class ListFloatItem extends ListItemBase {
|
|||
$description .= '<br/>' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
|
||||
$description .= '<br/>' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
|
||||
$description .= '</p>';
|
||||
$description .= '<p>' . t('Allowed HTML tags in labels: @tags', array('@tags' => $this->displayAllowedTags())) . '</p>';
|
||||
$description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '</p>';
|
||||
return $description;
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ class ListFloatItem extends ListItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function simplifyAllowedValues(array $structured_values) {
|
||||
$values = array();
|
||||
$values = [];
|
||||
foreach ($structured_values as $item) {
|
||||
// Nested elements are embedded in the label.
|
||||
if (is_array($item['label'])) {
|
||||
|
|
|
@ -34,16 +34,16 @@ class ListIntegerItem extends ListItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function schema(FieldStorageDefinitionInterface $field_definition) {
|
||||
return array(
|
||||
'columns' => array(
|
||||
'value' => array(
|
||||
return [
|
||||
'columns' => [
|
||||
'value' => [
|
||||
'type' => 'int',
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'value' => array('value'),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
'value' => ['value'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -55,7 +55,7 @@ class ListIntegerItem extends ListItemBase {
|
|||
$description .= '<br/>' . t('The label is optional: if a line contains a single number, it will be used as key and label.');
|
||||
$description .= '<br/>' . t('Lists of labels are also accepted (one label per line), only if the field does not hold any values yet. Numeric keys will be automatically generated from the positions in the list.');
|
||||
$description .= '</p>';
|
||||
$description .= '<p>' . t('Allowed HTML tags in labels: @tags', array('@tags' => $this->displayAllowedTags())) . '</p>';
|
||||
$description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '</p>';
|
||||
return $description;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,10 +21,10 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function defaultStorageSettings() {
|
||||
return array(
|
||||
'allowed_values' => array(),
|
||||
return [
|
||||
'allowed_values' => [],
|
||||
'allowed_values_function' => '',
|
||||
) + parent::defaultStorageSettings();
|
||||
] + parent::defaultStorageSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -85,28 +85,28 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
$allowed_values = $this->getSetting('allowed_values');
|
||||
$allowed_values_function = $this->getSetting('allowed_values_function');
|
||||
|
||||
$element['allowed_values'] = array(
|
||||
$element['allowed_values'] = [
|
||||
'#type' => 'textarea',
|
||||
'#title' => t('Allowed values list'),
|
||||
'#default_value' => $this->allowedValuesString($allowed_values),
|
||||
'#rows' => 10,
|
||||
'#access' => empty($allowed_values_function),
|
||||
'#element_validate' => array(array(get_class($this), 'validateAllowedValues')),
|
||||
'#element_validate' => [[get_class($this), 'validateAllowedValues']],
|
||||
'#field_has_data' => $has_data,
|
||||
'#field_name' => $this->getFieldDefinition()->getName(),
|
||||
'#entity_type' => $this->getEntity()->getEntityTypeId(),
|
||||
'#allowed_values' => $allowed_values,
|
||||
);
|
||||
];
|
||||
|
||||
$element['allowed_values']['#description'] = $this->allowedValuesDescription();
|
||||
|
||||
$element['allowed_values_function'] = array(
|
||||
$element['allowed_values_function'] = [
|
||||
'#type' => 'item',
|
||||
'#title' => t('Allowed values list'),
|
||||
'#markup' => t('The value of this field is being determined by the %function function and may not be changed.', array('%function' => $allowed_values_function)),
|
||||
'#markup' => t('The value of this field is being determined by the %function function and may not be changed.', ['%function' => $allowed_values_function]),
|
||||
'#access' => !empty($allowed_values_function),
|
||||
'#value' => $allowed_values_function,
|
||||
);
|
||||
];
|
||||
|
||||
return $element;
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
* @see \Drupal\options\Plugin\Field\FieldType\ListItemBase::allowedValuesString()
|
||||
*/
|
||||
protected static function extractAllowedValues($string, $has_data) {
|
||||
$values = array();
|
||||
$values = [];
|
||||
|
||||
$list = explode("\n", $string);
|
||||
$list = array_map('trim', $list);
|
||||
|
@ -180,7 +180,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
$generated_keys = $explicit_keys = FALSE;
|
||||
foreach ($list as $position => $text) {
|
||||
// Check for an explicit key.
|
||||
$matches = array();
|
||||
$matches = [];
|
||||
if (preg_match('/(.*)\|(.*)/', $text, $matches)) {
|
||||
// Trim key and value to avoid unwanted spaces issues.
|
||||
$key = trim($matches[1]);
|
||||
|
@ -239,7 +239,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
* - Each value is in the format "value|label" or "value".
|
||||
*/
|
||||
protected function allowedValuesString($values) {
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
foreach ($values as $key => $value) {
|
||||
$lines[] = "$key|$value";
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
* @see \Drupal\options\Plugin\Field\FieldType\ListItemBase::structureAllowedValues()
|
||||
*/
|
||||
protected static function simplifyAllowedValues(array $structured_values) {
|
||||
$values = array();
|
||||
$values = [];
|
||||
foreach ($structured_values as $item) {
|
||||
if (is_array($item['label'])) {
|
||||
// Nested elements are embedded in the label.
|
||||
|
@ -305,15 +305,15 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
* @see \Drupal\options\Plugin\Field\FieldType\ListItemBase::simplifyAllowedValues()
|
||||
*/
|
||||
protected static function structureAllowedValues(array $values) {
|
||||
$structured_values = array();
|
||||
$structured_values = [];
|
||||
foreach ($values as $value => $label) {
|
||||
if (is_array($label)) {
|
||||
$label = static::structureAllowedValues($label);
|
||||
}
|
||||
$structured_values[] = array(
|
||||
$structured_values[] = [
|
||||
'value' => static::castAllowedValue($value),
|
||||
'label' => $label,
|
||||
);
|
||||
];
|
||||
}
|
||||
return $structured_values;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class ListStringItem extends ListItemBase {
|
|||
public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
|
||||
$properties['value'] = DataDefinition::create('string')
|
||||
->setLabel(t('Text value'))
|
||||
->addConstraint('Length', array('max' => 255))
|
||||
->addConstraint('Length', ['max' => 255])
|
||||
->setRequired(TRUE);
|
||||
|
||||
return $properties;
|
||||
|
@ -36,17 +36,17 @@ class ListStringItem extends ListItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
public static function schema(FieldStorageDefinitionInterface $field_definition) {
|
||||
return array(
|
||||
'columns' => array(
|
||||
'value' => array(
|
||||
return [
|
||||
'columns' => [
|
||||
'value' => [
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'value' => array('value'),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
'indexes' => [
|
||||
'value' => ['value'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -57,7 +57,7 @@ class ListStringItem extends ListItemBase {
|
|||
$description .= '<br/>' . t('The key is the stored value. The label will be used in displayed values and edit forms.');
|
||||
$description .= '<br/>' . t('The label is optional: if a line contains a single string, it will be used as key and label.');
|
||||
$description .= '</p>';
|
||||
$description .= '<p>' . t('Allowed HTML tags in labels: @tags', array('@tags' => $this->displayAllowedTags())) . '</p>';
|
||||
$description .= '<p>' . t('Allowed HTML tags in labels: @tags', ['@tags' => $this->displayAllowedTags()]) . '</p>';
|
||||
return $description;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue