diff --git a/field_example/field_example.module b/field_example/field_example.module index d430c13..a68feb3 100755 --- a/field_example/field_example.module +++ b/field_example/field_example.module @@ -44,6 +44,24 @@ */ /** + * Implements hook_menu(). + * + * We will define a single menu route, so that we can give the user some + * helpful introductory information. + * + * @return array + * Complex array describing our menu item. + */ +function field_example_menu() { + $items['examples/field_example'] = array( + 'title' => 'Field Example', + 'route_name' => 'field_example_page', + 'expanded' => TRUE, + ); + return $items; +} + +/** * Validate and clean up the input on single text field entry. */ function field_example_text_validate($element, &$form_state) { diff --git a/field_example/lib/Drupal/field_example/Controller/FieldExampleController.php b/field_example/lib/Drupal/field_example/Controller/FieldExampleController.php index c1c4b11..df3877f 100644 --- a/field_example/lib/Drupal/field_example/Controller/FieldExampleController.php +++ b/field_example/lib/Drupal/field_example/Controller/FieldExampleController.php @@ -8,20 +8,11 @@ namespace Drupal\field_example\Controller; use Drupal\Core\Controller\ControllerBase; -use Drupal\Core\DependencyInjection\ContainerInjectionInterface; -use Symfony\Component\DependencyInjection\ContainerInterface; /** * Returns responses for dblog routes. */ -class FieldExampleController extends ControllerBase implements ContainerInjectionInterface { - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container) { - return new static(); - } +class FieldExampleController extends ControllerBase { /** * A simple page to explain to the developer what to do. diff --git a/field_example/lib/Drupal/field_example/Plugin/Field/FieldFormatter/SimpleTextFormatter.php b/field_example/lib/Drupal/field_example/Plugin/Field/FieldFormatter/SimpleTextFormatter.php index 2df1c07..2d65454 100755 --- a/field_example/lib/Drupal/field_example/Plugin/Field/FieldFormatter/SimpleTextFormatter.php +++ b/field_example/lib/Drupal/field_example/Plugin/Field/FieldFormatter/SimpleTextFormatter.php @@ -15,6 +15,7 @@ use Drupal\Core\Field\FieldItemListInterface; * * @FieldFormatter( * id = "field_example_simple_text", + * module = "field_example", * label = @Translation("Simple text-based formatter"), * field_types = { * "field_example_rgb" diff --git a/field_example/lib/Drupal/field_example/Plugin/Field/FieldType/RgbItem.php b/field_example/lib/Drupal/field_example/Plugin/Field/FieldType/RgbItem.php index 139904f..576dcd8 100755 --- a/field_example/lib/Drupal/field_example/Plugin/Field/FieldType/RgbItem.php +++ b/field_example/lib/Drupal/field_example/Plugin/Field/FieldType/RgbItem.php @@ -9,6 +9,7 @@ namespace Drupal\field_example\Plugin\Field\FieldType; use Drupal\Core\Field\ConfigFieldItemBase; use Drupal\field\FieldInterface; +use Drupal\Core\TypedData\DataDefinition; /** * Plugin implementation of the 'field_example_rgb' field type. @@ -16,8 +17,9 @@ use Drupal\field\FieldInterface; * @FieldType( * id = "field_example_rgb", * label = @Translation("Example Color RGB"), + * module = "field_example", * description = @Translation("Demonstrates a field composed of an RGB color."), - * default_widget = "field_example_3text", + * default_widget = "field_example_text", * default_formatter = "field_example_simple_text" * ) */ @@ -35,10 +37,8 @@ class RgbItem extends ConfigFieldItemBase { */ public function getPropertyDefinitions() { if (!isset(static::$propertyDefinitions)) { - static::$propertyDefinitions['value'] = array( - 'type' => 'string', - 'label' => t('Hex value'), - ); + static::$propertyDefinitions['value'] = DataDefinition::create('string') + ->setLabel(t('Hex value')); } return static::$propertyDefinitions; } diff --git a/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/ColorPickerWidget.php b/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/ColorPickerWidget.php index 354305b..f6882d1 100755 --- a/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/ColorPickerWidget.php +++ b/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/ColorPickerWidget.php @@ -13,6 +13,7 @@ use Drupal\Core\Field\FieldItemListInterface; * * @FieldWidget( * id = "field_example_colorpicker", + * module = "field_example", * label = @Translation("Color Picker"), * field_types = { * "field_example_rgb" diff --git a/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/Text3Widget.php b/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/Text3Widget.php index 130b77d..2fa5743 100755 --- a/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/Text3Widget.php +++ b/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/Text3Widget.php @@ -15,6 +15,7 @@ use Drupal\Core\Field\WidgetBase; * * @FieldWidget( * id = "field_example_3text", + * module = "field_example", * label = @Translation("RGB text field"), * field_types = { * "field_example_rgb" diff --git a/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/TextWidget.php b/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/TextWidget.php index 68fad7b..a3e1ca8 100755 --- a/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/TextWidget.php +++ b/field_example/lib/Drupal/field_example/Plugin/Field/FieldWidget/TextWidget.php @@ -15,6 +15,7 @@ use Drupal\Core\Field\WidgetBase; * * @FieldWidget( * id = "field_example_text", + * module = "field_example", * label = @Translation("RGB value as #ffffff"), * field_types = { * "field_example_rgb"