2016-09-01 12:15:17 +02:00
|
|
|
<?php
|
|
|
|
chdir(__DIR__);
|
|
|
|
|
2016-09-01 17:35:43 +02:00
|
|
|
// define('APPLICATION_ENV', 'development');
|
2016-09-01 17:33:00 +02:00
|
|
|
|
2016-09-01 12:15:17 +02:00
|
|
|
require_once __DIR__ . "/../bootstrap.php";
|
|
|
|
|
|
|
|
|
|
|
|
// Show table creation statements
|
|
|
|
// And (re)generate Proxies
|
|
|
|
|
2016-09-01 12:25:51 +02:00
|
|
|
$em = EmotionHero\Application::getInstance()->getEm();
|
2016-09-01 12:15:17 +02:00
|
|
|
|
|
|
|
var_dump($em->getConnection()->getDatabasePlatform()->getName());
|
|
|
|
// $serializer = JMS\Serializer\SerializerBuilder::create()->build();
|
|
|
|
|
|
|
|
$metadatas = $em->getMetadataFactory()->getAllMetadata();
|
|
|
|
// $metadatas = MetadataFilter::filter($metadatas, $input->getOption('filter'));
|
|
|
|
$destPath = $em->getConfiguration()->getProxyDir();
|
|
|
|
$em->getProxyFactory()->generateProxyClasses($metadatas, $destPath);
|
|
|
|
|
|
|
|
|
|
|
|
$tool = new Doctrine\ORM\Tools\SchemaTool($em);
|
|
|
|
|
|
|
|
$classes = $metadatas;
|
|
|
|
|
|
|
|
|
|
|
|
// $classes = array(
|
|
|
|
// $em->getClassMetadata('EmotionHero\Models\Emotion'),
|
|
|
|
// );
|
|
|
|
|
|
|
|
// $tool->getCreateDatabaseSQL();
|
|
|
|
$queries = $tool->getCreateSchemaSQL($classes);
|
|
|
|
// $queries = $tool->getUpdateSchemaSql($classes);
|
|
|
|
foreach($queries as $sql){ echo "$sql;\n"; }
|
|
|
|
// updateSchema
|
|
|
|
$tool->updateSchema($classes);
|
|
|
|
|
2016-09-04 13:41:59 +02:00
|
|
|
|
|
|
|
die();
|
2016-09-01 17:33:00 +02:00
|
|
|
// ADD EMOTIONS
|
|
|
|
|
|
|
|
$emotions = [];
|
|
|
|
try {
|
|
|
|
$emos = ['anger','contempt','disgust', 'fear', 'joy','sadness','surprise'];
|
|
|
|
foreach($emos as $emo) {
|
|
|
|
$emotion = $em->getRepository(EmotionHero\Models\Emotion::class)->findOneBy(['name' => $emo]);
|
|
|
|
if(empty($emotion))
|
|
|
|
{
|
|
|
|
$emotion = new EmotionHero\Models\Emotion();
|
|
|
|
$emotion->setName($emo);
|
|
|
|
$em->persist($emotion);
|
|
|
|
}
|
|
|
|
$emotions[$emo] = $emotion;
|
|
|
|
|
|
|
|
}
|
|
|
|
$em->flush();
|
|
|
|
} catch (Exception $e) {
|
|
|
|
echo "\nEmotions Probably already inserted...\n";
|
2016-09-01 12:15:17 +02:00
|
|
|
}
|
|
|
|
|
2016-09-01 17:33:00 +02:00
|
|
|
// TEST USER
|
2016-09-01 12:15:17 +02:00
|
|
|
|
2016-09-01 17:33:00 +02:00
|
|
|
if(empty($em->getRepository(EmotionHero\Models\User::class)->findOneBy([]))) {
|
|
|
|
$user = new EmotionHero\Models\User();
|
|
|
|
$em->persist($user);
|
|
|
|
|
|
|
|
$em->flush();
|
|
|
|
}
|
2016-09-01 12:15:17 +02:00
|
|
|
|
2016-09-01 17:33:00 +02:00
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(1);
|
|
|
|
$lvl->setName("I am sooo ANGRY");
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, 1);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, 2);
|
|
|
|
$lvl->createTarget($emotions['anger'], 10, 3);
|
|
|
|
$lvl->createTarget($emotions['anger'], 20, 4);
|
|
|
|
$lvl->createTarget($emotions['anger'], 40, 5);
|
|
|
|
$lvl->createTarget($emotions['anger'], 70, 6);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, 7);
|
|
|
|
$em->persist($lvl);
|
|
|
|
|
|
|
|
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(2);
|
|
|
|
$lvl->setName("Let's be joyfull!");
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 1);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 2);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 4);
|
|
|
|
$lvl->createTarget($emotions['contempt'], 20, 4);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, 5);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 7);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, 9);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 11);
|
|
|
|
$lvl->createTarget($emotions['joy'], 70, 12);
|
|
|
|
$lvl->createTarget($emotions['joy'], 60, 13);
|
|
|
|
$lvl->createTarget($emotions['joy'], 30, 14);
|
|
|
|
$lvl->createTarget($emotions['joy'], 10, 14.5);
|
|
|
|
$lvl->createTarget($emotions['anger'], 100, 16);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 17);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 18);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 19);
|
|
|
|
$lvl->createTarget($emotions['joy'], 100, 20);
|
|
|
|
$em->persist($lvl);
|
|
|
|
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(3);
|
|
|
|
$lvl->setName("What a surprise");
|
|
|
|
$lvl->createTarget($emotions['surprise'], 20, 1);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 50, 2);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 80, 3);
|
|
|
|
$lvl->createTarget($emotions['surprise'], 100, 4);
|
|
|
|
$em->persist($lvl);
|
|
|
|
|
|
|
|
$lvl = new EmotionHero\Models\Level();
|
|
|
|
$lvl->setId(4);
|
|
|
|
$lvl->setName("Please, don't cry...");
|
|
|
|
$lvl->createTarget($emotions['sadness'], 20, 1);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 50, 2);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 80, 3);
|
|
|
|
$lvl->createTarget($emotions['sadness'], 100, 4);
|
|
|
|
$em->persist($lvl);
|
|
|
|
|
|
|
|
$em->flush();
|