From e462570d9df590bb40af8cc319708e52ca3b60c2 Mon Sep 17 00:00:00 2001 From: Korina Cordero Date: Fri, 22 Nov 2019 03:27:16 +0000 Subject: [PATCH] Remove dotenv implementation from setting of customer privacy policy. #275 --- config/services.yaml | 6 +++++ src/Command/ImportPartnersCommand.php | 2 +- .../SetCustomerPrivacyPolicyCommand.php | 26 +++++++++---------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/config/services.yaml b/config/services.yaml index c6f2f877..5e1b95c5 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -91,6 +91,12 @@ services: arguments: $geofence_flag: "%env(GEOFENCE_ENABLE)%" + App\Command\SetCustomerPrivacyPolicyCommand: + arguments: + $policy_promo: "%env(POLICY_PROMO)%" + $policy_third_party: "%env(POLICY_THIRD_PARTY)%" + $policy_mobile: "%env(POLICY_MOBILE)%" + Catalyst\APIBundle\Security\APIKeyUserProvider: arguments: $em: "@doctrine.orm.entity_manager" diff --git a/src/Command/ImportPartnersCommand.php b/src/Command/ImportPartnersCommand.php index 526fb282..74e02d5b 100644 --- a/src/Command/ImportPartnersCommand.php +++ b/src/Command/ImportPartnersCommand.php @@ -34,7 +34,7 @@ class ImportPartnersCommand extends Command protected $em; - public function __construct(Objectmanager $om) + public function __construct(ObjectManager $om) { $this->em = $om; diff --git a/src/Command/SetCustomerPrivacyPolicyCommand.php b/src/Command/SetCustomerPrivacyPolicyCommand.php index d4431175..4132fa91 100644 --- a/src/Command/SetCustomerPrivacyPolicyCommand.php +++ b/src/Command/SetCustomerPrivacyPolicyCommand.php @@ -7,7 +7,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Dotenv\Dotenv; use Doctrine\Common\Persistence\ObjectManager; @@ -19,10 +18,19 @@ class SetCustomerPrivacyPolicyCommand extends Command { private $em; - public function __construct(ObjectManager $om) + private $policy_promo_id; + private $policy_third_party_id; + private $policy_mobile_id; + + public function __construct(ObjectManager $om, $policy_promo, + $policy_third_party, $policy_mobile) { $this->em = $om; + $this->policy_promo_id = $policy_promo; + $this->policy_third_party_id = $policy_third_party; + $this->policy_mobile_id = $policy_mobile; + parent::__construct(); } @@ -35,16 +43,8 @@ class SetCustomerPrivacyPolicyCommand extends Command protected function execute(InputInterface $input, OutputInterface $output) { - // get the policy ids from .env - $dotenv = new Dotenv(); - $dotenv->loadEnv(__DIR__.'/../../.env'); - - $policy_promo_id = $_ENV['POLICY_PROMO']; - $policy_third_party_id = $_ENV['POLICY_THIRD_PARTY']; - $policy_mobile_id = $_ENV['POLICY_MOBILE']; - // get third party policy - $third_party_policy = $this->em->getRepository(PrivacyPolicy::class)->find($policy_third_party_id); + $third_party_policy = $this->em->getRepository(PrivacyPolicy::class)->find($this->policy_third_party_id); // get customers on third party $third_party_customers = $this->em->getRepository(Customer::class)->findBy(['priv_third_party' => true]); @@ -54,7 +54,7 @@ class SetCustomerPrivacyPolicyCommand extends Command } // get promo policy - $promo_policy = $this->em->getRepository(PrivacyPolicy::class)->find($policy_promo_id); + $promo_policy = $this->em->getRepository(PrivacyPolicy::class)->find($this->policy_promo_id); // get customers on promo $promo_customers = $this->em->getRepository(Customer::class)->findBy(['priv_promo' => true]); @@ -66,7 +66,7 @@ class SetCustomerPrivacyPolicyCommand extends Command $this->em->flush(); // get mobile policy - $mobile_policy = $this->em->getRepository(PrivacyPolicy::class)->find($policy_mobile_id); + $mobile_policy = $this->em->getRepository(PrivacyPolicy::class)->find($this->policy_mobile_id); // get mobile sessions $mobile_sessions = $this->em->getRepository(MobileSession::class)->findAll();