Skip to content

Commit

Permalink
Actualizada la aplicación a Symfony 2.0.10
Browse files Browse the repository at this point in the history
  * Actualizado el comando bin/vendors porque ha cambiado en esta versión
  * Actualizados los archivos deps y deps.lock oficiales de Symfony2
  * Eliminados los bloqueos propios en deps.lock
  * Actualizadas las clases de los fixtures según los cambios de Doctrine2

Otro cambio importante que trae esta versión es que ahora el comando
`doctrine:fixtures:load` ya no elimina las tablas de la base de datos,
sino que sólo borra su información. La consecuencia es que, al menos en
MySQL, no se resetean los valores autoincrementales.

Para utilizar `doctrine:fixtures:load` como antes, es necesario añadir
siempre la opción --purge-with-truncate
  • Loading branch information
javiereguiluz committed Feb 13, 2012
1 parent 63b8495 commit 3db6428
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 56 deletions.
83 changes: 55 additions & 28 deletions bin/vendors
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
* file that was distributed with this source code.
*/

set_time_limit(0);

$rootDir = dirname(__DIR__);
$vendorDir = $rootDir.'/vendor';

Expand All @@ -22,14 +24,14 @@ Specify a command to run:
install: install vendors as specified in deps or deps.lock (recommended)
update: update vendors to their latest versions (as specified in deps)
lock: lock vendors to their current versions
EOF
);
}

