Commit c6794606 authored by alexpott's avatar alexpott
Browse files

Issue #2035317 by andypost, hussainweb | dawehner: DateTimeDefaultWidget...

Issue #2035317 by andypost, hussainweb | dawehner: DateTimeDefaultWidget should implement ContainerFactoryPluginInterface.
parent a0e5302d
......@@ -6,10 +6,13 @@
namespace Drupal\datetime\Plugin\Field\FieldWidget;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\WidgetBase;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\datetime\Plugin\Field\FieldType\DateTimeItem;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Plugin implementation of the 'datetime_default' widget.
......@@ -22,7 +25,7 @@
* }
* )
*/
class DateTimeDefaultWidget extends WidgetBase {
class DateTimeDefaultWidget extends WidgetBase implements ContainerFactoryPluginInterface {
/**
* The date format storage.
......@@ -34,11 +37,24 @@ class DateTimeDefaultWidget extends WidgetBase {
/**
* {@inheritdoc}
*/
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings) {
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, EntityStorageInterface $date_storage) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
// @todo Inject this once https://drupal.org/node/2035317 is in.
$this->dateStorage = \Drupal::entityManager()->getStorage('date_format');
$this->dateStorage = $date_storage;
}
/**
* {@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['third_party_settings'],
$container->get('entity.manager')->getStorage('date_format')
);
}
/**
......
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