This repository has been archived on 2024-01-26. You can view files and clone it, but cannot push or open issues or pull requests.
calcifer/app/DoctrineMigrations/Version20140710120656.php

74 lines
2.2 KiB
PHP
Raw Normal View History

2014-07-10 12:44:18 +02:00
<?php
namespace Application\Migrations;
use Doctrine\DBAL\Migrations\AbstractMigration;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\ORM\EntityManager;
use Hackspace\Bundle\CalciferBundle\Entity\Event;
use Hackspace\Bundle\CalciferBundle\Entity\Location;
use Hackspace\Bundle\CalciferBundle\Entity\Tag;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Auto-generated Migration: Please modify to your needs!
*/
class Version20140710120656 extends AbstractMigration implements ContainerAwareInterface
{
/** @var ContainerInterface */
private $container;
public function setContainer(ContainerInterface $container = null)
{
$this->container = $container;
}
public function up(Schema $schema)
{
/** @var EntityManager $em */
$em = $this->container->get('doctrine.orm.entity_manager');
$repo = $em->getRepository('CalciferBundle:Event');
$entities = $repo->findAll();
if (count($entities) > 0) {
foreach($entities as $entity) {
/** @var Event $entity */
$entity->setSlug(\URLify::filter($entity->getSummary(),255,'de'));
$em->persist($entity);
$em->flush();
}
}
$repo = $em->getRepository('CalciferBundle:Location');
$entities = $repo->findAll();
if (count($entities) > 0) {
foreach($entities as $entity) {
/** @var Location $entity */
$entity->setSlug(\URLify::filter($entity->getName(),255,'de'));
$em->persist($entity);
$em->flush();
}
}
$repo = $em->getRepository('CalciferBundle:Tag');
$entities = $repo->findAll();
if (count($entities) > 0) {
foreach($entities as $entity) {
/** @var Tag $entity */
$entity->setSlug(\URLify::filter($entity->getName(),255,'de'));
$em->persist($entity);
$em->flush();
}
}
}
public function down(Schema $schema)
{
// this down() migration is auto-generated, please modify it to your needs
}
}