diff --git a/src/Command/AdjustLongLatCommand.php b/src/Command/AdjustLongLatCommand.php index b7e26ad1..62405269 100644 --- a/src/Command/AdjustLongLatCommand.php +++ b/src/Command/AdjustLongLatCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\JobOrder; @@ -17,9 +17,9 @@ class AdjustLongLatCommand extends Command { protected $em; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } diff --git a/src/Command/ComputeWarrantyExpiryDateCommand.php b/src/Command/ComputeWarrantyExpiryDateCommand.php index 383370f7..cffc24ef 100644 --- a/src/Command/ComputeWarrantyExpiryDateCommand.php +++ b/src/Command/ComputeWarrantyExpiryDateCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Battery; @@ -18,7 +18,7 @@ class ComputeWarrantyExpiryDateCommand extends Command protected $em; protected $wh; - public function __construct(ObjectManager $em, WarrantyHandler $wh) + public function __construct(EntityManagerInterface $em, WarrantyHandler $wh) { $this->em = $em; $this->wh = $wh; diff --git a/src/Command/CreateCustomerFromWarrantyCommand.php b/src/Command/CreateCustomerFromWarrantyCommand.php index 91684217..42b2fe73 100644 --- a/src/Command/CreateCustomerFromWarrantyCommand.php +++ b/src/Command/CreateCustomerFromWarrantyCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Warranty; use App\Entity\Customer; @@ -33,7 +33,7 @@ class CreateCustomerFromWarrantyCommand extends Command protected $cvu_mfg_id; protected $cvu_brand_id; - public function __construct(ObjectManager $em, $cvu_mfg_id, $cvu_brand_id) + public function __construct(EntityManagerInterface $em, $cvu_mfg_id, $cvu_brand_id) { $this->em = $em; diff --git a/src/Command/FulfillOldJobOrderCommand.php b/src/Command/FulfillOldJobOrderCommand.php index a0cabd57..dc987e8b 100644 --- a/src/Command/FulfillOldJobOrderCommand.php +++ b/src/Command/FulfillOldJobOrderCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\JobOrder; use App\Entity\JOEvent; @@ -22,9 +22,9 @@ class FulfillOldJobOrderCommand extends Command { protected $em; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } diff --git a/src/Command/FulfillPendingJobOrderCommand.php b/src/Command/FulfillPendingJobOrderCommand.php index 22180186..0c1fe7b0 100644 --- a/src/Command/FulfillPendingJobOrderCommand.php +++ b/src/Command/FulfillPendingJobOrderCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\JobOrder; use App\Entity\JOEvent; @@ -22,9 +22,9 @@ class FulfillPendingJobOrderCommand extends Command { protected $em; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } diff --git a/src/Command/GenerateBatteryCompatibilityCommand.php b/src/Command/GenerateBatteryCompatibilityCommand.php index 57e20076..ec0a1843 100644 --- a/src/Command/GenerateBatteryCompatibilityCommand.php +++ b/src/Command/GenerateBatteryCompatibilityCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\VehicleManufacturer; use App\Entity\Vehicle; @@ -21,9 +21,9 @@ class GenerateBatteryCompatibilityCommand extends Command protected $em; protected $vmfg_index; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } diff --git a/src/Command/GenerateWarrantyFromJobOrderCommand.php b/src/Command/GenerateWarrantyFromJobOrderCommand.php index 86653d97..1d3f100b 100644 --- a/src/Command/GenerateWarrantyFromJobOrderCommand.php +++ b/src/Command/GenerateWarrantyFromJobOrderCommand.php @@ -10,7 +10,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\JobOrder; use App\Entity\Warranty; @@ -25,7 +25,7 @@ class GenerateWarrantyFromJobOrderCommand extends Command protected $sapbatt_hash; protected $warranties_hash; - public function __construct(ObjectManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; diff --git a/src/Command/ImportBatteryPriceCommand.php b/src/Command/ImportBatteryPriceCommand.php index 02bbbea9..12fade3a 100644 --- a/src/Command/ImportBatteryPriceCommand.php +++ b/src/Command/ImportBatteryPriceCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use CrEOF\Spatial\PHP\Types\Geometry\Point; use DateTime; @@ -30,9 +30,9 @@ class ImportBatteryPriceCommand extends Command protected $em; protected $size_index; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->size_index = []; parent::__construct(); diff --git a/src/Command/ImportCustomerCommand.php b/src/Command/ImportCustomerCommand.php index f6babefc..4c0e75e7 100644 --- a/src/Command/ImportCustomerCommand.php +++ b/src/Command/ImportCustomerCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use DateTime; @@ -49,7 +49,7 @@ class ImportCustomerCommand extends Command protected $mfg_index; protected $vehicle_index; - public function __construct(ObjectManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; $this->populateMfgIndex(); diff --git a/src/Command/ImportLegacyJobOrderCommand.php b/src/Command/ImportLegacyJobOrderCommand.php index 7546880b..76e30d10 100644 --- a/src/Command/ImportLegacyJobOrderCommand.php +++ b/src/Command/ImportLegacyJobOrderCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Warranty; use App\Entity\Battery; @@ -44,9 +44,9 @@ class ImportLegacyJobOrderCommand extends Command protected $row_max_field_size; protected $data_max_field_size; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->loadBatteryModels(); $this->loadBatterySizes(); diff --git a/src/Command/ImportOutletsCommand.php b/src/Command/ImportOutletsCommand.php index dbcb5979..1558b74e 100644 --- a/src/Command/ImportOutletsCommand.php +++ b/src/Command/ImportOutletsCommand.php @@ -7,7 +7,8 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; -use Doctrine\Common\Persistence\ObjectManager; + +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Outlet; use App\Entity\Hub; @@ -17,11 +18,11 @@ use DateTime; class ImportOutletsCommand extends Command { - private $object_manager; + private $em; - public function __construct(ObjectManager $om, ValidatorInterface $validator) + public function __construct(EntityManagerInterface $em, ValidatorInterface $validator) { - $this->object_manager = $om; + $this->em = $em; $this->validator = $validator; parent::__construct(); @@ -60,7 +61,7 @@ class ImportOutletsCommand extends Command } // get entity manager - $em = $this->object_manager; + $em = $this->em; // row counter $row = 1; diff --git a/src/Command/ImportPartnersCommand.php b/src/Command/ImportPartnersCommand.php index 74e02d5b..1a09df6d 100644 --- a/src/Command/ImportPartnersCommand.php +++ b/src/Command/ImportPartnersCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use CrEOF\Spatial\PHP\Types\Geometry\Point; use DateTime; @@ -34,9 +34,9 @@ class ImportPartnersCommand extends Command protected $em; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } diff --git a/src/Command/ImportSAPBatteryCommand.php b/src/Command/ImportSAPBatteryCommand.php index fcd54f7d..9189a0e5 100644 --- a/src/Command/ImportSAPBatteryCommand.php +++ b/src/Command/ImportSAPBatteryCommand.php @@ -7,7 +7,8 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Validator\Validator\ValidatorInterface; -use Doctrine\Common\Persistence\ObjectManager; + +use Doctrine\ORM\EntityManagerInterface; use App\Entity\SAPBattery; use App\Entity\SAPBatteryBrand; @@ -22,7 +23,7 @@ class ImportSAPBatteryCommand extends Command private $batt_size_hash; private $batt_brand_hash; - public function __construct(ObjectManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; $this->initBatteryHash(); @@ -37,12 +38,14 @@ class ImportSAPBatteryCommand extends Command $this->setName('sap_battery:import') ->setDescription('Import a CSV file with SAP battery data.') ->setHelp('Creates SAP battery data entries off imported CSV.') - ->addArgument('file', InputArgument::REQUIRED, 'Path to the CSV file.'); + ->addArgument('file', InputArgument::REQUIRED, 'Path to the CSV file.') + ->addArgument('output_file', InputArgument::REQUIRED, 'Path to the output CSV file.'); } protected function execute(InputInterface $input, OutputInterface $output) { $csv_file = $input->getArgument('file'); + $report_file = $input->getArgument('output_file'); // CSV column order: // 0 - brand @@ -68,6 +71,9 @@ class ImportSAPBatteryCommand extends Command // has error? $has_error = false; + $dupe_brands = []; + $dupe_sizes = []; + $dupe_batteries = []; // loop through rows and build hashes while (($fields = fgetcsv($handle)) !== false) { @@ -77,7 +83,7 @@ class ImportSAPBatteryCommand extends Command // clean up fields $clean_brand = trim($fields[0]); - $clean_sku = trim($fields[1]); + $clean_sku = strtoupper(trim($fields[1])); $clean_size = trim($fields[2]); $output->writeln("Parsing $clean_sku..."); @@ -92,6 +98,11 @@ class ImportSAPBatteryCommand extends Command $this->batt_brand_hash[$clean_brand] = $brand; } + else + { + // add to duplicate list + $dupe_brands[] = $clean_brand; + } // size hash if (!isset($this->batt_size_hash[$clean_size])) @@ -103,6 +114,10 @@ class ImportSAPBatteryCommand extends Command $this->batt_size_hash[$clean_size] = $size; } + else + { + $dupe_sizes[] = $clean_size; + } // battery hash if (!isset($this->battery_hash[$clean_sku])) @@ -110,14 +125,26 @@ class ImportSAPBatteryCommand extends Command // create battery entry $battery = new SAPBattery(); $battery->setID($clean_sku) - ->setSize($size_hash[$clean_size]) - ->setBrand($brand_hash[$clean_brand]); + ->setSize($this->batt_size_hash[$clean_size]) + ->setBrand($this->batt_brand_hash[$clean_brand]); $em->persist($battery); } + else + { + $dupe_batteries[] = $clean_sku; + } } $em->flush(); + + // write dupes report + if ((count($dupe_brands) > 0) || + (count($dupe_sizes) > 0) || + (count($dupe_batteries) > 0)) + { + $this->writeDupeReport($report_file, $dupe_brands, $dupe_sizes, $dupe_batteries); + } } protected function initBatteryHash() @@ -146,4 +173,40 @@ class ImportSAPBatteryCommand extends Command foreach ($brands as $brand) $this->batt_brand_hash[$brand->getName()] = $brand; } + + protected function writeDupeReport($report_file, $brands, $sizes, $batts) + { + try + { + $fh = fopen($report_file, "w"); + } + catch (Exception $e) + { + throw new Exception('The file "' . $report_file . '" could be opened.'); + } + + fputs($fh, 'Brands not added: ' . "\n"); + foreach ($brands as $brand) + { + fputs($fh, $brand, strlen($brand)); + fputs($fh, "\n"); + } + + fputs($fh, 'Sizes not added: ' . "\n"); + foreach ($sizes as $size) + { + fputs($fh, $size, strlen($size)); + fputs($fh, "\n"); + } + + fputs($fh, 'SKUs not added: ' . "\n"); + foreach ($batts as $batt) + { + fputs($fh, $batt, strlen($batt)); + fputs($fh, "\n"); + } + + fclose($fh); + + } } diff --git a/src/Command/ImportVehicleBatteryCommand.php b/src/Command/ImportVehicleBatteryCommand.php index 93c0bd77..c3511330 100644 --- a/src/Command/ImportVehicleBatteryCommand.php +++ b/src/Command/ImportVehicleBatteryCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use CrEOF\Spatial\PHP\Types\Geometry\Point; use DateTime; @@ -35,9 +35,9 @@ class ImportVehicleBatteryCommand extends Command protected $batt_index; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->vmfg_index = []; $this->v_index = []; $this->batt_index = []; diff --git a/src/Command/ImportVehicleCompatibilityCommand.php b/src/Command/ImportVehicleCompatibilityCommand.php index 29d74417..481579e1 100644 --- a/src/Command/ImportVehicleCompatibilityCommand.php +++ b/src/Command/ImportVehicleCompatibilityCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use CrEOF\Spatial\PHP\Types\Geometry\Point; use DateTime; @@ -28,9 +28,9 @@ class ImportVehicleCompatibilityCommand extends Command protected $bsize_index; protected $b_index; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->vmfg_index = []; $this->v_index = []; $this->b_index = []; diff --git a/src/Command/MergeDuplicateVehiclesCommand.php b/src/Command/MergeDuplicateVehiclesCommand.php index a0b729cd..99bbbec4 100644 --- a/src/Command/MergeDuplicateVehiclesCommand.php +++ b/src/Command/MergeDuplicateVehiclesCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Vehicle; @@ -15,9 +15,9 @@ class MergeDuplicateVehiclesCommand extends Command { protected $em; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; parent::__construct(); } diff --git a/src/Command/ReportRiderTime.php b/src/Command/ReportRiderTime.php index 77d7f94d..e8825b5b 100644 --- a/src/Command/ReportRiderTime.php +++ b/src/Command/ReportRiderTime.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use DateTime; @@ -21,7 +21,7 @@ class ReportRiderTime extends Command protected $jo_index; protected $filtered_jo_index; - public function __construct(ObjectManager $em) + public function __construct(EntityManagerInterface $em) { $this->em = $em; diff --git a/src/Command/SetCustomerPrivacyPolicyCommand.php b/src/Command/SetCustomerPrivacyPolicyCommand.php index 4132fa91..e5d27617 100644 --- a/src/Command/SetCustomerPrivacyPolicyCommand.php +++ b/src/Command/SetCustomerPrivacyPolicyCommand.php @@ -8,7 +8,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Customer; use App\Entity\PrivacyPolicy; @@ -22,10 +22,10 @@ class SetCustomerPrivacyPolicyCommand extends Command private $policy_third_party_id; private $policy_mobile_id; - public function __construct(ObjectManager $om, $policy_promo, + public function __construct(EntityManagerInterface $em, $policy_promo, $policy_third_party, $policy_mobile) { - $this->em = $om; + $this->em = $em; $this->policy_promo_id = $policy_promo; $this->policy_third_party_id = $policy_third_party; diff --git a/src/Command/TestRegAPNSCommand.php b/src/Command/TestRegAPNSCommand.php index d9615141..52ec7d76 100644 --- a/src/Command/TestRegAPNSCommand.php +++ b/src/Command/TestRegAPNSCommand.php @@ -7,8 +7,6 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; - use App\Service\APNSClient; use DateTime; diff --git a/src/Command/UpdateCustomerVehicleBatteryCommand.php b/src/Command/UpdateCustomerVehicleBatteryCommand.php index f7e09e30..57ad1246 100644 --- a/src/Command/UpdateCustomerVehicleBatteryCommand.php +++ b/src/Command/UpdateCustomerVehicleBatteryCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\JobOrder; @@ -18,9 +18,9 @@ class UpdateCustomerVehicleBatteryCommand extends Command protected $em; protected $custvehicle_hash; - public function __construct(ObjectManager $om) + public function __construct(EntityManagerInterface $em) { - $this->em = $om; + $this->em = $em; $this->custvehicle_hash = []; parent::__construct(); diff --git a/src/Command/UpdateCustomerVehicleWarrantyCommand.php b/src/Command/UpdateCustomerVehicleWarrantyCommand.php index 89b6e5e0..98fec1cb 100644 --- a/src/Command/UpdateCustomerVehicleWarrantyCommand.php +++ b/src/Command/UpdateCustomerVehicleWarrantyCommand.php @@ -7,7 +7,7 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Doctrine\Common\Persistence\ObjectManager; +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Warranty; use App\Entity\CustomerVehicle; @@ -19,7 +19,7 @@ class UpdateCustomerVehicleWarrantyCommand extends Command protected $em; protected $wh; - public function __construct(ObjectManager $em, WarrantyHandler $wh) + public function __construct(EntityManagerInterface $em, WarrantyHandler $wh) { $this->em = $em; $this->wh = $wh; diff --git a/src/Command/UploadCleanupCommand.php b/src/Command/UploadCleanupCommand.php index 94d22c6e..ffa1828b 100644 --- a/src/Command/UploadCleanupCommand.php +++ b/src/Command/UploadCleanupCommand.php @@ -7,7 +7,8 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Exception\IOExceptionInterface; -use Doctrine\Common\Persistence\ObjectManager; + +use Doctrine\ORM\EntityManagerInterface; use App\Entity\Rider; use App\Entity\Battery; @@ -18,11 +19,11 @@ use DirectoryIterator; class UploadCleanupCommand extends Command { private $encoder_factory; - private $object_manager; + private $em; - public function __construct(ObjectManager $om, Filesystem $fs, FileUploader $uploader) + public function __construct(EntityManagerInterface $em, Filesystem $fs, FileUploader $uploader) { - $this->object_manager = $om; + $this->em = $em; $this->filesystem = $fs; $this->uploader = $uploader; @@ -41,7 +42,7 @@ class UploadCleanupCommand extends Command $output->writeln('Retrieving file whitelist...'); // get all image filenames - $em = $this->object_manager; + $em = $this->em; $riders = $em->getRepository(Rider::class)->findAll(); $whitelist = ['.gitkeep']; diff --git a/src/Command/UserCreateCommand.php b/src/Command/UserCreateCommand.php index f0873dc1..3b10d771 100644 --- a/src/Command/UserCreateCommand.php +++ b/src/Command/UserCreateCommand.php @@ -8,7 +8,8 @@ use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface; -use Doctrine\Common\Persistence\ObjectManager; + +use Doctrine\ORM\EntityManagerInterface; use App\Entity\User; use App\Entity\Role; @@ -16,12 +17,12 @@ use App\Entity\Role; class UserCreateCommand extends Command { private $encoder_factory; - private $object_manager; + private $em; - public function __construct(EncoderFactoryInterface $ef, ObjectManager $om) + public function __construct(EncoderFactoryInterface $ef, EntityManagerInterface $em) { $this->encoder_factory = $ef; - $this->object_manager = $om; + $this->em = $em; parent::__construct(); } @@ -49,7 +50,7 @@ class UserCreateCommand extends Command // get entity manager // $em = $this->getContainer()->get('doctrine')->getEntityManager(); - $em = $this->object_manager; + $em = $this->em; // build user $user->setUsername($username)