Add the WarrantyHandler service. Move the computeDateExpire to the service. #286
This commit is contained in:
parent
0a6c6eebfb
commit
bd2ea5fba3
3 changed files with 45 additions and 8 deletions
|
|
@ -91,6 +91,10 @@ services:
|
||||||
arguments:
|
arguments:
|
||||||
$geofence_flag: "%env(GEOFENCE_ENABLE)%"
|
$geofence_flag: "%env(GEOFENCE_ENABLE)%"
|
||||||
|
|
||||||
|
App\Service\WarrantyHandler:
|
||||||
|
arguments:
|
||||||
|
$em: "@doctrine.orm.entity_manager"
|
||||||
|
|
||||||
App\Command\SetCustomerPrivacyPolicyCommand:
|
App\Command\SetCustomerPrivacyPolicyCommand:
|
||||||
arguments:
|
arguments:
|
||||||
$policy_promo: "%env(POLICY_PROMO)%"
|
$policy_promo: "%env(POLICY_PROMO)%"
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,8 @@ use Doctrine\Common\Persistence\ObjectManager;
|
||||||
use App\Entity\Warranty;
|
use App\Entity\Warranty;
|
||||||
use App\Entity\Battery;
|
use App\Entity\Battery;
|
||||||
|
|
||||||
|
use App\Service\WarrantyHandler;
|
||||||
|
|
||||||
use App\Ramcar\WarrantyClass;
|
use App\Ramcar\WarrantyClass;
|
||||||
|
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
|
@ -20,10 +22,12 @@ use DateInterval;
|
||||||
class ComputeWarrantyExpiryDateCommand extends Command
|
class ComputeWarrantyExpiryDateCommand extends Command
|
||||||
{
|
{
|
||||||
protected $em;
|
protected $em;
|
||||||
|
protected $wh;
|
||||||
|
|
||||||
public function __construct(ObjectManager $em)
|
public function __construct(ObjectManager $em, WarrantyHandler $wh)
|
||||||
{
|
{
|
||||||
$this->em = $em;
|
$this->em = $em;
|
||||||
|
$this->wh = $wh;
|
||||||
|
|
||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
@ -51,7 +55,7 @@ class ComputeWarrantyExpiryDateCommand extends Command
|
||||||
|
|
||||||
if ($warr_period != null)
|
if ($warr_period != null)
|
||||||
{
|
{
|
||||||
$expiry_date = $this->computeDateExpire($date_purchase, $warr_period);
|
$expiry_date = $this->wh->computeDateExpire($date_purchase, $warr_period);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -156,10 +160,4 @@ class ComputeWarrantyExpiryDateCommand extends Command
|
||||||
return $warranty_period;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
35
src/Service/WarrantyHandler.php
Normal file
35
src/Service/WarrantyHandler.php
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Service;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
|
use App\Entity\Warranty;
|
||||||
|
|
||||||
|
use DateTime;
|
||||||
|
use DateInterval;
|
||||||
|
|
||||||
|
class WarrantyHandler
|
||||||
|
{
|
||||||
|
protected $em;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $em)
|
||||||
|
{
|
||||||
|
$this->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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue