Add command for populating long / lat fields in job order #186
This commit is contained in:
parent
bc8d01dc6a
commit
3d3f386fa3
1 changed files with 50 additions and 0 deletions
50
src/Command/AdjustLongLatCommand.php
Normal file
50
src/Command/AdjustLongLatCommand.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
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\Entity\JobOrder;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class AdjustLongLatCommand extends Command
|
||||
{
|
||||
protected $em;
|
||||
|
||||
public function __construct(ObjectManager $om)
|
||||
{
|
||||
$this->em = $om;
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
protected function configure()
|
||||
{
|
||||
$this->setName('joborder:adjust_longlat')
|
||||
->setDescription('Separate longitude and latitude from coordinate point.')
|
||||
->setHelp('Get longitude and latitude from existing point type coordinate. Separate into individual fields for reports purposes.');
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
// get entity manager
|
||||
$em = $this->em;
|
||||
|
||||
$job_orders = $em->getRepository(JobOrder::class)->findAll();
|
||||
|
||||
// fulfill each
|
||||
foreach ($job_orders as $jo)
|
||||
{
|
||||
$point = $jo->getCoordinates();
|
||||
$jo->setCoordinates($point);
|
||||
}
|
||||
|
||||
$em->flush();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue