Issue #1854868 by swentel: Let formatter summaries return arrays instead of strings.
parent
3282c15424
commit
30e1599a3c
|
@ -32,7 +32,7 @@ use Drupal\Core\Template\Attribute;
|
||||||
class DateTimeDefaultFormatter extends FormatterBase {
|
class DateTimeDefaultFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ class DateTimeDefaultFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
|
|
||||||
|
@ -119,15 +119,13 @@ class DateTimeDefaultFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsSummary().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
|
$summary = array();
|
||||||
$date = new DrupalDateTime();
|
$date = new DrupalDateTime();
|
||||||
$output = array();
|
$summary[] = t('Format: @display', array('@display' => $this->dateFormat($date, FALSE)));
|
||||||
$output[] = t('Format: @display', array('@display' => $this->dateFormat($date, FALSE)));
|
return $summary;
|
||||||
return implode('<br />', $output);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ use Drupal\entity_reference\Plugin\field\formatter\EntityReferenceFormatterBase;
|
||||||
class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
|
class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides \Drupal\entity_reference\Plugin\field\formatter\EntityReferenceFormatterBase::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$view_modes = entity_get_view_modes($this->field['settings']['target_type']);
|
$view_modes = entity_get_view_modes($this->field['settings']['target_type']);
|
||||||
|
@ -60,7 +60,7 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides \Drupal\field\Plugin\Type\Formatter\FormatterBase::settingsSummary().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
$summary = array();
|
$summary = array();
|
||||||
|
@ -70,11 +70,11 @@ class EntityReferenceEntityFormatter extends EntityReferenceFormatterBase {
|
||||||
$summary[] = t('Rendered as @mode', array('@mode' => isset($view_modes[$view_mode]['label']) ? $view_modes[$view_mode]['label'] : $view_mode));
|
$summary[] = t('Rendered as @mode', array('@mode' => isset($view_modes[$view_mode]['label']) ? $view_modes[$view_mode]['label'] : $view_mode));
|
||||||
$summary[] = $this->getSetting('links') ? t('Display links') : t('Do not display links');
|
$summary[] = $this->getSetting('links') ? t('Display links') : t('Do not display links');
|
||||||
|
|
||||||
return implode('<br />', $summary);
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides \Drupal\entity_reference\Plugin\field\formatter\EntityReferenceFormatterBase::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
// Remove un-accessible items.
|
// Remove un-accessible items.
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Drupal\entity_reference\Plugin\field\formatter\EntityReferenceFormatterBase;
|
||||||
class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
|
class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides \Drupal\field\Plugin\Type\Formatter\FormatterBase::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$elements['link'] = array(
|
$elements['link'] = array(
|
||||||
|
@ -44,17 +44,16 @@ class EntityReferenceLabelFormatter extends EntityReferenceFormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides \Drupal\field\Plugin\Type\Formatter\FormatterBase::settingsSummary().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
$summary = array();
|
$summary = array();
|
||||||
$summary[] = $this->getSetting('link') ? t('Link to the referenced entity') : t('No link');
|
$summary[] = $this->getSetting('link') ? t('Link to the referenced entity') : t('No link');
|
||||||
|
return $summary;
|
||||||
return implode('<br />', $summary);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overrides \Drupal\entity_reference\Plugin\field\formatter\EntityReferenceFormatterBase::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
// Remove un-accessible items.
|
// Remove un-accessible items.
|
||||||
|
|
|
@ -78,7 +78,7 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::view().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function view(EntityInterface $entity, $langcode, array $items) {
|
public function view(EntityInterface $entity, $langcode, array $items) {
|
||||||
$field = $this->field;
|
$field = $this->field;
|
||||||
|
@ -113,21 +113,21 @@ abstract class FormatterBase extends PluginSettingsBase implements FormatterInte
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsSummary().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
return '';
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::prepareView().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function prepareView(array $entities, $langcode, array &$items) { }
|
public function prepareView(array $entities, $langcode, array &$items) { }
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Definition of Drupal\field\Plugin\Type\Formatter\FormatterInterface.
|
* Contains \Drupal\field\Plugin\Type\Formatter\FormatterInterface.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Drupal\field\Plugin\Type\Formatter;
|
namespace Drupal\field\Plugin\Type\Formatter;
|
||||||
|
@ -40,8 +40,8 @@ interface FormatterInterface extends PluginSettingsInterface {
|
||||||
* configurable settings, and no UI will be provided to display a settings
|
* configurable settings, and no UI will be provided to display a settings
|
||||||
* form.
|
* form.
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array()
|
||||||
* A short summary of the formatter settings..
|
* A short summary of the formatter settings.
|
||||||
*/
|
*/
|
||||||
public function settingsSummary();
|
public function settingsSummary();
|
||||||
|
|
||||||
|
|
|
@ -276,7 +276,8 @@ function field_test_field_formatter_settings_form_alter(&$element, &$form_state,
|
||||||
* Implements hook_field_formatter_settings_summary_alter().
|
* Implements hook_field_formatter_settings_summary_alter().
|
||||||
*/
|
*/
|
||||||
function field_test_field_formatter_settings_summary_alter(&$summary, $context) {
|
function field_test_field_formatter_settings_summary_alter(&$summary, $context) {
|
||||||
$summary .= '<br />field_test_field_formatter_settings_summary_alter';
|
$summary[] = 'field_test_field_formatter_settings_summary_alter';
|
||||||
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Definition of Drupal\field_test\Plugin\field\formatter\TestFieldDefaultFormatter.
|
* Contains \Drupal\field_test\Plugin\field\formatter\TestFieldDefaultFormatter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Drupal\field_test\Plugin\field\formatter;
|
namespace Drupal\field_test\Plugin\field\formatter;
|
||||||
|
@ -31,7 +31,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
class TestFieldDefaultFormatter extends FormatterBase {
|
class TestFieldDefaultFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$element['test_formatter_setting'] = array(
|
$element['test_formatter_setting'] = array(
|
||||||
|
@ -45,14 +45,16 @@ class TestFieldDefaultFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
return t('@setting: @value', array('@setting' => 'test_formatter_setting', '@value' => $this->getSetting('test_formatter_setting')));
|
$summary = array();
|
||||||
|
$summary[] = t('@setting: @value', array('@setting' => 'test_formatter_setting', '@value' => $this->getSetting('test_formatter_setting')));
|
||||||
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Definition of Drupal\field_test\Plugin\field\formatter\TestFieldMultipleFormatter.
|
* Contains \Drupal\field_test\Plugin\field\formatter\TestFieldMultipleFormatter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Drupal\field_test\Plugin\field\formatter;
|
namespace Drupal\field_test\Plugin\field\formatter;
|
||||||
|
@ -31,7 +31,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
class TestFieldMultipleFormatter extends FormatterBase {
|
class TestFieldMultipleFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$element['test_formatter_setting_multiple'] = array(
|
$element['test_formatter_setting_multiple'] = array(
|
||||||
|
@ -45,14 +45,16 @@ class TestFieldMultipleFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
return t('@setting: @value', array('@setting' => 'test_formatter_setting_multiple', '@value' => $this->getSetting('test_formatter_setting_multiple')));
|
$summary = array();
|
||||||
|
$summary[] = t('@setting: @value', array('@setting' => 'test_formatter_setting_multiple', '@value' => $this->getSetting('test_formatter_setting_multiple')));
|
||||||
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Definition of Drupal\field_test\Plugin\field\formatter\TestFieldPrepareViewFormatter.
|
* Contains \Drupal\field_test\Plugin\field\formatter\TestFieldPrepareViewFormatter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Drupal\field_test\Plugin\field\formatter;
|
namespace Drupal\field_test\Plugin\field\formatter;
|
||||||
|
@ -31,7 +31,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
class TestFieldPrepareViewFormatter extends FormatterBase {
|
class TestFieldPrepareViewFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$element['test_formatter_setting_additional'] = array(
|
$element['test_formatter_setting_additional'] = array(
|
||||||
|
@ -45,14 +45,16 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
return t('@setting: @value', array('@setting' => 'test_formatter_setting_additional', '@value' => $this->getSetting('test_formatter_setting_additional')));
|
$summary = array();
|
||||||
|
$summary[] = t('@setting: @value', array('@setting' => 'test_formatter_setting_additional', '@value' => $this->getSetting('test_formatter_setting_additional')));
|
||||||
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::prepareView().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function prepareView(array $entities, $langcode, array &$items) {
|
public function prepareView(array $entities, $langcode, array &$items) {
|
||||||
foreach ($items as $id => $item) {
|
foreach ($items as $id => $item) {
|
||||||
|
@ -66,7 +68,7 @@ class TestFieldPrepareViewFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
|
@ -93,10 +93,10 @@ function hook_field_instance_settings_form($field, $instance, $form_state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alter the formatter settings form.
|
* Alters the formatter settings form.
|
||||||
*
|
*
|
||||||
* @param $element
|
* @param $element
|
||||||
* Form array as returned by hook_field_formatter_settings_form().
|
* Form array.
|
||||||
* @param $form_state
|
* @param $form_state
|
||||||
* The form state of the (entire) configuration form.
|
* The form state of the (entire) configuration form.
|
||||||
* @param $context
|
* @param $context
|
||||||
|
@ -106,6 +106,8 @@ function hook_field_instance_settings_form($field, $instance, $form_state) {
|
||||||
* - instance: The instance structure being configured.
|
* - instance: The instance structure being configured.
|
||||||
* - view_mode: The view mode being configured.
|
* - view_mode: The view mode being configured.
|
||||||
* - form: The (entire) configuration form array.
|
* - form: The (entire) configuration form array.
|
||||||
|
*
|
||||||
|
* @see \Drupal\field_ui\DisplayOverView.
|
||||||
*/
|
*/
|
||||||
function hook_field_formatter_settings_form_alter(&$element, &$form_state, $context) {
|
function hook_field_formatter_settings_form_alter(&$element, &$form_state, $context) {
|
||||||
// Add a 'mysetting' checkbox to the settings form for 'foo_field' fields.
|
// Add a 'mysetting' checkbox to the settings form for 'foo_field' fields.
|
||||||
|
@ -119,23 +121,25 @@ function hook_field_formatter_settings_form_alter(&$element, &$form_state, $cont
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Alter the field formatter settings summary.
|
* Alters the field formatter settings summary.
|
||||||
*
|
*
|
||||||
* @param $summary
|
* @param $summary
|
||||||
* The summary as returned by hook_field_formatter_settings_summary().
|
* The summary.
|
||||||
* @param $context
|
* @param $context
|
||||||
* An associative array with the following elements:
|
* An associative array with the following elements:
|
||||||
* - formatter: The formatter object.
|
* - formatter: The formatter object.
|
||||||
* - field: The field structure being configured.
|
* - field: The field structure being configured.
|
||||||
* - instance: The instance structure being configured.
|
* - instance: The instance structure being configured.
|
||||||
* - view_mode: The view mode being configured.
|
* - view_mode: The view mode being configured.
|
||||||
|
*
|
||||||
|
* @see \Drupal\field_ui\DisplayOverView.
|
||||||
*/
|
*/
|
||||||
function hook_field_formatter_settings_summary_alter(&$summary, $context) {
|
function hook_field_formatter_settings_summary_alter(&$summary, $context) {
|
||||||
// Append a message to the summary when an instance of foo_field has
|
// Append a message to the summary when an instance of foo_field has
|
||||||
// mysetting set to TRUE for the current view mode.
|
// mysetting set to TRUE for the current view mode.
|
||||||
if ($context['field']['type'] == 'foo_field') {
|
if ($context['field']['type'] == 'foo_field') {
|
||||||
if ($context['formatter']->getSetting('mysetting')) {
|
if ($context['formatter']->getSetting('mysetting')) {
|
||||||
$summary .= '<br />' . t('My setting enabled.');
|
$summary[] = t('My setting enabled.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -265,9 +265,9 @@ class DisplayOverview extends OverviewBase {
|
||||||
);
|
);
|
||||||
drupal_alter('field_formatter_settings_summary', $summary, $context);
|
drupal_alter('field_formatter_settings_summary', $summary, $context);
|
||||||
|
|
||||||
if ($summary) {
|
if (!empty($summary)) {
|
||||||
$table[$name]['settings_summary'] = array(
|
$table[$name]['settings_summary'] = array(
|
||||||
'#markup' => '<div class="field-formatter-summary">' . $summary . '</div>',
|
'#markup' => '<div class="field-formatter-summary">' . implode('<br />', $summary) . '</div>',
|
||||||
'#cell_attributes' => array('class' => array('field-formatter-summary-cell')),
|
'#cell_attributes' => array('class' => array('field-formatter-summary-cell')),
|
||||||
);
|
);
|
||||||
$table[$name]['settings_edit'] = $base_button + array(
|
$table[$name]['settings_edit'] = $base_button + array(
|
||||||
|
|
|
@ -31,7 +31,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
class ImageFormatter extends FormatterBase {
|
class ImageFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$image_styles = image_style_options(FALSE);
|
$image_styles = image_style_options(FALSE);
|
||||||
|
@ -59,7 +59,7 @@ class ImageFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsSummary().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
$summary = array();
|
$summary = array();
|
||||||
|
@ -87,11 +87,11 @@ class ImageFormatter extends FormatterBase {
|
||||||
$summary[] = $link_types[$image_link_setting];
|
$summary[] = $link_types[$image_link_setting];
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode('<br />', $summary);
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
|
@ -109,7 +109,7 @@ class LinkFormatter extends FormatterBase {
|
||||||
$summary[] = t('Open link in new window');
|
$summary[] = t('Open link in new window');
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode('<br />', $summary);
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Definition of Drupal\number\Plugin\field\formatter\DefaultNumberFormatter.
|
* Contains \Drupal\number\Plugin\field\formatter\DefaultNumberFormatter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Drupal\number\Plugin\field\formatter;
|
namespace Drupal\number\Plugin\field\formatter;
|
||||||
|
@ -18,7 +18,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
abstract class DefaultNumberFormatter extends FormatterBase {
|
abstract class DefaultNumberFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$options = array(
|
$options = array(
|
||||||
|
@ -48,7 +48,7 @@ abstract class DefaultNumberFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
$summary = array();
|
$summary = array();
|
||||||
|
@ -58,11 +58,11 @@ abstract class DefaultNumberFormatter extends FormatterBase {
|
||||||
$summary[] = t('Display with prefix and suffix.');
|
$summary[] = t('Display with prefix and suffix.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode('<br />', $summary);
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
* Definition of Drupal\picture\Plugin\field\formatter\PictureFormatter.
|
* Contains \Drupal\picture\Plugin\field\formatter\PictureFormatter.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Drupal\picture\Plugin\field\formatter;
|
namespace Drupal\picture\Plugin\field\formatter;
|
||||||
|
@ -32,7 +32,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
class PictureFormatter extends FormatterBase {
|
class PictureFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$picture_options = array();
|
$picture_options = array();
|
||||||
|
@ -78,7 +78,7 @@ class PictureFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
$summary = array();
|
$summary = array();
|
||||||
|
@ -109,11 +109,11 @@ class PictureFormatter extends FormatterBase {
|
||||||
$summary[] = t('Select a picture mapping.');
|
$summary[] = t('Select a picture mapping.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return implode('<br />', $summary);
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
|
@ -30,7 +30,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
class TelephoneLinkFormatter extends FormatterBase {
|
class TelephoneLinkFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$elements['title'] = array(
|
$elements['title'] = array(
|
||||||
|
@ -43,23 +43,24 @@ class TelephoneLinkFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsSummary().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
|
$summary = array();
|
||||||
$settings = $this->getSettings();
|
$settings = $this->getSettings();
|
||||||
|
|
||||||
if (!empty($settings['title'])) {
|
if (!empty($settings['title'])) {
|
||||||
$summary = t('Link using text: @title', array('@title' => $settings['title']));
|
$summary[] = t('Link using text: @title', array('@title' => $settings['title']));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$summary = t('Link using provided telephone number.');
|
$summary[] = t('Link using provided telephone number.');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $summary;
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::prepareView().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function prepareView(array $entities, $langcode, array &$items) {
|
public function prepareView(array $entities, $langcode, array &$items) {
|
||||||
$settings = $this->getSettings();
|
$settings = $this->getSettings();
|
||||||
|
@ -79,7 +80,7 @@ class TelephoneLinkFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$element = array();
|
$element = array();
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
/**
|
/**
|
||||||
* @file
|
* @file
|
||||||
*
|
*
|
||||||
* Definition of Drupal\text\Plugin\field\formatter\TextTrimmedFormatter.
|
* Contains \Drupal\text\Plugin\field\formatter\TextTrimmedFormatter.
|
||||||
*/
|
*/
|
||||||
namespace Drupal\text\Plugin\field\formatter;
|
namespace Drupal\text\Plugin\field\formatter;
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ use Drupal\Core\Entity\EntityInterface;
|
||||||
class TextTrimmedFormatter extends FormatterBase {
|
class TextTrimmedFormatter extends FormatterBase {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsForm().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsForm(array $form, array &$form_state) {
|
public function settingsForm(array $form, array &$form_state) {
|
||||||
$element['trim_length'] = array(
|
$element['trim_length'] = array(
|
||||||
|
@ -54,16 +54,16 @@ class TextTrimmedFormatter extends FormatterBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::settingsSummary().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function settingsSummary() {
|
public function settingsSummary() {
|
||||||
return t('Trim length: @trim_length', array(
|
$summary = array();
|
||||||
'@trim_length' => $this->getSetting('trim_length'),
|
$summary[] = t('Trim length: @trim_length', array('@trim_length' => $this->getSetting('trim_length')));
|
||||||
));
|
return $summary;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements Drupal\field\Plugin\Type\Formatter\FormatterInterface::viewElements().
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
public function viewElements(EntityInterface $entity, $langcode, array $items) {
|
||||||
$elements = array();
|
$elements = array();
|
||||||
|
|
Loading…
Reference in New Issue