if (!in_array($command = array_shift($argv), array('install', 'update'))) {
exit(sprintf("Command \"%s\" does not exist.\n", $command));
if (!in_array($command = array_shift($argv), array('install', 'update', 'lock'))) {
exit(sprintf('Command "%s" does not exist.', $command).PHP_EOL);
}

/*
Expand Down Expand Up @@ -57,7 +59,7 @@ if ('install' === $command && file_exists($rootDir.'/deps.lock')) {
foreach (file($rootDir.'/deps.lock', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) as $line) {
$parts = array_values(array_filter(explode(' ', $line)));
if (2 !== count($parts)) {
exit(sprintf('The deps version file is not valid (near "%s")', $line));
exit(sprintf('The deps version file is not valid (near "%s")', $line).PHP_EOL);
}
$versions[$parts[0]] = $parts[1];
}
Expand All @@ -66,59 +68,84 @@ if ('install' === $command && file_exists($rootDir.'/deps.lock')) {
$newversions = array();
$deps = parse_ini_file($rootDir.'/deps', true, INI_SCANNER_RAW);
if (false === $deps) {
exit("The deps file is not valid ini syntax. Perhaps missing a trailing newline?\n");
exit('The deps file is not valid ini syntax. Perhaps missing a trailing newline?'.PHP_EOL);
}
foreach ($deps as $name => $dep) {
$dep = array_map('trim', $dep);

// revision
if (isset($versions[$name])) {
$rev = $versions[$name];
} else {
$rev = isset($dep['version']) ? $dep['version'] : 'origin/HEAD';
}

// install dir
$installDir = isset($dep['target']) ? $vendorDir.'/'.$dep['target'] : $vendorDir.'/'.$name;
if (in_array('--reinstall', $argv)) {
if (PHP_OS == 'WINNT') {
if (defined('PHP_WINDOWS_VERSION_BUILD')) {
system(sprintf('rmdir /S /Q %s', escapeshellarg(realpath($installDir))));
} else {
system(sprintf('rm -rf %s', escapeshellarg($installDir)));
}
}

echo "> Installing/Updating $name\n";
if ('install' === $command || 'update' === $command) {
echo '> Installing/Updating '.$name.PHP_EOL;

// url
if (!isset($dep['git'])) {
exit(sprintf('The "git" value for the "%s" dependency must be set.', $name));
}
$url = $dep['git'];
// url
if (!isset($dep['git'])) {
exit(sprintf('The "git" value for the "%s" dependency must be set.', $name).PHP_EOL);
}
$url = $dep['git'];

if (!is_dir($installDir)) {
system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir)));
}
if (!is_dir($installDir)) {
system(sprintf('git clone %s %s', escapeshellarg($url), escapeshellarg($installDir)));
}

system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
// revision
if (isset($versions[$name])) {
$rev = $versions[$name];
} else {
$rev = isset($dep['version']) ? $dep['version'] : 'origin/HEAD';
}

if ('update' === $command) {
$status = system(sprintf('cd %s && git status --porcelain', escapeshellarg($installDir)));
if (!empty($status)) {
exit(sprintf('"%s" has local modifications. Please revert or commit/push them before running this command again.', $name).PHP_EOL);
}
$current_rev = system(sprintf('cd %s && git rev-list --max-count=1 HEAD', escapeshellarg($installDir)));
if ($current_rev === $rev) {
continue;
}

system(sprintf('cd %s && git fetch origin && git reset --hard %s', escapeshellarg($installDir), escapeshellarg($rev)));
}

if ('update' === $command || 'lock' === $command) {
ob_start();
system(sprintf('cd %s && git log -n 1 --format=%%H', escapeshellarg($installDir)));
$newversions[] = trim($name.' '.ob_get_clean());
$newversion = trim(ob_get_clean());

ob_start();
system(sprintf('cd %s && git name-rev --tags --name-only %s', escapeshellarg($installDir), $newversion));
// remove trailing ^0 from tags, those are the tags themselves
$niceversion = preg_replace('/\^0$/', '', trim(ob_get_clean()));

// undefined is returned in case no name-rev could be found
if ('undefined' !== $niceversion) {
$newversions[] = $name.' '.$niceversion;
} else {
$newversions[] = $name.' '.$newversion;
}
}
}

// update?
if ('update' === $command) {
if ('update' === $command || 'lock' === $command) {
echo '> Updating deps.lock'.PHP_EOL;

file_put_contents($rootDir.'/deps.lock', implode("\n", $newversions));
}

// php on windows can't use the shebang line from system()
$interpreter = PHP_OS == 'WINNT' ? 'php.exe' : '';
$interpreter = defined('PHP_WINDOWS_VERSION_BUILD') ? 'php.exe' : '';

// Update the bootstrap files
system(sprintf('%s %s', $interpreter, escapeshellarg($rootDir.'/vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php')));
system(sprintf('%s %s %s', $interpreter, escapeshellarg($rootDir.'/vendor/bundles/Sensio/Bundle/DistributionBundle/Resources/bin/build_bootstrap.php'), escapeshellarg($rootDir)));

// Update assets
system(sprintf('%s %s assets:install %s', $interpreter, escapeshellarg($rootDir.'/app/console'), escapeshellarg($rootDir.'/web/')));
Expand Down
8 changes: 4 additions & 4 deletions deps
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[symfony]
git=http://github.com/symfony/symfony.git
version=v2.0.9
version=v2.0.10

[twig]
git=http://github.com/fabpot/Twig.git
version=v1.5.1
version=v1.6.0

[monolog]
git=http://github.com/Seldaek/monolog.git
Expand All @@ -16,11 +16,11 @@

[doctrine-dbal]
git=http://github.com/doctrine/dbal.git
version=2.1.5
version=2.1.6

[doctrine]
git=http://github.com/doctrine/doctrine2.git
version=2.1.5
version=2.1.6

[swiftmailer]
git=http://github.com/swiftmailer/swiftmailer.git
Expand Down
28 changes: 12 additions & 16 deletions deps.lock
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
symfony 3e9d937eb8fedb8a585559e04311ee9a39db421f
twig 5bba14970604a26469af90b605d10c716b3af411
monolog b704c49a3051536f67f2d39f13568f74615b9922
doctrine-common b886898821288d305862ee9c567cc5b5cbb4c0dc
doctrine-dbal ae358bd94ec09d7d3ad92ca7820e67825ad9e5f4
doctrine da0e3439aba4c8bf5e8a6ee4ccee5ce2624be8d1
swiftmailer 982b4c9498b7dd85e70f6d35e65d909c888e6345
assetic f829ad23d23c87480151a21faad49fefe7c09e5d
twig-extensions a05ab5ed18a51ae45f3dcc2d0c4ec9b3a6386987
metadata 8717ad2a5689480765d9ffafe925cd8a2457e582
SensioFrameworkExtraBundle 1c7e92f466d11f83130b0c1271f44d067a2c3b31
symfony v2.0.10
twig v1.6.0
monolog 1.0.2
doctrine-common 2.1.4
doctrine-dbal 2.1.6
doctrine 2.1.6
swiftmailer v4.1.5
assetic v1.0.2
twig-extensions 1dfff8e793f50f651c4f74f796c2c68a4aee3147
metadata 1.0.0
SensioFrameworkExtraBundle 638f545b7020b9e9d5944a7e3167f60ed848250d
JMSSecurityExtraBundle 541a4c242328dc04b99540c75346cc74a7c0cfb5
SensioDistributionBundle 20b66a408084ad8752f98e50f10533f5245310bf
SensioGeneratorBundle dd37fc4487bc09ac01bdcf89e0ff4ee4484b7fab
AsseticBundle 41b5913b5086a0909af92adcb4a6005ee0051b16
doctrine-fixtures 4a8464ef83093de2378cef2770e13da7e4858ffc
DoctrineFixturesBundle 275e33be3ed4aa76afc21ff0aa5517b0e4795ba1
doctrine-extensions 3279a826d5f1fac61e8b1829d7a7ff24cffd7285
IdeupSimplePaginatorBundle a56e662da476e4b8fc5378f134f80d072ff65659
AsseticBundle v1.0.1
3 changes: 2 additions & 1 deletion src/Cupon/CiudadBundle/DataFixtures/ORM/Ciudades.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Cupon\CiudadBundle\Entity\Ciudad;

/**
Expand All @@ -29,7 +30,7 @@ public function getOrder()
return 10;
}

public function load($manager)
public function load(ObjectManager $manager)
{
// Los 25 municipios más poblados de España según el INE
// fuente: http://es.wikipedia.org/wiki/Municipios_de_Espa%C3%B1a_por_poblaci%C3%B3n
Expand Down
3 changes: 2 additions & 1 deletion src/Cupon/OfertaBundle/DataFixtures/ORM/Ofertas.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
Expand Down Expand Up @@ -43,7 +44,7 @@ public function setContainer(ContainerInterface $container = null)
$this->container = $container;
}

public function load($manager)
public function load(ObjectManager $manager)
{
// Obtener todas las tiendas y ciudades de la base de datos
$ciudades = $manager->getRepository('CiudadBundle:Ciudad')->findAll();
Expand Down
9 changes: 5 additions & 4 deletions src/Cupon/OfertaBundle/DataFixtures/ORM/Ventas.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Cupon\OfertaBundle\Entity\Oferta,
Cupon\UsuarioBundle\Entity\Usuario,
Cupon\OfertaBundle\Entity\Venta;
use Doctrine\Common\Persistence\ObjectManager;
use Cupon\OfertaBundle\Entity\Oferta;
use Cupon\UsuarioBundle\Entity\Usuario;
use Cupon\OfertaBundle\Entity\Venta;

/**
* Fixtures de la entidad Venta.
Expand All @@ -31,7 +32,7 @@ public function getOrder()
return 50;
}

public function load($manager)
public function load(ObjectManager $manager)
{
// Obtener todas las ofertas y usuarios de la base de datos
$ofertas = $manager->getRepository('OfertaBundle:Oferta')->findAll();
Expand Down
3 changes: 2 additions & 1 deletion src/Cupon/TiendaBundle/DataFixtures/ORM/Tiendas.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Cupon\CiudadBundle\Entity\Ciudad;
Expand All @@ -39,7 +40,7 @@ public function setContainer(ContainerInterface $container = null)
$this->container = $container;
}

public function load($manager)
public function load(ObjectManager $manager)
{
// Obtener todas las ciudades de la base de datos
$ciudades = $manager->getRepository('CiudadBundle:Ciudad')->findAll();
Expand Down
3 changes: 2 additions & 1 deletion src/Cupon/UsuarioBundle/DataFixtures/ORM/Usuarios.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Cupon\CiudadBundle\Entity\Ciudad;
Expand All @@ -39,7 +40,7 @@ public function setContainer(ContainerInterface $container = null)
$this->container = $container;
}

public function load($manager)
public function load(ObjectManager $manager)
{
// Obtener todas las ciudades de la base de datos
$ciudades = $manager->getRepository('CiudadBundle:Ciudad')->findAll();
Expand Down

0 comments on commit 3db6428

Please sign in to comment.