resq/src/Command/AdjustLongLatCommand.php

50 lines
1.2 KiB
PHP

<?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();
}
}