<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use App\Entity\App\Tramite;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20230629142616 extends AbstractMigration implements ContainerAwareInterface
{
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$em = $this->container->get('doctrine')->getManager();
$tramites = $em->getRepository(Tramite::class)->findAll();
foreach ($tramites as $tramite) {
$link = $tramite->getLink();
if ($link !== null && strpos($link, '/') === 0) {
$urlConDrupal = 'https://www.buenosaires.gob.ar' . $tramite->getLink();
$query = "UPDATE tramite SET link = ':link' WHERE id = :id";
$query = str_replace(':link', $urlConDrupal, $query);
$query = str_replace(':id', strval($tramite->getId()), $query);
$this->addSql($query);
}
}
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}