Verified Commit 69be3c1f authored by Alan Poulain's avatar Alan Poulain
Browse files

Fix fixtures

parent d17463ba
......@@ -24,6 +24,7 @@ parameters:
oauth_google_secret: '%env(OAUTH_GOOGLE_SECRET)%'
oauth_facebook_id: '%env(OAUTH_FACEBOOK_ID)%'
oauth_facebook_secret: '%env(OAUTH_FACEBOOK_SECRET)%'
doctrine_mongodb.odm.fixtures_dirs: ['src/DataFixtures/MongoDB']
services:
# default configuration for services in *this* file
......
......@@ -23,7 +23,7 @@ class MigrationCommand extends GoGoAbstractCommand
// -----------------------------------------------------------------
// DO NOT REMOVE A SINGLE ELEMENT OF THOSE ARRAYS, ONLY ADD NEW ONES
// -----------------------------------------------------------------
public $migrations = [
public static $migrations = [
// v2.4.6
'db.TileLayer.updateMany({name:"cartodb"}, {$set: {attribution:"&copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a> &copy; <a href=\"http://cartodb.com/attributions\">CartoDB</a>"}})',
'db.TileLayer.updateMany({name:"hydda"}, {$set: {attribution:"Tiles courtesy of <a href=\"http://openstreetmap.se/\" target=\"_blank\">OpenStreetMap Sweden</a> &mdash; Map data &copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>"}})',
......@@ -33,7 +33,7 @@ class MigrationCommand extends GoGoAbstractCommand
'db.TileLayer.updateMany({name:"stamenWaterColor"}, {$set: {attribution:"Map tiles by <a href=\"http://stamen.com\">Stamen Design</a>, <a href=\"http://creativecommons.org/licenses/by/3.0\">CC BY 3.0</a> &mdash; Map data &copy; <a href=\"http://www.openstreetmap.org/copyright\">OpenStreetMap</a>"}})',
];
public $commands = [
public static $commands = [
// v2.3.1
"app:elements:updateJson all",
// v2.3.4
......@@ -42,7 +42,7 @@ class MigrationCommand extends GoGoAbstractCommand
"app:elements:updateJson all"
];
public $messages = [
public static $messages = [
// v2.3.0
"Un champ <b>Image (url)</b> est maintenant disponible dans la confiugration du formulaire !",
"Vous pouvez désormais customizer la popup qui s'affiche au survol d'un marqueur. Allez dans Personnalisation -> Marqueur / Popup",
......@@ -86,8 +86,8 @@ class MigrationCommand extends GoGoAbstractCommand
$dbNames = $dm->createQueryBuilder('App\Document\Project')->select('domainName')->hydrate(false)->getQuery()->execute()->toArray();
foreach ($dbNames as $object) { $dbs[] = $object['domainName']; }
if (count($this->migrations) > $migrationState->getMigrationIndex()) {
$migrationsToRun = array_slice($this->migrations, $migrationState->getMigrationIndex());
if (count(self::$migrations) > $migrationState->getMigrationIndex()) {
$migrationsToRun = array_slice(self::$migrations, $migrationState->getMigrationIndex());
$migrationsToRun = array_unique($migrationsToRun);
foreach($dbs as $db) {
foreach($migrationsToRun as $migration) {
......@@ -102,8 +102,8 @@ class MigrationCommand extends GoGoAbstractCommand
// run them syncronously otherwise all the command will be run at once
$this->asyncService->setRunSynchronously(true);
if (count($this->commands) > $migrationState->getCommandsIndex()) {
$commandsToRun = array_slice($this->commands, $migrationState->getCommandsIndex());
if (count(self::$commands) > $migrationState->getCommandsIndex()) {
$commandsToRun = array_slice(self::$commands, $migrationState->getCommandsIndex());
$commandsToRun = array_unique($commandsToRun);
$this->log(count($commandsToRun) . " commands to run");
foreach($dbs as $db) {
......@@ -116,8 +116,8 @@ class MigrationCommand extends GoGoAbstractCommand
$this->log("No commands to run");
}
if (count($this->messages) > $migrationState->getMessagesIndex()) {
$messagesToAdd = array_slice($this->messages, $migrationState->getMessagesIndex());
if (count(self::$messages) > $migrationState->getMessagesIndex()) {
$messagesToAdd = array_slice(self::$messages, $migrationState->getMessagesIndex());
$this->log(count($messagesToAdd) . " messages to add");
foreach($dbs as $db) {
$this->log("add message on project " . $db);
......@@ -136,9 +136,9 @@ class MigrationCommand extends GoGoAbstractCommand
$this->error("Error performing migrations: " . $message);
}
$migrationState->setMigrationIndex(count($this->migrations));
$migrationState->setCommandsIndex(count($this->commands));
$migrationState->setMessagesIndex(count($this->messages));
$migrationState->setMigrationIndex(count(self::$migrations));
$migrationState->setCommandsIndex(count(self::$commands));
$migrationState->setMessagesIndex(count(self::$messages));
$dm->flush();
}
......
......@@ -3,9 +3,8 @@
namespace App\DataFixtures\MongoDB;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use App\Document\About;
use Doctrine\Persistence\ObjectManager;
use joshtronic\LoremIpsum;
class LoadAbout implements FixtureInterface
......
......@@ -2,6 +2,7 @@
namespace App\DataFixtures\MongoDB;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\ODM\MongoDB\DocumentManager;
use App\Document\Configuration;
use App\Document\Configuration\ConfigurationHome;
......@@ -15,10 +16,11 @@ use App\Document\FeatureConfiguration;
use App\Document\InteractionConfiguration;
use App\Document\Coordinates;
use App\Document\TileLayer;
use Doctrine\Persistence\ObjectManager;
class LoadConfiguration
class LoadConfiguration implements FixtureInterface
{
public function load($dm, $container = null, $configToCopy = null, $contribConfig = null)
public function load(ObjectManager $dm, $container = null, $configToCopy = null, $contribConfig = null)
{
$configuration = new Configuration();
$tileLayersToCopy = null;
......
......@@ -3,23 +3,21 @@
namespace App\DataFixtures\MongoDB;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use App\Document\MigrationState;
use App\Command\MigrationCommand;
use Doctrine\Persistence\ObjectManager;
use joshtronic\LoremIpsum;
class LoadMigrationState implements FixtureInterface
{
public function load(ObjectManager $manager)
{
$migrationState = new MigrationState();
$migrationCommand = new MigrationCommand();
$migrationState->setMigrationIndex(count($migrationCommand->migrations));
$migrationState->setCommandsIndex(count($migrationCommand->commands));
$migrationState->setMessagesIndex(count($migrationCommand->messages));
$migrationState->setMigrationIndex(count(MigrationCommand::$migrations));
$migrationState->setCommandsIndex(count(MigrationCommand::$commands));
$migrationState->setMessagesIndex(count(MigrationCommand::$messages));
$manager->persist($migrationState);
$manager->flush();
}
}
\ No newline at end of file
}
......@@ -3,10 +3,9 @@
namespace App\DataFixtures\MongoDB;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use App\Document\Partner;
use App\Document\PartnerImage;
use Doctrine\Persistence\ObjectManager;
use joshtronic\LoremIpsum;
class LoadPartner implements FixtureInterface
......
......@@ -14,12 +14,10 @@
namespace App\DataFixtures\MongoDB;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use App\Document\Taxonomy;
use App\Document\Category;
use App\Document\Option;
use Doctrine\Persistence\ObjectManager;
class LoadTaxonomy implements FixtureInterface
{
......
......@@ -3,14 +3,11 @@
namespace App\DataFixtures\MongoDB;
use Doctrine\Common\DataFixtures\FixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use App\Document\Wrapper;
use Doctrine\Persistence\ObjectManager;
class LoadWrapper implements FixtureInterface
{
public function load(ObjectManager $manager)
{
$new_wrapper = new Wrapper();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment