summaryrefslogtreecommitdiffstats
path: root/src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php
diff options
context:
space:
mode:
authorarshad2017-05-02 21:39:49 +0200
committerMateu Aguiló Bosch2017-05-02 21:39:59 +0200
commit03fc3daf459ab9b9119c91dbbccf79eed4c94f84 (patch)
treec7e0be6ae5fdbc73a4457c91958f79f826ef06df /src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php
parent628896b7fe61a649cb5237a8fe212c52e86018ee (diff)
refactor(DX): Add a ResourceFieldEnhancerBase (#2874501 by arshadcn)
Diffstat (limited to 'src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php')
-rw-r--r--src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php42
1 files changed, 3 insertions, 39 deletions
diff --git a/src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php b/src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php
index 4f5aee2..622e257 100644
--- a/src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php
+++ b/src/Plugin/jsonapi/FieldEnhancer/DateTimeEnhancer.php
@@ -2,11 +2,7 @@
namespace Drupal\jsonapi_extras\Plugin\jsonapi\FieldEnhancer;
-use Drupal\Core\Annotation\Translation;
-use Drupal\Core\Plugin\PluginBase;
-use Drupal\Core\StringTranslation\StringTranslationTrait;
-use Drupal\jsonapi_extras\Annotation\ResourceFieldEnhancer;
-use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerInterface;
+use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerBase;
/**
* Perform additional manipulations to date fields.
@@ -14,25 +10,10 @@ use Drupal\jsonapi_extras\Plugin\ResourceFieldEnhancerInterface;
* @ResourceFieldEnhancer(
* id = "date_time",
* label = @Translation("Date Time"),
- * description = @Translation("Transform a data format into anothed different based the configured date format.")
+ * description = @Translation("Formats a date based the configured date format.")
* )
*/
-class DateTimeEnhancer extends PluginBase implements ResourceFieldEnhancerInterface {
-
- /**
- * Holds the plugin configuration.
- *
- * @var array
- */
- protected $configuration;
-
- /**
- * {@inheritdoc}
- */
- public function calculateDependencies() {
- // TODO: This should have a dependency on the resource_config configuration entity.
- return [];
- }
+class DateTimeEnhancer extends ResourceFieldEnhancerBase {
/**
* {@inheritdoc}
@@ -46,23 +27,6 @@ class DateTimeEnhancer extends PluginBase implements ResourceFieldEnhancerInterf
/**
* {@inheritdoc}
*/
- public function getConfiguration() {
- return $this->configuration
- ? $this->configuration
- : $this->setConfiguration([]);
- }
-
- /**
- * {@inheritdoc}
- */
- public function setConfiguration(array $configuration) {
- $this->configuration = $configuration + $this->defaultConfiguration();
- return $this->configuration;
- }
-
- /**
- * {@inheritdoc}
- */
public function postProcess($value) {
$date = new \DateTime();
$date->setTimestamp($value);