From bd2ea5fba31fd544111ccf6485ba30a0deabf869 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Mon, 16 Dec 2019 07:29:25 +0000 Subject: [PATCH] Add the WarrantyHandler service. Move the computeDateExpire to the service. #286 --- config/services.yaml | 4 +++ .../ComputeWarrantyExpiryDateCommand.php | 14 ++++---- src/Service/WarrantyHandler.php | 35 +++++++++++++++++++ 3 files changed, 45 insertions(+), 8 deletions(-) create mode 100644 src/Service/WarrantyHandler.php diff --git a/config/services.yaml b/config/services.yaml index 42044b7d..14a5e6c8 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -91,6 +91,10 @@ services: arguments: $geofence_flag: "%env(GEOFENCE_ENABLE)%" + App\Service\WarrantyHandler: + arguments: + $em: "@doctrine.orm.entity_manager" + App\Command\SetCustomerPrivacyPolicyCommand: arguments: $policy_promo: "%env(POLICY_PROMO)%" diff --git a/src/Command/ComputeWarrantyExpiryDateCommand.php b/src/Command/ComputeWarrantyExpiryDateCommand.php index 7f206cc5..ee49b02d 100644 --- a/src/Command/ComputeWarrantyExpiryDateCommand.php +++ b/src/Command/ComputeWarrantyExpiryDateCommand.php @@ -12,6 +12,8 @@ use Doctrine\Common\Persistence\ObjectManager; use App\Entity\Warranty; use App\Entity\Battery; +use App\Service\WarrantyHandler; + use App\Ramcar\WarrantyClass; use DateTime; @@ -20,10 +22,12 @@ use DateInterval; class ComputeWarrantyExpiryDateCommand extends Command { protected $em; + protected $wh; - public function __construct(ObjectManager $em) + public function __construct(ObjectManager $em, WarrantyHandler $wh) { $this->em = $em; + $this->wh = $wh; parent::__construct(); } @@ -51,7 +55,7 @@ class ComputeWarrantyExpiryDateCommand extends Command if ($warr_period != null) { - $expiry_date = $this->computeDateExpire($date_purchase, $warr_period); + $expiry_date = $this->wh->computeDateExpire($date_purchase, $warr_period); } else { @@ -156,10 +160,4 @@ class ComputeWarrantyExpiryDateCommand extends Command return $warranty_period; } - protected function computeDateExpire($date_create, $warranty_period) - { - $expire_date = clone $date_create; - $expire_date->add(new DateInterval('P'.$warranty_period.'M')); - return $expire_date; - } } diff --git a/src/Service/WarrantyHandler.php b/src/Service/WarrantyHandler.php new file mode 100644 index 00000000..3e9018c5 --- /dev/null +++ b/src/Service/WarrantyHandler.php @@ -0,0 +1,35 @@ +em = $em; + } + + public function createWarranty() + { + } + + public function updateWarranty() + { + } + + public function computeDateExpire($date_create, $warranty_period) + { + $expire_date = clone $date_create; + $expire_date->add(new DateInterval('P'.$warranty_period.'M')); + return $expire_date; + } +}