Initial commit
This commit is contained in:
commit
7d9ac74a21
25 changed files with 2418 additions and 0 deletions
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
vendor
|
||||||
|
composer.lock
|
||||||
|
.htaccess
|
||||||
|
cache/db.sqlite
|
||||||
|
config/*
|
||||||
|
!config/_default.php
|
||||||
|
.phpintel
|
||||||
|
|
6
README.md
Normal file
6
README.md
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
# Emotion Hero Web Services
|
||||||
|
|
||||||
|
1. Website
|
||||||
|
2. API
|
||||||
|
|
||||||
|
To run development server run `php -S localhost:80 -t www`.
|
50
bin/generate_db.php
Normal file
50
bin/generate_db.php
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
chdir(__DIR__);
|
||||||
|
|
||||||
|
require_once __DIR__ . "/../bootstrap.php";
|
||||||
|
|
||||||
|
|
||||||
|
// Show table creation statements
|
||||||
|
// And (re)generate Proxies
|
||||||
|
|
||||||
|
$em = $_em;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
|
||||||
|
$emotions = ['anger','contempt','disgust', 'fear', 'joy','sadness','surprise'];
|
||||||
|
foreach($emotions as $emo) {
|
||||||
|
$emotion = new EmotionHero\Models\Emotion();
|
||||||
|
$emotion->setName($emo);
|
||||||
|
$em->persist($emotion);
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = new EmotionHero\Models\User();
|
||||||
|
$em->persist($user);
|
||||||
|
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
var_dump($user->getId());
|
10
bootstrap.php
Normal file
10
bootstrap.php
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<?php
|
||||||
|
// if APPLICATION_ENV is not defined (ie. through htaccess).. assume dev version is ran trough php cli-server
|
||||||
|
// rest is production
|
||||||
|
defined('APPLICATION_ENV')
|
||||||
|
|| define('APPLICATION_ENV',
|
||||||
|
(getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
|
||||||
|
: (php_sapi_name() === 'cli-server' ? 'development' : "production")));
|
||||||
|
|
||||||
|
|
||||||
|
require_once __DIR__.'/vendor/autoload.php';
|
224
cache/proxy/__CG__EmotionHeroModelsEmotion.php
vendored
Normal file
224
cache/proxy/__CG__EmotionHeroModelsEmotion.php
vendored
Normal file
|
@ -0,0 +1,224 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DoctrineProxies\__CG__\EmotionHero\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
|
||||||
|
*/
|
||||||
|
class Emotion extends \EmotionHero\Models\Emotion implements \Doctrine\ORM\Proxy\Proxy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
|
||||||
|
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
|
||||||
|
* initialization process and an array of ordered parameters that were passed to that method.
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setInitializer
|
||||||
|
*/
|
||||||
|
public $__initializer__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setCloner
|
||||||
|
*/
|
||||||
|
public $__cloner__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean flag indicating if this object was already initialized
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
|
||||||
|
*/
|
||||||
|
public $__isInitialized__ = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array properties to be lazy loaded, with keys being the property
|
||||||
|
* names and values being their default values
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
|
||||||
|
*/
|
||||||
|
public static $lazyPropertiesDefaults = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Closure $initializer
|
||||||
|
* @param \Closure $cloner
|
||||||
|
*/
|
||||||
|
public function __construct($initializer = null, $cloner = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__) {
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Emotion' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Emotion' . "\0" . 'name', '' . "\0" . 'EmotionHero\\Models\\Emotion' . "\0" . 'targets'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Emotion' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Emotion' . "\0" . 'name', '' . "\0" . 'EmotionHero\\Models\\Emotion' . "\0" . 'targets'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
if ( ! $this->__isInitialized__) {
|
||||||
|
$this->__initializer__ = function (Emotion $proxy) {
|
||||||
|
$proxy->__setInitializer(null);
|
||||||
|
$proxy->__setCloner(null);
|
||||||
|
|
||||||
|
$existingProperties = get_object_vars($proxy);
|
||||||
|
|
||||||
|
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
|
||||||
|
if ( ! array_key_exists($property, $existingProperties)) {
|
||||||
|
$proxy->$property = $defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces initialization of the proxy
|
||||||
|
*/
|
||||||
|
public function __load()
|
||||||
|
{
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __isInitialized()
|
||||||
|
{
|
||||||
|
return $this->__isInitialized__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitialized($initialized)
|
||||||
|
{
|
||||||
|
$this->__isInitialized__ = $initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitializer(\Closure $initializer = null)
|
||||||
|
{
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __getInitializer()
|
||||||
|
{
|
||||||
|
return $this->__initializer__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setCloner(\Closure $cloner = null)
|
||||||
|
{
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific cloning logic
|
||||||
|
*/
|
||||||
|
public function __getCloner()
|
||||||
|
{
|
||||||
|
return $this->__cloner__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
public function __getLazyProperties()
|
||||||
|
{
|
||||||
|
return self::$lazyPropertiesDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__ === false) {
|
||||||
|
return (int) parent::getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []);
|
||||||
|
|
||||||
|
return parent::getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getName', []);
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setName', [$name]);
|
||||||
|
|
||||||
|
return parent::setName($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getTargets()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getTargets', []);
|
||||||
|
|
||||||
|
return parent::getTargets();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
176
cache/proxy/__CG__EmotionHeroModelsGame.php
vendored
Normal file
176
cache/proxy/__CG__EmotionHeroModelsGame.php
vendored
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DoctrineProxies\__CG__\EmotionHero\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
|
||||||
|
*/
|
||||||
|
class Game extends \EmotionHero\Models\Game implements \Doctrine\ORM\Proxy\Proxy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
|
||||||
|
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
|
||||||
|
* initialization process and an array of ordered parameters that were passed to that method.
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setInitializer
|
||||||
|
*/
|
||||||
|
public $__initializer__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setCloner
|
||||||
|
*/
|
||||||
|
public $__cloner__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean flag indicating if this object was already initialized
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
|
||||||
|
*/
|
||||||
|
public $__isInitialized__ = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array properties to be lazy loaded, with keys being the property
|
||||||
|
* names and values being their default values
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
|
||||||
|
*/
|
||||||
|
public static $lazyPropertiesDefaults = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Closure $initializer
|
||||||
|
* @param \Closure $cloner
|
||||||
|
*/
|
||||||
|
public function __construct($initializer = null, $cloner = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__) {
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'user', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'level', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'hits', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'createdAt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'user', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'level', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'hits', '' . "\0" . 'EmotionHero\\Models\\Game' . "\0" . 'createdAt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
if ( ! $this->__isInitialized__) {
|
||||||
|
$this->__initializer__ = function (Game $proxy) {
|
||||||
|
$proxy->__setInitializer(null);
|
||||||
|
$proxy->__setCloner(null);
|
||||||
|
|
||||||
|
$existingProperties = get_object_vars($proxy);
|
||||||
|
|
||||||
|
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
|
||||||
|
if ( ! array_key_exists($property, $existingProperties)) {
|
||||||
|
$proxy->$property = $defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces initialization of the proxy
|
||||||
|
*/
|
||||||
|
public function __load()
|
||||||
|
{
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __isInitialized()
|
||||||
|
{
|
||||||
|
return $this->__isInitialized__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitialized($initialized)
|
||||||
|
{
|
||||||
|
$this->__isInitialized__ = $initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitializer(\Closure $initializer = null)
|
||||||
|
{
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __getInitializer()
|
||||||
|
{
|
||||||
|
return $this->__initializer__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setCloner(\Closure $cloner = null)
|
||||||
|
{
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific cloning logic
|
||||||
|
*/
|
||||||
|
public function __getCloner()
|
||||||
|
{
|
||||||
|
return $this->__cloner__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
public function __getLazyProperties()
|
||||||
|
{
|
||||||
|
return self::$lazyPropertiesDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
176
cache/proxy/__CG__EmotionHeroModelsHit.php
vendored
Normal file
176
cache/proxy/__CG__EmotionHeroModelsHit.php
vendored
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DoctrineProxies\__CG__\EmotionHero\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
|
||||||
|
*/
|
||||||
|
class Hit extends \EmotionHero\Models\Hit implements \Doctrine\ORM\Proxy\Proxy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
|
||||||
|
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
|
||||||
|
* initialization process and an array of ordered parameters that were passed to that method.
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setInitializer
|
||||||
|
*/
|
||||||
|
public $__initializer__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setCloner
|
||||||
|
*/
|
||||||
|
public $__cloner__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean flag indicating if this object was already initialized
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
|
||||||
|
*/
|
||||||
|
public $__isInitialized__ = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array properties to be lazy loaded, with keys being the property
|
||||||
|
* names and values being their default values
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
|
||||||
|
*/
|
||||||
|
public static $lazyPropertiesDefaults = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Closure $initializer
|
||||||
|
* @param \Closure $cloner
|
||||||
|
*/
|
||||||
|
public function __construct($initializer = null, $cloner = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__) {
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'target', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'game', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'score', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'emotion', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'hits'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'target', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'game', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'score', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'emotion', '' . "\0" . 'EmotionHero\\Models\\Hit' . "\0" . 'hits'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
if ( ! $this->__isInitialized__) {
|
||||||
|
$this->__initializer__ = function (Hit $proxy) {
|
||||||
|
$proxy->__setInitializer(null);
|
||||||
|
$proxy->__setCloner(null);
|
||||||
|
|
||||||
|
$existingProperties = get_object_vars($proxy);
|
||||||
|
|
||||||
|
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
|
||||||
|
if ( ! array_key_exists($property, $existingProperties)) {
|
||||||
|
$proxy->$property = $defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces initialization of the proxy
|
||||||
|
*/
|
||||||
|
public function __load()
|
||||||
|
{
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __isInitialized()
|
||||||
|
{
|
||||||
|
return $this->__isInitialized__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitialized($initialized)
|
||||||
|
{
|
||||||
|
$this->__isInitialized__ = $initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitializer(\Closure $initializer = null)
|
||||||
|
{
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __getInitializer()
|
||||||
|
{
|
||||||
|
return $this->__initializer__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setCloner(\Closure $cloner = null)
|
||||||
|
{
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific cloning logic
|
||||||
|
*/
|
||||||
|
public function __getCloner()
|
||||||
|
{
|
||||||
|
return $this->__cloner__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
public function __getLazyProperties()
|
||||||
|
{
|
||||||
|
return self::$lazyPropertiesDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
176
cache/proxy/__CG__EmotionHeroModelsLevel.php
vendored
Normal file
176
cache/proxy/__CG__EmotionHeroModelsLevel.php
vendored
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DoctrineProxies\__CG__\EmotionHero\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
|
||||||
|
*/
|
||||||
|
class Level extends \EmotionHero\Models\Level implements \Doctrine\ORM\Proxy\Proxy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
|
||||||
|
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
|
||||||
|
* initialization process and an array of ordered parameters that were passed to that method.
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setInitializer
|
||||||
|
*/
|
||||||
|
public $__initializer__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setCloner
|
||||||
|
*/
|
||||||
|
public $__cloner__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean flag indicating if this object was already initialized
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
|
||||||
|
*/
|
||||||
|
public $__isInitialized__ = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array properties to be lazy loaded, with keys being the property
|
||||||
|
* names and values being their default values
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
|
||||||
|
*/
|
||||||
|
public static $lazyPropertiesDefaults = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Closure $initializer
|
||||||
|
* @param \Closure $cloner
|
||||||
|
*/
|
||||||
|
public function __construct($initializer = null, $cloner = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__) {
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Level' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Level' . "\0" . 'targets', '' . "\0" . 'EmotionHero\\Models\\Level' . "\0" . 'games'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Level' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Level' . "\0" . 'targets', '' . "\0" . 'EmotionHero\\Models\\Level' . "\0" . 'games'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
if ( ! $this->__isInitialized__) {
|
||||||
|
$this->__initializer__ = function (Level $proxy) {
|
||||||
|
$proxy->__setInitializer(null);
|
||||||
|
$proxy->__setCloner(null);
|
||||||
|
|
||||||
|
$existingProperties = get_object_vars($proxy);
|
||||||
|
|
||||||
|
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
|
||||||
|
if ( ! array_key_exists($property, $existingProperties)) {
|
||||||
|
$proxy->$property = $defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces initialization of the proxy
|
||||||
|
*/
|
||||||
|
public function __load()
|
||||||
|
{
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __isInitialized()
|
||||||
|
{
|
||||||
|
return $this->__isInitialized__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitialized($initialized)
|
||||||
|
{
|
||||||
|
$this->__isInitialized__ = $initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitializer(\Closure $initializer = null)
|
||||||
|
{
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __getInitializer()
|
||||||
|
{
|
||||||
|
return $this->__initializer__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setCloner(\Closure $cloner = null)
|
||||||
|
{
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific cloning logic
|
||||||
|
*/
|
||||||
|
public function __getCloner()
|
||||||
|
{
|
||||||
|
return $this->__cloner__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
public function __getLazyProperties()
|
||||||
|
{
|
||||||
|
return self::$lazyPropertiesDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
176
cache/proxy/__CG__EmotionHeroModelsTarget.php
vendored
Normal file
176
cache/proxy/__CG__EmotionHeroModelsTarget.php
vendored
Normal file
|
@ -0,0 +1,176 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DoctrineProxies\__CG__\EmotionHero\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
|
||||||
|
*/
|
||||||
|
class Target extends \EmotionHero\Models\Target implements \Doctrine\ORM\Proxy\Proxy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
|
||||||
|
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
|
||||||
|
* initialization process and an array of ordered parameters that were passed to that method.
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setInitializer
|
||||||
|
*/
|
||||||
|
public $__initializer__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setCloner
|
||||||
|
*/
|
||||||
|
public $__cloner__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean flag indicating if this object was already initialized
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
|
||||||
|
*/
|
||||||
|
public $__isInitialized__ = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array properties to be lazy loaded, with keys being the property
|
||||||
|
* names and values being their default values
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
|
||||||
|
*/
|
||||||
|
public static $lazyPropertiesDefaults = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Closure $initializer
|
||||||
|
* @param \Closure $cloner
|
||||||
|
*/
|
||||||
|
public function __construct($initializer = null, $cloner = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__) {
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'level', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'time', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'emotion', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'hits'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'level', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'time', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'emotion', '' . "\0" . 'EmotionHero\\Models\\Target' . "\0" . 'hits'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
if ( ! $this->__isInitialized__) {
|
||||||
|
$this->__initializer__ = function (Target $proxy) {
|
||||||
|
$proxy->__setInitializer(null);
|
||||||
|
$proxy->__setCloner(null);
|
||||||
|
|
||||||
|
$existingProperties = get_object_vars($proxy);
|
||||||
|
|
||||||
|
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
|
||||||
|
if ( ! array_key_exists($property, $existingProperties)) {
|
||||||
|
$proxy->$property = $defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces initialization of the proxy
|
||||||
|
*/
|
||||||
|
public function __load()
|
||||||
|
{
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __isInitialized()
|
||||||
|
{
|
||||||
|
return $this->__isInitialized__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitialized($initialized)
|
||||||
|
{
|
||||||
|
$this->__isInitialized__ = $initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitializer(\Closure $initializer = null)
|
||||||
|
{
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __getInitializer()
|
||||||
|
{
|
||||||
|
return $this->__initializer__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setCloner(\Closure $cloner = null)
|
||||||
|
{
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific cloning logic
|
||||||
|
*/
|
||||||
|
public function __getCloner()
|
||||||
|
{
|
||||||
|
return $this->__cloner__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
public function __getLazyProperties()
|
||||||
|
{
|
||||||
|
return self::$lazyPropertiesDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
268
cache/proxy/__CG__EmotionHeroModelsUser.php
vendored
Normal file
268
cache/proxy/__CG__EmotionHeroModelsUser.php
vendored
Normal file
|
@ -0,0 +1,268 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DoctrineProxies\__CG__\EmotionHero\Models;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DO NOT EDIT THIS FILE - IT WAS CREATED BY DOCTRINE'S PROXY GENERATOR
|
||||||
|
*/
|
||||||
|
class User extends \EmotionHero\Models\User implements \Doctrine\ORM\Proxy\Proxy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible for loading properties in the proxy object. This callback is called with
|
||||||
|
* three parameters, being respectively the proxy object to be initialized, the method that triggered the
|
||||||
|
* initialization process and an array of ordered parameters that were passed to that method.
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setInitializer
|
||||||
|
*/
|
||||||
|
public $__initializer__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \Closure the callback responsible of loading properties that need to be copied in the cloned object
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__setCloner
|
||||||
|
*/
|
||||||
|
public $__cloner__;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean flag indicating if this object was already initialized
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__isInitialized
|
||||||
|
*/
|
||||||
|
public $__isInitialized__ = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var array properties to be lazy loaded, with keys being the property
|
||||||
|
* names and values being their default values
|
||||||
|
*
|
||||||
|
* @see \Doctrine\Common\Persistence\Proxy::__getLazyProperties
|
||||||
|
*/
|
||||||
|
public static $lazyPropertiesDefaults = [];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param \Closure $initializer
|
||||||
|
* @param \Closure $cloner
|
||||||
|
*/
|
||||||
|
public function __construct($initializer = null, $cloner = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function __sleep()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__) {
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\User' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\User' . "\0" . 'games', 'createdAt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
return ['__isInitialized__', '' . "\0" . 'EmotionHero\\Models\\User' . "\0" . 'id', '' . "\0" . 'EmotionHero\\Models\\User' . "\0" . 'games', 'createdAt'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __wakeup()
|
||||||
|
{
|
||||||
|
if ( ! $this->__isInitialized__) {
|
||||||
|
$this->__initializer__ = function (User $proxy) {
|
||||||
|
$proxy->__setInitializer(null);
|
||||||
|
$proxy->__setCloner(null);
|
||||||
|
|
||||||
|
$existingProperties = get_object_vars($proxy);
|
||||||
|
|
||||||
|
foreach ($proxy->__getLazyProperties() as $property => $defaultValue) {
|
||||||
|
if ( ! array_key_exists($property, $existingProperties)) {
|
||||||
|
$proxy->$property = $defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->__cloner__ && $this->__cloner__->__invoke($this, '__clone', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces initialization of the proxy
|
||||||
|
*/
|
||||||
|
public function __load()
|
||||||
|
{
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, '__load', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __isInitialized()
|
||||||
|
{
|
||||||
|
return $this->__isInitialized__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitialized($initialized)
|
||||||
|
{
|
||||||
|
$this->__isInitialized__ = $initialized;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setInitializer(\Closure $initializer = null)
|
||||||
|
{
|
||||||
|
$this->__initializer__ = $initializer;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __getInitializer()
|
||||||
|
{
|
||||||
|
return $this->__initializer__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
*/
|
||||||
|
public function __setCloner(\Closure $cloner = null)
|
||||||
|
{
|
||||||
|
$this->__cloner__ = $cloner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific cloning logic
|
||||||
|
*/
|
||||||
|
public function __getCloner()
|
||||||
|
{
|
||||||
|
return $this->__cloner__;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
* @internal generated method: use only when explicitly handling proxy specific loading logic
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
public function __getLazyProperties()
|
||||||
|
{
|
||||||
|
return self::$lazyPropertiesDefaults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function setCreatedAt(\DateTime $createdAt)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'setCreatedAt', [$createdAt]);
|
||||||
|
|
||||||
|
return parent::setCreatedAt($createdAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getCreatedAt()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getCreatedAt', []);
|
||||||
|
|
||||||
|
return parent::getCreatedAt();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getRoles()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getRoles', []);
|
||||||
|
|
||||||
|
return parent::getRoles();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getPassword()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getPassword', []);
|
||||||
|
|
||||||
|
return parent::getPassword();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getSalt()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getSalt', []);
|
||||||
|
|
||||||
|
return parent::getSalt();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getUsername()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getUsername', []);
|
||||||
|
|
||||||
|
return parent::getUsername();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function eraseCredentials()
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'eraseCredentials', []);
|
||||||
|
|
||||||
|
return parent::eraseCredentials();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
if ($this->__isInitialized__ === false) {
|
||||||
|
return parent::getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$this->__initializer__ && $this->__initializer__->__invoke($this, 'getId', []);
|
||||||
|
|
||||||
|
return parent::getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
composer.json
Normal file
18
composer.json
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"name": "emotionhero/emotionhero_api",
|
||||||
|
"description": "The API for the Emotion Hero game.",
|
||||||
|
"require": {
|
||||||
|
"silex/silex": "~2.0",
|
||||||
|
"doctrine/orm": "v2.5.4",
|
||||||
|
"beberlei/DoctrineExtensions": "^1.0",
|
||||||
|
"gedmo/doctrine-extensions": "^2.4",
|
||||||
|
"symfony/serializer": "^3.1",
|
||||||
|
"cnam/security-jwt-service-provider": "2.*",
|
||||||
|
"jms/serializer": "^1.3"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"EmotionHero\\": "src/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
config/_default.php
Normal file
13
config/_default.php
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
<?php
|
||||||
|
// base config which is overwritten by individual
|
||||||
|
// environment-dependant configuration files
|
||||||
|
$config = [
|
||||||
|
'debug' => false,
|
||||||
|
'db' => [
|
||||||
|
'dsn' => null,
|
||||||
|
'username' => null,
|
||||||
|
'password' => null
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
return $config;
|
1
src/Api/Manager.php
Normal file
1
src/Api/Manager.php
Normal file
|
@ -0,0 +1 @@
|
||||||
|
<?php
|
54
src/Api/ScoreControllerProvider.php
Normal file
54
src/Api/ScoreControllerProvider.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
namespace EmotionHero\Api;
|
||||||
|
|
||||||
|
use EmotionHero\Application as EH;
|
||||||
|
use Silex\Application;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
use Silex\Api\ControllerProviderInterface;
|
||||||
|
use EmotionHero\Models;
|
||||||
|
|
||||||
|
class ScoreControllerProvider implements ControllerProviderInterface
|
||||||
|
{
|
||||||
|
/** @var EH */
|
||||||
|
protected $_eh;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->_eh = EH::getInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function connect(Application $app)
|
||||||
|
{
|
||||||
|
// creates a new controller based on the default route
|
||||||
|
$controllers = $app['controllers_factory'];
|
||||||
|
|
||||||
|
$controllers->get('/', function (Application $app) {
|
||||||
|
return "OK";
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/levels', function (Application $app) {
|
||||||
|
$levels = $this->_eh->getEm()->getRepository(Models\Level::class)->findAll();
|
||||||
|
return $app['serializer']->serialize($levels, 'json');
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/emotions', function (Application $app) {
|
||||||
|
$levels = $this->_eh->getEm()->getRepository(Models\Emotion::class)->findAll();
|
||||||
|
return $app['serializer']->serialize($levels, 'json');
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->get('/me', function (Application $app) {
|
||||||
|
$token = $app['security.token_storage']->getToken();
|
||||||
|
$user = $token->getUser();
|
||||||
|
return $app['serializer']->serialize($user, 'json');
|
||||||
|
});
|
||||||
|
|
||||||
|
$controllers->post('/me/games', function (Request $request, Application $app) {
|
||||||
|
$vars = json_decode($request->getContent(), true);
|
||||||
|
var_dump($vars);
|
||||||
|
return $app['serializer']->serialize($levels, 'json');
|
||||||
|
});
|
||||||
|
|
||||||
|
return $controllers;
|
||||||
|
}
|
||||||
|
}
|
90
src/Application.php
Normal file
90
src/Application.php
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
<?php
|
||||||
|
namespace EmotionHero;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Tools\Setup;
|
||||||
|
use Doctrine\ORM\EntityManager;
|
||||||
|
use Doctrine\Common\Annotations\AnnotationRegistry;
|
||||||
|
use Doctrine\DBAL\Configuration;
|
||||||
|
use Doctrine\DBAL\DriverManager;
|
||||||
|
use Doctrine\DBAL\Logging\DebugStack;
|
||||||
|
use Doctrine\DBAL\Types\Type;
|
||||||
|
|
||||||
|
class Application {
|
||||||
|
// object instance
|
||||||
|
private static $instance;
|
||||||
|
|
||||||
|
private $config;
|
||||||
|
|
||||||
|
private $em;
|
||||||
|
|
||||||
|
private function __construct() {
|
||||||
|
$default_config = require __DIR__ . "/../config/_default.php";
|
||||||
|
$env_config = require __DIR__ . "/../config/".APPLICATION_ENV.".php";
|
||||||
|
$this->config = array_merge($default_config, $env_config);
|
||||||
|
}
|
||||||
|
private function __clone() {}
|
||||||
|
|
||||||
|
public static function getInstance() {
|
||||||
|
if (!Application::$instance instanceof self) {
|
||||||
|
Application::$instance = new self();
|
||||||
|
}
|
||||||
|
return Application::$instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getConfig() {
|
||||||
|
return $this->config;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEm() {
|
||||||
|
|
||||||
|
if(!$this->em) {
|
||||||
|
|
||||||
|
$config = $this->getConfig();
|
||||||
|
|
||||||
|
$em_config = Setup::createAnnotationMetadataConfiguration([__DIR__.'/../src/'], $config['debug'], __DIR__ . '/../cache/proxy',null,false);
|
||||||
|
$em_config->addFilter('soft-deleteable', \Gedmo\SoftDeleteable\Filter\SoftDeleteableFilter::class);
|
||||||
|
// TODO: make sure APCu is enabled (in test AND live!!)
|
||||||
|
// $em_config->setQueryCacheImpl(new \Doctrine\Common\Cache\ApcuCache());
|
||||||
|
// $em_config->setResultCacheImpl(new \Doctrine\Common\Cache\ApcuCache());
|
||||||
|
// $em_config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ApcuCache());
|
||||||
|
|
||||||
|
$connectionConfig = new Configuration();
|
||||||
|
$connectionParams = array(
|
||||||
|
'pdo' => new \PDO(
|
||||||
|
$config['db']['dsn'],
|
||||||
|
isSet($config['username']) ? $config['username'] : null,
|
||||||
|
isSet($config['password']) ? $config['password'] : null
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
if($config['debug'])
|
||||||
|
{
|
||||||
|
$doctrine_debug_stack = new DebugStack();
|
||||||
|
$connectionConfig->setSQLLogger($doctrine_debug_stack);
|
||||||
|
}
|
||||||
|
|
||||||
|
$conn = DriverManager::getConnection($connectionParams, $connectionConfig);
|
||||||
|
$platform = $conn->getDatabasePlatform();
|
||||||
|
$platform->registerDoctrineTypeMapping('enum', 'string');
|
||||||
|
Type::addType('utctime', EmotionHero\Tools\UTCDateTimeType::class);
|
||||||
|
$platform->registerDoctrineTypeMapping('datetime', 'utctime');
|
||||||
|
|
||||||
|
|
||||||
|
// AnnotationRegistry::registerAutoloadNamespace("Hateoas\Configuration", __DIR__."/vendor/willdurand/hateoas/src/");
|
||||||
|
AnnotationRegistry::registerAutoloadNamespace("JMS\Serializer", __DIR__."/../vendor/jms/serializer/src/");
|
||||||
|
AnnotationRegistry::registerAutoloadNamespace("Gedmo\Mapping", __DIR__."/../vendor/gedmo/doctrine-extensions/lib/");
|
||||||
|
|
||||||
|
// obtaining the entity manager
|
||||||
|
$_em = EntityManager::create($conn, $em_config);
|
||||||
|
// Need to enable explicitly: https://github.com/Atlantic18/DoctrineExtensions/blob/master/doc/softdeleteable.md
|
||||||
|
$_em->getFilters()->enable('soft-deleteable');
|
||||||
|
$_em->getEventManager()->addEventSubscriber(new \Gedmo\SoftDeleteable\SoftDeleteableListener());
|
||||||
|
$_em->getEventManager()->addEventSubscriber(new \Gedmo\Timestampable\TimestampableListener());
|
||||||
|
|
||||||
|
$this->em = $_em;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->em;
|
||||||
|
}
|
||||||
|
}
|
89
src/Models/Emotion.php
Normal file
89
src/Models/Emotion.php
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use JMS\Serializer\Annotation as JMS;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="emotions")
|
||||||
|
* @ORM\Entity
|
||||||
|
*/
|
||||||
|
class Emotion
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="id",type="integer")
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
* @ORM\Column(unique=true)
|
||||||
|
*/
|
||||||
|
private $name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @var \Doctrine\Common\Collections\Collection
|
||||||
|
* @ORM\OneToMany(targetEntity="Target", mappedBy="emotion")
|
||||||
|
* @JMS\Exclude
|
||||||
|
*/
|
||||||
|
private $targets;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->targets = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of id.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of name.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getName()
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the value of name.
|
||||||
|
*
|
||||||
|
* @param string $name the name
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
*/
|
||||||
|
public function setName($name)
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of targets.
|
||||||
|
*
|
||||||
|
* @return \Doctrine\Common\Collections\Collection
|
||||||
|
*/
|
||||||
|
public function getTargets()
|
||||||
|
{
|
||||||
|
return $this->targets;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
54
src/Models/Game.php
Normal file
54
src/Models/Game.php
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use JMS\Serializer\Annotation as JMS;
|
||||||
|
use Gedmo\Mapping\Annotation as Gedmo;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Single play of a game: combines User, Level and time
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="games")
|
||||||
|
* @ORM\Entity(repositoryClass="EmotionHero\Models\GameRepository")
|
||||||
|
*/
|
||||||
|
class Game
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="id")
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue(strategy="UUID")
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="User", inversedBy="games")
|
||||||
|
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", nullable=false)
|
||||||
|
*/
|
||||||
|
private $user;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Level", inversedBy="games")
|
||||||
|
* @ORM\JoinColumn(name="level_id", referencedColumnName="id", nullable=false)
|
||||||
|
*/
|
||||||
|
private $level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Hit", mappedBy="game", fetch="EXTRA_LAZY")
|
||||||
|
*/
|
||||||
|
private $hits;
|
||||||
|
|
||||||
|
/** @var float Total score of the game (sum of hits) */
|
||||||
|
private $score;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \DateTime $created
|
||||||
|
*
|
||||||
|
* @Gedmo\Timestampable(on="create")
|
||||||
|
* @ORM\Column(type="datetime")
|
||||||
|
*/
|
||||||
|
private $createdAt;
|
||||||
|
}
|
18
src/Models/GameRepository.php
Normal file
18
src/Models/GameRepository.php
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
<?php
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
|
||||||
|
class UserRepository extends EntityRepository
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// $query = $this->_em->createQuery(
|
||||||
|
// 'SELECT ri FROM ...::class ri WHERE ri.result = :result AND ri.hitAt IS NULL ORDER BY ri.usedPosition ASC'
|
||||||
|
// )
|
||||||
|
// ->setParameters([
|
||||||
|
// 'result' => $result,
|
||||||
|
// ])
|
||||||
|
// ->setMaxResults($limit);
|
||||||
|
// $resultItems = $query->getResult();
|
||||||
|
}
|
311
src/Models/Hit.php
Normal file
311
src/Models/Hit.php
Normal file
|
@ -0,0 +1,311 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use JMS\Serializer\Annotation as JMS;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hit of a target and the facial parameters at the moment of the hit
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="hits")
|
||||||
|
* @ORM\Entity
|
||||||
|
*/
|
||||||
|
class Hit
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="id",type="integer")
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Target", inversedBy="hits")
|
||||||
|
* @ORM\JoinColumn(name="target_id", referencedColumnName="id", nullable=false)
|
||||||
|
*/
|
||||||
|
private $target;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Game", inversedBy="hits")
|
||||||
|
* @ORM\JoinColumn(name="game_id", referencedColumnName="id", nullable=false)
|
||||||
|
*/
|
||||||
|
private $game;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float The score this hit resulted in
|
||||||
|
*/
|
||||||
|
private $score;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Emotion", inversedBy="targets")
|
||||||
|
* @ORM\JoinColumn(name="emotion_id", referencedColumnName="id", nullable=false)
|
||||||
|
*/
|
||||||
|
private $emotion;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Hit", mappedBy="target")
|
||||||
|
*/
|
||||||
|
private $hits;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
* @ORM\Column(name="gender",columnDefinition="VARCHAR(1)")
|
||||||
|
*/
|
||||||
|
private $gender;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $glasses;
|
||||||
|
|
||||||
|
/** @var float Head roll angle */
|
||||||
|
private $roll;
|
||||||
|
/** @var float Head pitch angle */
|
||||||
|
private $pitch;
|
||||||
|
/** @var float Head yaw angle */
|
||||||
|
private $yaw;
|
||||||
|
/** @var float Distance between two outer eye corners (mm?) */
|
||||||
|
private $inter_ocular_distance;
|
||||||
|
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $mouth_open;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $lip_press;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $brow_raise;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $nose_wrinkler;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $lip_depressor;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $brow_furrow;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $attention;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $smile;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $inner_brow_raiser;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $chin_raiser;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $smirk;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $lip_suck;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $upper_lip_raiser;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $lip_pucker;
|
||||||
|
/** @var float Expression parameter */
|
||||||
|
private $eye_closure;
|
||||||
|
|
||||||
|
/** @var float 'Expression' parameter */
|
||||||
|
private $engagement;
|
||||||
|
/** @var float 'Expression' parameter */
|
||||||
|
private $valence;
|
||||||
|
|
||||||
|
/** @var float Emotion parameter */
|
||||||
|
private $anger;
|
||||||
|
/** @var float Emotion parameter */
|
||||||
|
private $contempt;
|
||||||
|
/** @var float Emotion parameter */
|
||||||
|
private $disgust;
|
||||||
|
/** @var float Emotion parameter */
|
||||||
|
private $fear;
|
||||||
|
/** @var float Emotion parameter */
|
||||||
|
private $joy;
|
||||||
|
/** @var float Emotion parameter */
|
||||||
|
private $sadness;
|
||||||
|
/** @var float Emotion parameter */
|
||||||
|
private $surprise;
|
||||||
|
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_0x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_0y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_1x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_1y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_2x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_2y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_3x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_3y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_4x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_4y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_5x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_5y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_6x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_6y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_7x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_7y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_8x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_8y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_9x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_9y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_10x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_10y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_11x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_11y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_12x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_12y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_13x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_13y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_14x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_14y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_15x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_15y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_16x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_16y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_17x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_17y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_18x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_18y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_19x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_19y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_20x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_20y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_21x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_21y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_22x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_22y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_23x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_23y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_24x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_24y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_25x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_25y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_26x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_26y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_27x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_27y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_28x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_28y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_29x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_29y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_30x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_30y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_31x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_31y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_32x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_32y;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_33x;
|
||||||
|
/** @var float Facial landmark */
|
||||||
|
private $point_33y;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A full list of facial landmarks from Affectiva docs
|
||||||
|
* http://developer.affectiva.com/fpi/
|
||||||
|
*
|
||||||
|
* 0 Right Top Jaw
|
||||||
|
* 1 Right Jaw Angle
|
||||||
|
* 2 Tip of Chin
|
||||||
|
* 3 Left Jaw Angle
|
||||||
|
* 4 Left Top Jaw
|
||||||
|
* 5 Outer Right Brow Corner
|
||||||
|
* 6 Right Brow Center
|
||||||
|
* 7 Inner Right Brow Corner
|
||||||
|
* 8 Inner Left Brow Corner
|
||||||
|
* 9 Left Brow Center
|
||||||
|
* 10 Outer Left Brow Corner
|
||||||
|
* 11 Nose Root
|
||||||
|
* 12 Nose Tip
|
||||||
|
* 13 Nose Lower Right Boundary
|
||||||
|
* 14 Nose Bottom Boundary
|
||||||
|
* 15 Nose Lower Left Boundary
|
||||||
|
* 16 Outer Right Eye
|
||||||
|
* 17 Inner Right Eye
|
||||||
|
* 18 Inner Left Eye
|
||||||
|
* 19 Outer Left Eye
|
||||||
|
* 20 Right Lip Corner
|
||||||
|
* 21 Right Apex Upper Lip
|
||||||
|
* 22 Upper Lip Center
|
||||||
|
* 23 Left Apex Upper Lip
|
||||||
|
* 24 Left Lip Corner
|
||||||
|
* 25 Left Edge Lower Lip
|
||||||
|
* 26 Lower Lip Center
|
||||||
|
* 27 Right Edge Lower Lip
|
||||||
|
* 28 Bottom Upper Lip
|
||||||
|
* 29 Top Lower Lip
|
||||||
|
* 30 Upper Corner Right Eye
|
||||||
|
* 31 Lower Corner Right Eye
|
||||||
|
* 32 Upper Corner Left Eye
|
||||||
|
* 33 Lower Corner Left Eye
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->hits = new ArrayCollection();
|
||||||
|
}
|
||||||
|
}
|
43
src/Models/Level.php
Normal file
43
src/Models/Level.php
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use JMS\Serializer\Annotation as JMS;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="levels")
|
||||||
|
* @ORM\Entity
|
||||||
|
*/
|
||||||
|
class Level
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="id",type="integer")
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Target", mappedBy="level")
|
||||||
|
*/
|
||||||
|
private $targets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Game", mappedBy="level", fetch="EXTRA_LAZY")
|
||||||
|
*/
|
||||||
|
private $games;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->targets = new ArrayCollection();
|
||||||
|
$this->games = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
55
src/Models/Target.php
Normal file
55
src/Models/Target.php
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use JMS\Serializer\Annotation as JMS;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="targets")
|
||||||
|
* @ORM\Entity
|
||||||
|
*/
|
||||||
|
class Target
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="id",type="integer")
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Level", inversedBy="targets")
|
||||||
|
* @ORM\JoinColumn(name="level_id", referencedColumnName="id", nullable=false)
|
||||||
|
*/
|
||||||
|
private $level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var float
|
||||||
|
*/
|
||||||
|
private $time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="Emotion", inversedBy="targets")
|
||||||
|
* @ORM\JoinColumn(name="emotion_id", referencedColumnName="id", nullable=false)
|
||||||
|
*/
|
||||||
|
private $emotion;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Hit", mappedBy="target", fetch="EXTRA_LAZY")
|
||||||
|
*/
|
||||||
|
private $hits;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->hits = new ArrayCollection();
|
||||||
|
}
|
||||||
|
}
|
142
src/Models/User.php
Normal file
142
src/Models/User.php
Normal file
|
@ -0,0 +1,142 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\Mapping as ORM;
|
||||||
|
use JMS\Serializer\Annotation as JMS;
|
||||||
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
|
use Gedmo\Mapping\Annotation as Gedmo;
|
||||||
|
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users
|
||||||
|
*
|
||||||
|
* @ORM\Table(name="users")
|
||||||
|
* @ORM\Entity(repositoryClass="EmotionHero\Models\UserRepository")
|
||||||
|
*/
|
||||||
|
class User implements UserInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var integer
|
||||||
|
*
|
||||||
|
* @ORM\Column(name="id")
|
||||||
|
* @ORM\Id
|
||||||
|
* @ORM\GeneratedValue(strategy="UUID")
|
||||||
|
*/
|
||||||
|
private $id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\OneToMany(targetEntity="Game", mappedBy="user")
|
||||||
|
*/
|
||||||
|
private $games;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var \DateTime
|
||||||
|
* @Gedmo\Timestampable(on="create")
|
||||||
|
* @ORM\Column(type="datetime")
|
||||||
|
*/
|
||||||
|
protected $createdAt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets createdAt.
|
||||||
|
*
|
||||||
|
* @param \DateTime $createdAt
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setCreatedAt(\DateTime $createdAt)
|
||||||
|
{
|
||||||
|
$this->createdAt = $createdAt;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns createdAt.
|
||||||
|
*
|
||||||
|
* @return \DateTime
|
||||||
|
*/
|
||||||
|
public function getCreatedAt()
|
||||||
|
{
|
||||||
|
return $this->createdAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->games = new ArrayCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the roles granted to the user.
|
||||||
|
*
|
||||||
|
* <code>
|
||||||
|
* public function getRoles()
|
||||||
|
* {
|
||||||
|
* return array('ROLE_USER');
|
||||||
|
* }
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
|
* Alternatively, the roles might be stored on a ``roles`` property,
|
||||||
|
* and populated in any number of different ways when the user object
|
||||||
|
* is created.
|
||||||
|
*
|
||||||
|
* @return (Role|string)[] The user roles
|
||||||
|
*/
|
||||||
|
public function getRoles() {
|
||||||
|
return ['ROLE_USER'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the password used to authenticate the user.
|
||||||
|
*
|
||||||
|
* This should be the encoded password. On authentication, a plain-text
|
||||||
|
* password will be salted, encoded, and then compared to this value.
|
||||||
|
*
|
||||||
|
* @return string The password
|
||||||
|
*/
|
||||||
|
public function getPassword() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the salt that was originally used to encode the password.
|
||||||
|
*
|
||||||
|
* This can return null if the password was not encoded using a salt.
|
||||||
|
*
|
||||||
|
* @return string|null The salt
|
||||||
|
*/
|
||||||
|
public function getSalt() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the username used to authenticate the user.
|
||||||
|
*
|
||||||
|
* @return string The username
|
||||||
|
*/
|
||||||
|
public function getUsername() {
|
||||||
|
return $this->getId();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes sensitive data from the user.
|
||||||
|
*
|
||||||
|
* This is important if, at any given point, sensitive information like
|
||||||
|
* the plain-text password is stored on this object.
|
||||||
|
*/
|
||||||
|
public function eraseCredentials() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of id.
|
||||||
|
*
|
||||||
|
* @return integer
|
||||||
|
*/
|
||||||
|
public function getId()
|
||||||
|
{
|
||||||
|
return $this->id;
|
||||||
|
}
|
||||||
|
}
|
68
src/Models/UserRepository.php
Normal file
68
src/Models/UserRepository.php
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
<?php
|
||||||
|
namespace EmotionHero\Models;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityRepository;
|
||||||
|
use Symfony\Component\Security\Core\User\UserProviderInterface;
|
||||||
|
use Symfony\Component\Security\Core\User\UserInterface;
|
||||||
|
|
||||||
|
class UserRepository extends EntityRepository implements UserProviderInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads the user for the given username.
|
||||||
|
*
|
||||||
|
* This method must throw UsernameNotFoundException if the user is not
|
||||||
|
* found.
|
||||||
|
*
|
||||||
|
* @param string $username The username
|
||||||
|
*
|
||||||
|
* @return UserInterface
|
||||||
|
*
|
||||||
|
* @throws UsernameNotFoundException if the user is not found
|
||||||
|
*/
|
||||||
|
public function loadUserByUsername($username) {
|
||||||
|
$user = $this->find($username); // username == $id field
|
||||||
|
if(!$user) {
|
||||||
|
throw new \Symfony\Component\Security\Core\Exception\UsernameNotFoundException("Invalid username");
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Refreshes the user for the account interface.
|
||||||
|
*
|
||||||
|
* It is up to the implementation to decide if the user data should be
|
||||||
|
* totally reloaded (e.g. from the database), or if the UserInterface
|
||||||
|
* object can just be merged into some internal array of users / identity
|
||||||
|
* map.
|
||||||
|
*
|
||||||
|
* @param UserInterface $user
|
||||||
|
*
|
||||||
|
* @return UserInterface
|
||||||
|
*
|
||||||
|
* @throws UnsupportedUserException if the account is not supported
|
||||||
|
*/
|
||||||
|
public function refreshUser(UserInterface $user) {
|
||||||
|
$this->_em->refresh($user);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether this provider supports the given user class.
|
||||||
|
*
|
||||||
|
* @param string $class
|
||||||
|
* @todo Extending User should be possible
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function supportsClass($class) {
|
||||||
|
return $class == User::class;
|
||||||
|
}
|
||||||
|
|
||||||
|
// $query = $this->_em->createQuery(
|
||||||
|
// 'SELECT ri FROM ...::class ri WHERE ri.result = :result AND ri.hitAt IS NULL ORDER BY ri.usedPosition ASC'
|
||||||
|
// )
|
||||||
|
// ->setParameters([
|
||||||
|
// 'result' => $result,
|
||||||
|
// ])
|
||||||
|
// ->setMaxResults($limit);
|
||||||
|
// $resultItems = $query->getResult();
|
||||||
|
}
|
45
src/Tools/UTCDateTimeType.php
Normal file
45
src/Tools/UTCDateTimeType.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?php
|
||||||
|
namespace EmotionHero\Tools;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Types\DateTimeType;
|
||||||
|
use Doctrine\DBAL\Platforms\AbstractPlatform;
|
||||||
|
use Doctrine\DBAL\Types\ConversionException;
|
||||||
|
|
||||||
|
class UTCDateTimeType extends DateTimeType
|
||||||
|
{
|
||||||
|
static private $utc = null;
|
||||||
|
|
||||||
|
public function convertToDatabaseValue($value, AbstractPlatform $platform)
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null(self::$utc)) {
|
||||||
|
self::$utc = new \DateTimeZone('UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
$value->setTimeZone(self::$utc);
|
||||||
|
|
||||||
|
return $value->format($platform->getDateTimeFormatString());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function convertToPHPValue($value, AbstractPlatform $platform)
|
||||||
|
{
|
||||||
|
if ($value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_null(self::$utc)) {
|
||||||
|
self::$utc = new \DateTimeZone('UTC');
|
||||||
|
}
|
||||||
|
|
||||||
|
$val = \DateTime::createFromFormat($platform->getDateTimeFormatString(), $value, self::$utc);
|
||||||
|
|
||||||
|
if (!$val) {
|
||||||
|
throw ConversionException::conversionFailed($value, $this->getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $val;
|
||||||
|
}
|
||||||
|
}
|
147
www/index.php
Normal file
147
www/index.php
Normal file
|
@ -0,0 +1,147 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Security\Core\Exception\UsernameNotFoundException;
|
||||||
|
|
||||||
|
require __DIR__ . '/../bootstrap.php';
|
||||||
|
|
||||||
|
$eh = EmotionHero\Application::getInstance();
|
||||||
|
|
||||||
|
$app = new Silex\Application([
|
||||||
|
'debug' => $eh->getConfig()['debug']
|
||||||
|
]);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* JWT setup
|
||||||
|
*/
|
||||||
|
|
||||||
|
define('USER_ID_FIELD', 'id');
|
||||||
|
|
||||||
|
$get_secret_key = function($payload){return 'AqeZFu4MWMZ=P2H_SMgS%%7'.$payload['uid'].'y9aas52%$^eQSQ%HQbYqU(fDo';};
|
||||||
|
|
||||||
|
$app['security.jwt'] = [
|
||||||
|
'secret_key' => 'Very_secret_key',
|
||||||
|
'life_time' => 86400 * 365,
|
||||||
|
'options' => [
|
||||||
|
'username_claim' => USER_ID_FIELD, // default name, option specifying claim containing username
|
||||||
|
'header_name' => 'X-Access-Token', // default null, option for usage normal oauth2 header
|
||||||
|
'token_prefix' => 'Bearer',
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
$app['users'] = function () use ($eh) {
|
||||||
|
return $eh->getEm()->getRepository(EmotionHero\Models\User::class);
|
||||||
|
};
|
||||||
|
|
||||||
|
$app['serializer'] = function () use ($eh) {
|
||||||
|
return JMS\Serializer\SerializerBuilder::create()->build();
|
||||||
|
};
|
||||||
|
|
||||||
|
$app['security.firewalls'] = array(
|
||||||
|
'login' => [
|
||||||
|
'pattern' => 'login|register|oauth|token',
|
||||||
|
'anonymous' => true,
|
||||||
|
],
|
||||||
|
'secured' => array(
|
||||||
|
'pattern' => '^.*$',
|
||||||
|
'logout' => array('logout_path' => '/logout'),
|
||||||
|
'users' => $app['users'],
|
||||||
|
'jwt' => array(
|
||||||
|
'use_forward' => true,
|
||||||
|
'require_previous_session' => false,
|
||||||
|
'stateless' => true,
|
||||||
|
)
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
$app->register(new Silex\Provider\SecurityServiceProvider());
|
||||||
|
$app->register(new Silex\Provider\SecurityJWTServiceProvider());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get token for user
|
||||||
|
*/
|
||||||
|
$app->post('/api/register', function(Request $request) use ($app, $eh){
|
||||||
|
// return $app['serializer']->serialize($eh->getEm()->getRepository(EmotionHero\Models\User::class)->findAll(), 'json');
|
||||||
|
// validate user with... NOTING!!!
|
||||||
|
$user = new EmotionHero\Models\User();
|
||||||
|
$eh->getEm()->persist($user);
|
||||||
|
$eh->getEm()->flush();
|
||||||
|
return $app['serializer']->serialize($user, 'json');
|
||||||
|
});
|
||||||
|
/**
|
||||||
|
* Get token for user with UUID
|
||||||
|
* As it is already a generated token.. don't use password
|
||||||
|
*/
|
||||||
|
$app->post('/api/token', function(Request $request) use ($app){
|
||||||
|
$vars = json_decode($request->getContent(), true);
|
||||||
|
try {
|
||||||
|
if (empty($vars['userid'])) {
|
||||||
|
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $vars['userid']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var $user EmotionHero\Models\User
|
||||||
|
*/
|
||||||
|
$user = $app['users']->loadUserByUsername($vars['userid']);
|
||||||
|
|
||||||
|
if (! $user) {
|
||||||
|
// if (! $app['security.encoder.digest']->isPasswordValid($user->getPassword(), $vars['password'], '')) { // no password set
|
||||||
|
throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $vars['userid']));
|
||||||
|
} else {
|
||||||
|
$response = [
|
||||||
|
'success' => true,
|
||||||
|
'token' => $app['security.jwt.encoder']->encode([USER_ID_FIELD => $user->getUsername()]),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
} catch (UsernameNotFoundException $e) {
|
||||||
|
$response = [
|
||||||
|
'success' => false,
|
||||||
|
'error' => 'Invalid credentials',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $app->json($response, ($response['success'] == true ? Response::HTTP_OK : Response::HTTP_BAD_REQUEST));
|
||||||
|
})
|
||||||
|
;
|
||||||
|
/* EXAMPLE
|
||||||
|
$app->get('/api/protected_resource', function() use ($app){
|
||||||
|
$token = $app['security.token_storage']->getToken();
|
||||||
|
$jwt = 'no';
|
||||||
|
$token = $app['security.token_storage']->getToken();
|
||||||
|
if ($token instanceof Silex\Component\Security\Http\Token\JWTToken) {
|
||||||
|
$jwt = 'yes';
|
||||||
|
}
|
||||||
|
$granted = 'no';
|
||||||
|
if($app['security.authorization_checker']->isGranted('ROLE_ADMIN')) {
|
||||||
|
$granted = 'yes';
|
||||||
|
}
|
||||||
|
$granted_user = 'no';
|
||||||
|
if($app['security.authorization_checker']->isGranted('ROLE_USER')) {
|
||||||
|
$granted_user = 'yes';
|
||||||
|
}
|
||||||
|
$granted_super = 'no';
|
||||||
|
if($app['security.authorization_checker']->isGranted('ROLE_SUPER_ADMIN')) {
|
||||||
|
$granted_super = 'yes';
|
||||||
|
}
|
||||||
|
$user = $token->getUser();
|
||||||
|
return $app->json([
|
||||||
|
'hello' => $token->getUsername(),
|
||||||
|
'username' => $user->getUsername(),
|
||||||
|
'auth' => $jwt,
|
||||||
|
'granted' => $granted,
|
||||||
|
'granted_user' => $granted_user,
|
||||||
|
'granted_super' => $granted_super,
|
||||||
|
]);
|
||||||
|
});*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$app->mount('/', new EmotionHero\Api\ScoreControllerProvider());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$app->run();
|
Loading…
Reference in a new issue