Commit e6456b6f authored by akoepke's avatar akoepke
Browse files

Raw URL output of SoundCloud field value

parent 9587ca87
<?php
namespace Drupal\soundcloudfield\Plugin\Field\FieldFormatter;
use Drupal\Component\Utility\Unicode;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Plugin implementation of the 'soundcloud_url' formatter.
*
* @FieldFormatter(
* id = "soundcloud_url",
* module = "soundcloudfield",
* label = @Translation("Raw output of SoundCloud URI"),
* field_types = {
* "soundcloud"
* }
* )
*/
class SoundCloudURLFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = array();
foreach ($items as $delta => $item) {
if (!$item->isEmpty()) {
$elements[$delta]['#markup'] = $item->url;
}
}
return $elements;
}
}
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