Commit 164b14d1 authored by ephoto_dam's avatar ephoto_dam

Dev Ephoto Dam Field in progress

parent 0fdd4d57
display:
version: 1.x
header: true
js:
js/ephoto_dam.js: {}
css:
component:
css/ephoto_dam.css: {}
header: true
dependencies:
- core/jquery
settings:
header: true
css:
component:
plugin/plugin.css: {}
header: true
plugin/plugin.css: {}
edit:
version: 1.x
header: true
js:
js/ephoto_dam_field.js: {}
css:
component:
css/ephoto_dam_field.css: {}
header: true
dependencies:
- core/jquery
- core/jquery.cookie
<?php
namespace Drupal\ephoto_dam_field\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FormatterBase;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Plugin implementation of Ephoto Dam Field formatter.
*
* @FieldFormatter(
* id = "ephoto_dam_field_formatter",
* label = @Translation("Ephoto Dam Field"),
* field_types = {
* "ephoto_dam_field"
* }
* )
*/
class EphotoDamFieldFormatter extends FormatterBase implements ContainerFactoryPluginInterface {
/**
* Constructs a new instance of the plugin.
*
* @param string $plugin_id
* The plugin_id for the formatter.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition
* The definition of the field to which the formatter is associated.
* @param array $settings
* The formatter settings.
* @param string $label
* The formatter label display setting.
* @param string $view_mode
* The view mode.
* @param array $third_party_settings
* Third party settings.
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, $settings, $label, $view_mode, $third_party_settings) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$plugin_id,
$plugin_definition,
$configuration['field_definition'],
$configuration['settings'],
$configuration['label'],
$configuration['view_mode'],
$configuration['third_party_settings']
);
}
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$element = [];
return $element;
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ use Drupal\Core\TypedData\TraversableTypedDataInterface;
* description = @Translation("Stores a Ephoto Dam URL and then outputs some embed code"),
* category = @Translation("Media"),
* default_widget = "ephoto_dam_field_widget",
* default_formatter = "ephoto_dam_field_formatter"
* )
*/
class EphotoDamField extends FieldItemBase {
......
......@@ -11,15 +11,15 @@ use Drupal\Core\Form\FormStateInterface;
*
* @FieldWidget(
* id = "ephoto_dam_field_widget",
* label = @Translation("Ephoto Dam Field Widget"),
* label = @Translation("Ephoto Dam Field"),
* field_types = {
* "ephoto_dam"
* "ephoto_dam_field"
* },
* )
*/
class EphotoDamFieldWidget extends WidgetBase {
static bool $first = true;
private $_first = true;
/**
* {@inheritdoc}
......@@ -28,7 +28,7 @@ class EphotoDamFieldWidget extends WidgetBase {
$is_default_values_form = $this->isDefaultValueWidget($form_state);
$version_support = $this->getFieldSetting('version_support');
if (self::$first) {
if ($this->$_first) {
$classes = ['button', 'ephoto-dam-field-button', 'ephoto-dam-field-versions-button'];
if (!$version_support) $classes[] = 'ephoto-dam-field-hidden';
......@@ -42,7 +42,7 @@ class EphotoDamFieldWidget extends WidgetBase {
],
];
self::$first = false;
$this->$_first = false;
}
$classes = ['ephoto-dam-field-field', 'ephoto-dam-field-url-field'];
......
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