Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
soundcloudfield
Commits
e6456b6f
Commit
e6456b6f
authored
Oct 15, 2021
by
akoepke
Browse files
Raw URL output of SoundCloud field value
parent
9587ca87
Changes
1
Show whitespace changes
Inline
Side-by-side
src/Plugin/Field/FieldFormatter/SoundCloudURLFormatter.php
0 → 100644
View file @
e6456b6f
<?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
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment