From 22f55855d18913d98251e28058dbddf67acd7233 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 5 Aug 2013 17:27:21 +0200 Subject: [PATCH 1/7] Moved yaml doctrine conf to annotation --- .../Core/Provider/ORMServiceProvider.php | 34 ++++++++++++++--- lib/Doctrine/Entities/AuthFailure.php | 17 ++++++--- lib/Doctrine/Entities/Basket.php | 32 ++++++++++------ lib/Doctrine/Entities/BasketElement.php | 26 ++++++++----- lib/Doctrine/Entities/LazaretAttribute.php | 22 +++++++---- lib/Doctrine/Entities/LazaretCheck.php | 14 +++++-- lib/Doctrine/Entities/LazaretFile.php | 38 ++++++++++++------- lib/Doctrine/Entities/LazaretSession.php | 22 +++++++---- lib/Doctrine/Entities/Session.php | 38 +++++++++++-------- lib/Doctrine/Entities/SessionModule.php | 20 +++++++--- lib/Doctrine/Entities/StoryWZ.php | 19 +++++++--- lib/Doctrine/Entities/UsrAuthProvider.php | 32 ++++++++++------ lib/Doctrine/Entities/UsrList.php | 21 ++++++---- lib/Doctrine/Entities/UsrListEntry.php | 20 +++++++--- lib/Doctrine/Entities/UsrListOwner.php | 22 +++++++---- lib/Doctrine/Entities/ValidationData.php | 22 +++++++---- .../Entities/ValidationParticipant.php | 26 ++++++++----- lib/Doctrine/Entities/ValidationSession.php | 24 ++++++++---- 18 files changed, 301 insertions(+), 148 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 0bd21b9407..21e22000ad 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -48,15 +48,39 @@ class ORMServiceProvider implements ServiceProviderInterface $config->setSQLLogger($app['EM.sql-logger']); } + \Doctrine\Common\Annotations\AnnotationRegistry::registerFile( + $app['root.path'] .'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' + ); + $opCodeCacheType = $app['phraseanet.configuration']['main']['opcodecache']['type']; $opCodeCacheOptions = $app['phraseanet.configuration']['main']['opcodecache']['options']; $cacheType = $app['phraseanet.configuration']['main']['cache']['type']; $cacheOptions = $app['phraseanet.configuration']['main']['cache']['options']; + $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader; + $cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader( + $annotationReader, + new \Doctrine\Common\Cache\ArrayCache + ); + + $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain(); + \Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM( + $driverChain, + $cachedAnnotationReader + ); + + $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver( + $annotationReader, + array($app['root.path'].'/lib/Doctrine/Entities') + ); + + $driverChain->addDriver($annotationDriver, 'Entities'); + $config->setMetadataCacheImpl($app['phraseanet.cache-service']->factory( 'ORMmetadata', $opCodeCacheType, $opCodeCacheOptions )); + $config->setQueryCacheImpl($app['phraseanet.cache-service']->factory( 'ORMquery', $opCodeCacheType, $opCodeCacheOptions )); @@ -64,14 +88,12 @@ class ORMServiceProvider implements ServiceProviderInterface 'ORMresult', $cacheType, $cacheOptions )); - //define autoregeneration of proxies base on debug mode $config->setAutoGenerateProxyClasses($app['debug']); - $chainDriverImpl = new DriverChain(); - $driverYaml = new YamlDriver(array($app['root.path'] . '/lib/conf.d/Doctrine')); - $chainDriverImpl->addDriver($driverYaml, 'Entities'); - $chainDriverImpl->addDriver($driverYaml, 'Gedmo\Timestampable'); - $config->setMetadataDriverImpl($chainDriverImpl); +// $driverYaml = new YamlDriver(array($app['root.path'] . '/lib/conf.d/Doctrine')); +// $chainDriverImpl->addDriver($driverYaml, 'Entities'); + + $config->setMetadataDriverImpl($driverChain); $config->setProxyDir($app['root.path'] . '/lib/Doctrine/Proxies'); $config->setProxyNamespace('Proxies'); diff --git a/lib/Doctrine/Entities/AuthFailure.php b/lib/Doctrine/Entities/AuthFailure.php index b2121eee59..77c426cb89 100644 --- a/lib/Doctrine/Entities/AuthFailure.php +++ b/lib/Doctrine/Entities/AuthFailure.php @@ -12,34 +12,39 @@ namespace Entities; use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * AuthFailure + * @ORM\Table(name="AuthFailures") + * @ORM\Entity(repositoryClass="Repositories\AuthFailureRepository") */ class AuthFailure { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var string + * @ORM\Column(type="string", length=128) */ private $username; /** - * @var string + * @ORM\Column(type="string", length=128, nullable=true) */ private $ip; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $locked; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; diff --git a/lib/Doctrine/Entities/Basket.php b/lib/Doctrine/Entities/Basket.php index 634429e195..c024fecb9b 100644 --- a/lib/Doctrine/Entities/Basket.php +++ b/lib/Doctrine/Entities/Basket.php @@ -12,9 +12,12 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * Basket + * @ORM\Table(name="Baskets") + * @ORM\Entity(repositoryClass="Repositories\BasketRepository") */ class Basket { @@ -23,57 +26,62 @@ class Basket const ELEMENTSORDER_ASC = 'asc'; /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var string + * @ORM\Column(type="string", length=128) */ private $name; /** - * @var string + * @ORM\Column(type="text", nullable=true) */ private $description; /** - * @var integer + * @ORM\Column(type="integer") */ private $usr_id; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $is_read = false; /** - * @var integer + * @ORM\Column(type="integer", nullable=true) */ private $pusher_id; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $archived = false; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="update") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Entities\ValidationSession + * @ORM\OneToOne(targetEntity="ValidationSession", mappedBy="basket", cascade={"ALL"}) */ private $validation; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="BasketElement", mappedBy="basket", cascade={"ALL"}) + * @ORM\OrderBy({"ord" = "ASC"}) */ private $elements; diff --git a/lib/Doctrine/Entities/BasketElement.php b/lib/Doctrine/Entities/BasketElement.php index 17f196bb85..137623cd51 100644 --- a/lib/Doctrine/Entities/BasketElement.php +++ b/lib/Doctrine/Entities/BasketElement.php @@ -13,49 +13,57 @@ namespace Entities; use Alchemy\Phrasea\Application; use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * BasketElement + * @ORM\Table(name="BasketElements", uniqueConstraints={@ORM\UniqueConstraint(name="unique_recordcle", columns={"basket_id","sbas_id","record_id"})}) + * @ORM\Entity(repositoryClass="Repositories\BasketElementRepository") + * @ORM\HasLifecycleCallbacks */ class BasketElement { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $record_id; /** - * @var integer + * @ORM\Column(type="integer") */ private $sbas_id; /** - * @var integer + * @ORM\Column(type="integer") */ private $ord; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="ValidationData", mappedBy="basket_element", cascade={"all"}) */ private $validation_datas; /** - * @var \Entities\Basket + * @ORM\ManyToOne(targetEntity="Basket", inversedBy="elements", cascade={"persist"}) + * @ORM\JoinColumn(name="basket_id", referencedColumnName="id") */ private $basket; diff --git a/lib/Doctrine/Entities/LazaretAttribute.php b/lib/Doctrine/Entities/LazaretAttribute.php index 0484aa0df1..15dc073d36 100644 --- a/lib/Doctrine/Entities/LazaretAttribute.php +++ b/lib/Doctrine/Entities/LazaretAttribute.php @@ -12,39 +12,47 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * LazaretAttribute + * @ORM\Table(name="LazaretAttributes") + * @ORM\Entity */ class LazaretAttribute { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var string + * @ORM\Column(type="string", length=64) */ private $name; /** - * @var string + * @ORM\Column(type="string", length=2048) */ private $value; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Entities\LazaretFile + * @ORM\ManyToOne(targetEntity="LazaretFile", inversedBy="attributes", cascade={"persist"}) + * @ORM\JoinColumn(name="lazaret_file_id", referencedColumnName="id") */ private $lazaretFile; diff --git a/lib/Doctrine/Entities/LazaretCheck.php b/lib/Doctrine/Entities/LazaretCheck.php index 4de1fd2c2e..19f0680175 100644 --- a/lib/Doctrine/Entities/LazaretCheck.php +++ b/lib/Doctrine/Entities/LazaretCheck.php @@ -12,24 +12,30 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * LazaretCheck + * @ORM\Table(name="LazaretChecks") + * @ORM\Entity */ class LazaretCheck { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var string + * @ORM\Column(type="string", length=512) */ private $checkClassname; /** - * @var \Entities\LazaretFile + * @ORM\ManyToOne(targetEntity="LazaretFile", inversedBy="checks", cascade={"persist"}) + * @ORM\JoinColumn(name="lazaret_file_id", referencedColumnName="id") */ private $lazaretFile; diff --git a/lib/Doctrine/Entities/LazaretFile.php b/lib/Doctrine/Entities/LazaretFile.php index 615a077462..1a164df7bf 100644 --- a/lib/Doctrine/Entities/LazaretFile.php +++ b/lib/Doctrine/Entities/LazaretFile.php @@ -12,74 +12,84 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * LazaretFile + * @ORM\Table(name="LazaretFiles") + * @ORM\Entity(repositoryClass="Repositories\LazaretFileRepository") */ class LazaretFile { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var string + * @ORM\Column(type="string", length=512) */ private $filename; /** - * @var string + * @ORM\Column(type="string", length=512) */ private $thumbFilename; /** - * @var string + * @ORM\Column(type="string", length=256) */ private $originalName; /** - * @var integer + * @ORM\Column(type="integer") */ private $base_id; /** - * @var string + * @ORM\Column(type="string", length=36) */ private $uuid; /** - * @var string + * @ORM\Column(type="string", length=64) */ private $sha256; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $forced = false; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="LazaretAttribute", mappedBy="lazaretFile", cascade={"all"}) + * @ORM\OrderBy({"id" = "ASC"}) */ private $attributes; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="LazaretCheck", mappedBy="lazaretFile", cascade={"all"}) + * @ORM\OrderBy({"id" = "ASC"}) */ private $checks; /** - * @var \Entities\LazaretSession + * @ORM\ManyToOne(targetEntity="LazaretSession", inversedBy="files", cascade={"persist"}) + * @ORM\JoinColumn(name="lazaret_session_id", referencedColumnName="id") */ private $session; diff --git a/lib/Doctrine/Entities/LazaretSession.php b/lib/Doctrine/Entities/LazaretSession.php index 33f84ad7e6..75049a3b90 100644 --- a/lib/Doctrine/Entities/LazaretSession.php +++ b/lib/Doctrine/Entities/LazaretSession.php @@ -12,34 +12,42 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * LazaretSession + * @ORM\Table(name="LazaretSessions") + * @ORM\Entity */ class LazaretSession { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; - /** - * @var integer + /** + * @ORM\Column(type="integer", nullable=true) */ private $usr_id; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="LazaretFile", mappedBy="session", cascade={"all"}) + * @ORM\OrderBy({"id" = "ASC"}) */ private $files; diff --git a/lib/Doctrine/Entities/Session.php b/lib/Doctrine/Entities/Session.php index e4c74907c5..8e1ffb583e 100644 --- a/lib/Doctrine/Entities/Session.php +++ b/lib/Doctrine/Entities/Session.php @@ -12,79 +12,87 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * Session + * @ORM\Table(name="Sessions", indexes={@ORM\index(name="usr_id", columns={"usr_id"})}) + * @ORM\Entity(repositoryClass="Repositories\SessionRepository") */ class Session { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $usr_id; /** - * @var string + * @ORM\Column(type="string", length=512) */ private $user_agent; /** - * @var string + * @ORM\Column(type="string", length=40, nullable=true) */ private $ip_address; /** - * @var string + * @ORM\Column(type="string", length=128, nullable=true) */ private $platform; /** - * @var string + * @ORM\Column(type="string", length=128, nullable=true) */ private $browser_name; /** - * @var string + * @ORM\Column(type="string", length=32, nullable=true) */ private $browser_version; /** - * @var integer + * @ORM\Column(type="integer", nullable=true) */ private $screen_width; /** - * @var integer + * @ORM\Column(type="integer", nullable=true) */ private $screen_height; /** - * @var string + * @ORM\Column(type="string", length=128, nullable=true, unique=true) */ private $token; /** - * @var string + * @ORM\Column(type="string", length=16, nullable=true) */ private $nonce; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="SessionModule", mappedBy="session", cascade={"all"}) + * @ORM\OrderBy({"module_id" = "ASC"}) */ private $modules; diff --git a/lib/Doctrine/Entities/SessionModule.php b/lib/Doctrine/Entities/SessionModule.php index 4422fa6ede..5e2a0d43cc 100644 --- a/lib/Doctrine/Entities/SessionModule.php +++ b/lib/Doctrine/Entities/SessionModule.php @@ -12,34 +12,42 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * SessionModule + * @ORM\Table(name="SessionModules", uniqueConstraints={@ORM\UniqueConstraint(name="unique_module", columns={"session_id", "module_id"})}) + * @ORM\Entity(repositoryClass="Repositories\SessionModuleRepository") */ class SessionModule { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $module_id; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Entities\Session + * @ORM\ManyToOne(targetEntity="Session", inversedBy="modules", cascade={"persist"}) + * @ORM\JoinColumn(name="session_id", referencedColumnName="id") */ private $session; diff --git a/lib/Doctrine/Entities/StoryWZ.php b/lib/Doctrine/Entities/StoryWZ.php index 7382f6faae..da31fbc439 100644 --- a/lib/Doctrine/Entities/StoryWZ.php +++ b/lib/Doctrine/Entities/StoryWZ.php @@ -13,33 +13,40 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; + /** - * StoryWZ + * @ORM\Table(name="StoryWZ", uniqueConstraints={@ORM\UniqueConstraint(name="user_story", columns={"usr_id", "sbas_id", "record_id"})}) + * @ORM\Entity(repositoryClass="Repositories\StoryWZRepository") */ class StoryWZ { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $sbas_id; /** - * @var integer + * @ORM\Column(type="integer") */ private $record_id; /** - * @var integer + * @ORM\Column(type="integer") */ private $usr_id; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; diff --git a/lib/Doctrine/Entities/UsrAuthProvider.php b/lib/Doctrine/Entities/UsrAuthProvider.php index 88d3b7cb0d..cba9cb8715 100644 --- a/lib/Doctrine/Entities/UsrAuthProvider.php +++ b/lib/Doctrine/Entities/UsrAuthProvider.php @@ -3,42 +3,52 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * UsrAuthProvider + * @ORM\Table(name="UsrAuthProviders", uniqueConstraints={ + * @ORM\UniqueConstraint(name="unique_provider_per_user", columns={"usr_id", "provider"}), + * @ORM\UniqueConstraint(name="provider_ids", columns={"provider", "distant_id"}) + * }) + * @ORM\Entity(repositoryClass="Repositories\UsrAuthProviderRepository") */ class UsrAuthProvider { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $usr_id; /** - * @var string + * @ORM\Column(type="string", length=32) */ private $provider; /** - * @var string + * @ORM\Column(type="string", length=192) */ private $distant_id; /** - * @var \DateTime - */ - private $updated; - - /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; + /** + * @Gedmo\Timestampable(on="update") + * @ORM\Column(type="datetime") + */ + private $updated; + /** * Get id * diff --git a/lib/Doctrine/Entities/UsrList.php b/lib/Doctrine/Entities/UsrList.php index 06dd1e7d98..1b7db5d077 100644 --- a/lib/Doctrine/Entities/UsrList.php +++ b/lib/Doctrine/Entities/UsrList.php @@ -12,39 +12,46 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * UsrList + * @ORM\Table(name="UsrLists") + * @ORM\Entity(repositoryClass="Repositories\UsrListRepository") */ class UsrList { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var string + * @ORM\Column(type="string") */ private $name; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="UsrListOwner", mappedBy="list", cascade={"all"}) */ private $owners; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="UsrListEntry", mappedBy="list", cascade={"all"}) */ private $entries; diff --git a/lib/Doctrine/Entities/UsrListEntry.php b/lib/Doctrine/Entities/UsrListEntry.php index 56d270fab1..aa0e19b4b1 100644 --- a/lib/Doctrine/Entities/UsrListEntry.php +++ b/lib/Doctrine/Entities/UsrListEntry.php @@ -12,34 +12,42 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * UsrListEntry + * @ORM\Table(name="UsrListsContent", uniqueConstraints={@ORM\UniqueConstraint(name="unique_usr_per_list", columns={"usr_id", "list_id"})}) + * @ORM\Entity(repositoryClass="Repositories\UsrListEntryRepository") */ class UsrListEntry { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $usr_id; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Entities\UsrList + * @ORM\ManyToOne(targetEntity="UsrList", inversedBy="entries", cascade={"persist"}) + * @ORM\JoinColumn(name="list_id", referencedColumnName="id") */ private $list; diff --git a/lib/Doctrine/Entities/UsrListOwner.php b/lib/Doctrine/Entities/UsrListOwner.php index 2aae123dc0..0239094440 100644 --- a/lib/Doctrine/Entities/UsrListOwner.php +++ b/lib/Doctrine/Entities/UsrListOwner.php @@ -12,9 +12,12 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * UsrListOwner + * @ORM\Table(name="UsrListOwners", uniqueConstraints={@ORM\UniqueConstraint(name="unique_owner", columns={"usr_id", "id"})}) + * @ORM\Entity(repositoryClass="Repositories\UsrListOwnerRepository") */ class UsrListOwner { @@ -23,32 +26,37 @@ class UsrListOwner const ROLE_ADMIN = 3; /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $usr_id; /** - * @var string + * @ORM\Column(type="string") */ private $role; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Entities\UsrList + * @ORM\ManyToOne(targetEntity="UsrList", inversedBy="owners", cascade={"persist"}) + * @ORM\JoinColumn(name="list_id", referencedColumnName="id") */ private $list; diff --git a/lib/Doctrine/Entities/ValidationData.php b/lib/Doctrine/Entities/ValidationData.php index 64474e687c..0ef19b8c8c 100644 --- a/lib/Doctrine/Entities/ValidationData.php +++ b/lib/Doctrine/Entities/ValidationData.php @@ -12,39 +12,47 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * ValidationData + * @ORM\Table(name="ValidationDatas") + * @ORM\Entity */ class ValidationData { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var boolean + * @ORM\Column(type="boolean", nullable=true) */ private $agreement; /** - * @var string + * @ORM\Column(type="text", nullable=true) */ private $note; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \Entities\ValidationParticipant + * @ORM\ManyToOne(targetEntity="ValidationParticipant", inversedBy="datas", cascade={"persist"}) + * @ORM\JoinColumn(name="participant_id", referencedColumnName="id") */ private $participant; /** - * @var \Entities\BasketElement + * @ORM\ManyToOne(targetEntity="BasketElement", inversedBy="validation_datas", cascade={"persist"}) + * @ORM\JoinColumn(name="basket_element_id", referencedColumnName="id") */ private $basket_element; diff --git a/lib/Doctrine/Entities/ValidationParticipant.php b/lib/Doctrine/Entities/ValidationParticipant.php index c21e84a85c..b708f750b5 100644 --- a/lib/Doctrine/Entities/ValidationParticipant.php +++ b/lib/Doctrine/Entities/ValidationParticipant.php @@ -12,54 +12,60 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; /** - * ValidationParticipant + * @ORM\Table(name="ValidationParticipants") + * @ORM\Entity(repositoryClass="Repositories\ValidationParticipantRepository") */ class ValidationParticipant { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $usr_id; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $is_aware = false; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $is_confirmed = false; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $can_agree = false; /** - * @var boolean + * @ORM\Column(type="boolean") */ private $can_see_others = false; /** - * @var \DateTime + * @ORM\Column(type="datetime", nullable=true) */ private $reminded; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="ValidationData", mappedBy="participant", cascade={"all"}) */ private $datas; /** - * @var \Entities\ValidationSession + * @ORM\ManyToOne(targetEntity="ValidationSession", inversedBy="participants", cascade={"persist"}) + * @ORM\JoinColumn(name="ValidationSession_id", referencedColumnName="id") */ private $session; diff --git a/lib/Doctrine/Entities/ValidationSession.php b/lib/Doctrine/Entities/ValidationSession.php index f0c4667ac0..d3a51aa40a 100644 --- a/lib/Doctrine/Entities/ValidationSession.php +++ b/lib/Doctrine/Entities/ValidationSession.php @@ -12,45 +12,53 @@ namespace Entities; use Alchemy\Phrasea\Application; +use Doctrine\ORM\Mapping as ORM; +use Gedmo\Mapping\Annotation as Gedmo; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; /** - * ValidationSession + * @ORM\Table(name="ValidationSessions") + * @ORM\Entity */ class ValidationSession { /** - * @var integer + * @ORM\Column(type="integer") + * @ORM\Id + * @ORM\GeneratedValue */ private $id; /** - * @var integer + * @ORM\Column(type="integer") */ private $initiator_id; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $created; /** - * @var \DateTime + * @Gedmo\Timestampable(on="create") + * @ORM\Column(type="datetime") */ private $updated; /** - * @var \DateTime + * @ORM\Column(type="datetime", nullable=true) */ private $expires; /** - * @var \Entities\Basket + * @ORM\OneToOne(targetEntity="Basket", mappedBy="validation", cascade={"persist"}) + * @ORM\JoinColumn(name="basket_id", referencedColumnName="id") */ private $basket; /** - * @var \Doctrine\Common\Collections\Collection + * @ORM\OneToMany(targetEntity="ValidationParticipant", mappedBy="session", cascade={"all"}) */ private $participants; From 4c5ed2b153363143a2a872c73544ade05ecaeb36 Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 5 Aug 2013 18:18:26 +0200 Subject: [PATCH 2/7] Removed .yml files, added filecachereader --- .../Core/Provider/ORMServiceProvider.php | 23 +++---- .../Doctrine/Entities.AuthFailure.dcm.yml | 24 ------- lib/conf.d/Doctrine/Entities.Basket.dcm.yml | 48 -------------- .../Doctrine/Entities.BasketElement.dcm.yml | 45 ------------- .../Entities.LazaretAttribute.dcm.yml | 33 ---------- .../Doctrine/Entities.LazaretCheck.dcm.yml | 20 ------ .../Doctrine/Entities.LazaretFile.dcm.yml | 60 ----------------- .../Doctrine/Entities.LazaretSession.dcm.yml | 29 -------- lib/conf.d/Doctrine/Entities.Session.dcm.yml | 66 ------------------- .../Doctrine/Entities.SessionModule.dcm.yml | 33 ---------- lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml | 29 -------- .../Doctrine/Entities.UsrAuthProvider.dcm.yml | 33 ---------- lib/conf.d/Doctrine/Entities.UsrList.dcm.yml | 33 ---------- .../Doctrine/Entities.UsrListEntry.dcm.yml | 35 ---------- .../Doctrine/Entities.UsrListOwner.dcm.yml | 38 ----------- .../Doctrine/Entities.ValidationData.dcm.yml | 35 ---------- .../Entities.ValidationParticipant.dcm.yml | 36 ---------- .../Entities.ValidationSession.dcm.yml | 41 ------------ 18 files changed, 12 insertions(+), 649 deletions(-) delete mode 100644 lib/conf.d/Doctrine/Entities.AuthFailure.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.Basket.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.LazaretAttribute.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.LazaretCheck.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.LazaretFile.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.LazaretSession.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.Session.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.SessionModule.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.UsrAuthProvider.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.UsrList.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml delete mode 100644 lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 21e22000ad..95fadeed70 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -12,13 +12,16 @@ namespace Alchemy\Phrasea\Core\Provider; use Alchemy\Phrasea\Exception\RuntimeException; +use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\FileCacheReader; use Doctrine\Common\EventManager; +use Doctrine\ORM\Mapping\Driver\AnnotationDriver; use Doctrine\ORM\Mapping\Driver\DriverChain; -use Doctrine\ORM\Mapping\Driver\YamlDriver; use Doctrine\ORM\EntityManager; use Doctrine\ORM\Configuration as ORMConfiguration; use Doctrine\DBAL\Types\Type; use Doctrine\Logger\MonologSQLLogger; +use Gedmo\DoctrineExtensions; use Gedmo\Timestampable\TimestampableListener; use Monolog\Logger; use Monolog\Handler\RotatingFileHandler; @@ -58,19 +61,20 @@ class ORMServiceProvider implements ServiceProviderInterface $cacheType = $app['phraseanet.configuration']['main']['cache']['type']; $cacheOptions = $app['phraseanet.configuration']['main']['cache']['options']; - $annotationReader = new \Doctrine\Common\Annotations\AnnotationReader; - $cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader( + $annotationReader = new AnnotationReader; + $fileCacheReader = new FileCacheReader( $annotationReader, - new \Doctrine\Common\Cache\ArrayCache + $app['root.path']."/tmp/doctrine", + $app['debug'] ); - $driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain(); - \Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM( + $driverChain = new DriverChain(); + DoctrineExtensions::registerAbstractMappingIntoDriverChainORM( $driverChain, - $cachedAnnotationReader + $fileCacheReader ); - $annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver( + $annotationDriver = new AnnotationDriver( $annotationReader, array($app['root.path'].'/lib/Doctrine/Entities') ); @@ -90,9 +94,6 @@ class ORMServiceProvider implements ServiceProviderInterface $config->setAutoGenerateProxyClasses($app['debug']); -// $driverYaml = new YamlDriver(array($app['root.path'] . '/lib/conf.d/Doctrine')); -// $chainDriverImpl->addDriver($driverYaml, 'Entities'); - $config->setMetadataDriverImpl($driverChain); $config->setProxyDir($app['root.path'] . '/lib/Doctrine/Proxies'); diff --git a/lib/conf.d/Doctrine/Entities.AuthFailure.dcm.yml b/lib/conf.d/Doctrine/Entities.AuthFailure.dcm.yml deleted file mode 100644 index f93f1737c8..0000000000 --- a/lib/conf.d/Doctrine/Entities.AuthFailure.dcm.yml +++ /dev/null @@ -1,24 +0,0 @@ -Entities\AuthFailure: - type: entity - repositoryClass: Repositories\AuthFailureRepository - table: AuthFailures - id: - id: - type: integer - generator: - strategy: AUTO - fields: - username: - type: string - size: 128 - ip: - type: string - size: 128 - nullable: true - locked: - type: boolean - created: - type: datetime - gedmo: - timestampable: - on: create diff --git a/lib/conf.d/Doctrine/Entities.Basket.dcm.yml b/lib/conf.d/Doctrine/Entities.Basket.dcm.yml deleted file mode 100644 index d734395db2..0000000000 --- a/lib/conf.d/Doctrine/Entities.Basket.dcm.yml +++ /dev/null @@ -1,48 +0,0 @@ -Entities\Basket: - type: entity - repositoryClass: Repositories\BasketRepository - table: Baskets - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 128 - description: - type: text - nullable: true - usr_id: - type: integer - is_read: - type: boolean - pusher_id: - type: integer - nullable: true - archived: - type: boolean - default: false - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - oneToOne: - validation: - targetEntity: ValidationSession - mappedBy: basket - cascade: ["ALL"] - oneToMany: - elements: - targetEntity: BasketElement - mappedBy: basket - cascade: ["ALL"] - orderBy: - ord: ASC diff --git a/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml b/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml deleted file mode 100644 index a37e116d87..0000000000 --- a/lib/conf.d/Doctrine/Entities.BasketElement.dcm.yml +++ /dev/null @@ -1,45 +0,0 @@ -Entities\BasketElement: - type: entity - repositoryClass: Repositories\BasketElementRepository - table: BasketElements - uniqueConstraints: - unique_recordcle: - columns: basket_id,sbas_id,record_id - id: - id: - type: integer - generator: - strategy: AUTO - - fields: - record_id: - type: integer - sbas_id: - type: integer - ord: - type: integer - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - manyToOne: - basket: - targetEntity: Basket - inversedBy: elements - joinColumn: - name: basket_id - referencedColumnName: id - cascade: ["persist"] - oneToMany: - validation_datas: - targetEntity: ValidationData - mappedBy: basket_element - cascade: ["ALL"] - lifecycleCallbacks: - prePersist: [ setLastInBasket ] diff --git a/lib/conf.d/Doctrine/Entities.LazaretAttribute.dcm.yml b/lib/conf.d/Doctrine/Entities.LazaretAttribute.dcm.yml deleted file mode 100644 index c8ff7a751f..0000000000 --- a/lib/conf.d/Doctrine/Entities.LazaretAttribute.dcm.yml +++ /dev/null @@ -1,33 +0,0 @@ -Entities\LazaretAttribute: - type: entity - table: LazaretAttributes - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - length: 64 - value: - type: string - length: 2048 - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - manyToOne: - lazaretFile: - targetEntity: LazaretFile - inversedBy: attributes - joinColumn: - name: lazaret_file_id - referencedColumnName: id - cascade: ["persist"] diff --git a/lib/conf.d/Doctrine/Entities.LazaretCheck.dcm.yml b/lib/conf.d/Doctrine/Entities.LazaretCheck.dcm.yml deleted file mode 100644 index 6ff6087a04..0000000000 --- a/lib/conf.d/Doctrine/Entities.LazaretCheck.dcm.yml +++ /dev/null @@ -1,20 +0,0 @@ -Entities\LazaretCheck: - type: entity - table: LazaretChecks - id: - id: - type: integer - generator: - strategy: AUTO - fields: - checkClassname: - type: string - length: 512 - manyToOne: - lazaretFile: - targetEntity: LazaretFile - inversedBy: checks - joinColumn: - name: lazaret_file_id - referencedColumnName: id - cascade: ["persist"] diff --git a/lib/conf.d/Doctrine/Entities.LazaretFile.dcm.yml b/lib/conf.d/Doctrine/Entities.LazaretFile.dcm.yml deleted file mode 100644 index 38750d0900..0000000000 --- a/lib/conf.d/Doctrine/Entities.LazaretFile.dcm.yml +++ /dev/null @@ -1,60 +0,0 @@ -Entities\LazaretFile: - type: entity - repositoryClass: Repositories\LazaretFileRepository - table: LazaretFiles - id: - id: - type: integer - generator: - strategy: AUTO - fields: - filename: - type: string - length: 512 - thumbFilename: - type: string - length: 512 - originalName: - type: string - length: 256 - base_id: - type: integer - uuid: - type: string - length: 36 - sha256: - type: string - length: 64 - forced: - type: boolean - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - manyToOne: - session: - targetEntity: LazaretSession - inversedBy: files - joinColumn: - name: lazaret_session_id - referencedColumnName: id - cascade: ["persist"] - oneToMany: - attributes: - targetEntity: LazaretAttribute - mappedBy: lazaretFile - cascade: ["ALL"] - orderBy: - id: ASC - checks: - targetEntity: LazaretCheck - mappedBy: lazaretFile - cascade: ["ALL"] - orderBy: - id: ASC diff --git a/lib/conf.d/Doctrine/Entities.LazaretSession.dcm.yml b/lib/conf.d/Doctrine/Entities.LazaretSession.dcm.yml deleted file mode 100644 index 0e59b5a74b..0000000000 --- a/lib/conf.d/Doctrine/Entities.LazaretSession.dcm.yml +++ /dev/null @@ -1,29 +0,0 @@ -Entities\LazaretSession: - type: entity - table: LazaretSessions - id: - id: - type: integer - generator: - strategy: AUTO - fields: - usr_id: - type: integer - nullable: true - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - oneToMany: - files: - targetEntity: LazaretFile - mappedBy: session - cascade: ["ALL"] - orderBy: - id: ASC diff --git a/lib/conf.d/Doctrine/Entities.Session.dcm.yml b/lib/conf.d/Doctrine/Entities.Session.dcm.yml deleted file mode 100644 index cd93bcb07d..0000000000 --- a/lib/conf.d/Doctrine/Entities.Session.dcm.yml +++ /dev/null @@ -1,66 +0,0 @@ -Entities\Session: - type: entity - repositoryClass: Repositories\SessionRepository - table: Sessions - indexes: - usr_id: - columns: [ usr_id ] - id: - id: - type: integer - generator: - strategy: AUTO - fields: - usr_id: - type: integer - user_agent: - type: string - length: 512 - ip_address: - type: string - length: 40 - nullable: true - platform: - type: string - length: 128 - nullable: true - browser_name: - type: string - length: 128 - nullable: true - browser_version: - type: string - length: 32 - nullable: true - screen_width: - type: integer - nullable: true - screen_height: - type: integer - nullable: true - token: - type: string - length: 128 - nullable: true - unique: true - nonce: - type: string - length: 16 - nullable: true - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - oneToMany: - modules: - targetEntity: SessionModule - mappedBy: session - cascade: ["ALL"] - orderBy: - module_id: ASC \ No newline at end of file diff --git a/lib/conf.d/Doctrine/Entities.SessionModule.dcm.yml b/lib/conf.d/Doctrine/Entities.SessionModule.dcm.yml deleted file mode 100644 index 4c2611a971..0000000000 --- a/lib/conf.d/Doctrine/Entities.SessionModule.dcm.yml +++ /dev/null @@ -1,33 +0,0 @@ -Entities\SessionModule: - type: entity - repositoryClass: Repositories\SessionModuleRepository - table: SessionModules - id: - id: - type: integer - generator: - strategy: AUTO - uniqueConstraints: - unique_module: - columns: session_id,module_id - fields: - module_id: - type: integer - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - manyToOne: - session: - targetEntity: Session - inversedBy: modules - joinColumn: - name: session_id - referencedColumnName: id - cascade: ["persist"] diff --git a/lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml b/lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml deleted file mode 100644 index fd82c27ebc..0000000000 --- a/lib/conf.d/Doctrine/Entities.StoryWZ.dcm.yml +++ /dev/null @@ -1,29 +0,0 @@ -Entities\StoryWZ: - type: entity - repositoryClass: Repositories\StoryWZRepository - table: StoryWZ - uniqueConstraints: - user_story: - columns: usr_id,sbas_id,record_id - id: - id: - type: integer - generator: - strategy: AUTO - fields: - sbas_id: - type: integer - record_id: - type: integer - usr_id: - type: integer - created: - type: datetime - gedmo: - timestampable: - on: create - - - - - diff --git a/lib/conf.d/Doctrine/Entities.UsrAuthProvider.dcm.yml b/lib/conf.d/Doctrine/Entities.UsrAuthProvider.dcm.yml deleted file mode 100644 index 72f7e80285..0000000000 --- a/lib/conf.d/Doctrine/Entities.UsrAuthProvider.dcm.yml +++ /dev/null @@ -1,33 +0,0 @@ -Entities\UsrAuthProvider: - type: entity - repositoryClass: Repositories\UsrAuthProviderRepository - table: UsrAuthProviders - uniqueConstraints: - unique_provider_per_user: - columns: [ usr_id, provider ] - provider_ids: - columns: [ provider, distant_id ] - id: - id: - type: integer - generator: - strategy: AUTO - fields: - usr_id: - type: integer - provider: - type: string - length: 32 - distant_id: - type: string - length: 192 - updated: - type: datetime - gedmo: - timestampable: - on: update - created: - type: datetime - gedmo: - timestampable: - on: create diff --git a/lib/conf.d/Doctrine/Entities.UsrList.dcm.yml b/lib/conf.d/Doctrine/Entities.UsrList.dcm.yml deleted file mode 100644 index 6eb3597d9e..0000000000 --- a/lib/conf.d/Doctrine/Entities.UsrList.dcm.yml +++ /dev/null @@ -1,33 +0,0 @@ -Entities\UsrList: - type: entity - repositoryClass: Repositories\UsrListRepository - table: UsrLists - id: - id: - type: integer - generator: - strategy: AUTO - fields: - name: - type: string - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - oneToMany: - owners: - targetEntity: UsrListOwner - mappedBy: list - cascade: ["ALL"] - entries: - targetEntity: UsrListEntry - mappedBy: list - cascade: ["ALL"] - - diff --git a/lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml b/lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml deleted file mode 100644 index a9bab397a9..0000000000 --- a/lib/conf.d/Doctrine/Entities.UsrListEntry.dcm.yml +++ /dev/null @@ -1,35 +0,0 @@ -Entities\UsrListEntry: - type: entity - repositoryClass: Repositories\UsrListEntryRepository - table: UsrListsContent - uniqueConstraints: - unique_usr_per_list: - columns: usr_id,list_id - id: - id: - type: integer - generator: - strategy: AUTO - fields: - usr_id: - type: integer - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - manyToOne: - list: - targetEntity: UsrList - inversedBy: entries - joinColumn: - name: list_id - referencedColumnName: id - cascade: ["persist"] - - diff --git a/lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml b/lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml deleted file mode 100644 index 9fb72bc084..0000000000 --- a/lib/conf.d/Doctrine/Entities.UsrListOwner.dcm.yml +++ /dev/null @@ -1,38 +0,0 @@ -Entities\UsrListOwner: - type: entity - repositoryClass: Repositories\UsrListOwnerRepository - table: UsrListOwners - uniqueConstraints: - unique_owner: - columns: usr_id,id - id: - id: - type: integer - generator: - strategy: AUTO - fields: - usr_id: - type: integer - role: - type: string - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - manyToOne: - list: - targetEntity: UsrList - inversedBy: owners - joinColumn: - name: list_id - referencedColumnName: id - cascade: ["persist"] - - - diff --git a/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml deleted file mode 100644 index 0133e0da2d..0000000000 --- a/lib/conf.d/Doctrine/Entities.ValidationData.dcm.yml +++ /dev/null @@ -1,35 +0,0 @@ -Entities\ValidationData: - type: entity - table: ValidationDatas - id: - id: - type: integer - generator: - strategy: AUTO - fields: - agreement: - type: boolean - nullable: true - note: - type: text - nullable: true - updated: - type: datetime - gedmo: - timestampable: - on: update - manyToOne: - participant: - targetEntity: ValidationParticipant - inversedBy: datas - joinColumn: - name: participant_id - referencedColumnName: id - cascade: ["persist"] - basket_element: - targetEntity: BasketElement - inversedBy: validation_datas - joinColumn: - name: basket_element_id - referencedColumnName: id - cascade: ["persist"] diff --git a/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml deleted file mode 100644 index 0d458c6e9d..0000000000 --- a/lib/conf.d/Doctrine/Entities.ValidationParticipant.dcm.yml +++ /dev/null @@ -1,36 +0,0 @@ -Entities\ValidationParticipant: - type: entity - repositoryClass: Repositories\ValidationParticipantRepository - table: ValidationParticipants - id: - id: - type: integer - generator: - strategy: AUTO - fields: - usr_id: - type: integer - is_aware: - type: boolean - is_confirmed: - type: boolean - can_agree: - type: boolean - can_see_others: - type: boolean - reminded: - type: datetime - nullable: true; - oneToMany: - datas: - targetEntity: ValidationData - mappedBy: participant - cascade: ["ALL"] - manyToOne: - session: - targetEntity: ValidationSession - inversedBy: participants - joinColumn: - name: ValidationSession_id - referencedColumnName: id - cascade: ["persist"] diff --git a/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml b/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml deleted file mode 100644 index 1c3c901c27..0000000000 --- a/lib/conf.d/Doctrine/Entities.ValidationSession.dcm.yml +++ /dev/null @@ -1,41 +0,0 @@ -Entities\ValidationSession: - type: entity - table: ValidationSessions - id: - id: - type: integer - generator: - strategy: AUTO - fields: - initiator_id: - type: integer - created: - type: datetime - gedmo: - timestampable: - on: create - updated: - type: datetime - gedmo: - timestampable: - on: update - expires: - type: datetime - nullable: true - oneToOne: - basket: - targetEntity: Basket - inversedBy: validation - joinColumn: - name: basket_id - referencedColumnName: id - cascade: ["persist"] - oneToMany: - participants: - targetEntity: ValidationParticipant - mappedBy: session - cascade: ["ALL"] - - - - From 81a6d3e9dee59633e0ed1e2e336b0b0ac26fd5af Mon Sep 17 00:00:00 2001 From: Andrey Date: Mon, 5 Aug 2013 18:19:54 +0200 Subject: [PATCH 3/7] Added namespaces --- lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 95fadeed70..0017867a0f 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -13,6 +13,7 @@ namespace Alchemy\Phrasea\Core\Provider; use Alchemy\Phrasea\Exception\RuntimeException; use Doctrine\Common\Annotations\AnnotationReader; +use Doctrine\Common\Annotations\AnnotationRegistry; use Doctrine\Common\Annotations\FileCacheReader; use Doctrine\Common\EventManager; use Doctrine\ORM\Mapping\Driver\AnnotationDriver; @@ -51,7 +52,7 @@ class ORMServiceProvider implements ServiceProviderInterface $config->setSQLLogger($app['EM.sql-logger']); } - \Doctrine\Common\Annotations\AnnotationRegistry::registerFile( + AnnotationRegistry::registerFile( $app['root.path'] .'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' ); From c756a56383b492c2c6382a954a2ea0831b96bd27 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 6 Aug 2013 11:05:16 +0200 Subject: [PATCH 4/7] Fixed codestyle of entities --- lib/Doctrine/Entities/LazaretAttribute.php | 1 - lib/Doctrine/Entities/LazaretCheck.php | 2 -- lib/Doctrine/Entities/SessionModule.php | 1 - lib/Doctrine/Entities/ValidationData.php | 1 - lib/Doctrine/Entities/ValidationParticipant.php | 1 - 5 files changed, 6 deletions(-) diff --git a/lib/Doctrine/Entities/LazaretAttribute.php b/lib/Doctrine/Entities/LazaretAttribute.php index 15dc073d36..9ecff5bf60 100644 --- a/lib/Doctrine/Entities/LazaretAttribute.php +++ b/lib/Doctrine/Entities/LazaretAttribute.php @@ -11,7 +11,6 @@ namespace Entities; -use Alchemy\Phrasea\Application; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; diff --git a/lib/Doctrine/Entities/LazaretCheck.php b/lib/Doctrine/Entities/LazaretCheck.php index 19f0680175..8a8caa338c 100644 --- a/lib/Doctrine/Entities/LazaretCheck.php +++ b/lib/Doctrine/Entities/LazaretCheck.php @@ -11,9 +11,7 @@ namespace Entities; -use Alchemy\Phrasea\Application; use Doctrine\ORM\Mapping as ORM; -use Gedmo\Mapping\Annotation as Gedmo; /** * @ORM\Table(name="LazaretChecks") diff --git a/lib/Doctrine/Entities/SessionModule.php b/lib/Doctrine/Entities/SessionModule.php index 5e2a0d43cc..c29685ba96 100644 --- a/lib/Doctrine/Entities/SessionModule.php +++ b/lib/Doctrine/Entities/SessionModule.php @@ -11,7 +11,6 @@ namespace Entities; -use Alchemy\Phrasea\Application; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; diff --git a/lib/Doctrine/Entities/ValidationData.php b/lib/Doctrine/Entities/ValidationData.php index 0ef19b8c8c..14f37f890b 100644 --- a/lib/Doctrine/Entities/ValidationData.php +++ b/lib/Doctrine/Entities/ValidationData.php @@ -11,7 +11,6 @@ namespace Entities; -use Alchemy\Phrasea\Application; use Doctrine\ORM\Mapping as ORM; use Gedmo\Mapping\Annotation as Gedmo; diff --git a/lib/Doctrine/Entities/ValidationParticipant.php b/lib/Doctrine/Entities/ValidationParticipant.php index b708f750b5..be257e0b20 100644 --- a/lib/Doctrine/Entities/ValidationParticipant.php +++ b/lib/Doctrine/Entities/ValidationParticipant.php @@ -13,7 +13,6 @@ namespace Entities; use Alchemy\Phrasea\Application; use Doctrine\ORM\Mapping as ORM; -use Gedmo\Mapping\Annotation as Gedmo; /** * @ORM\Table(name="ValidationParticipants") From 35cc66cc8f3c27f25c95912c282fada569f72780 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 6 Aug 2013 11:42:23 +0200 Subject: [PATCH 5/7] Fixed codestyle of ORMServiceProvider --- lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php index 0017867a0f..e602080d57 100644 --- a/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php +++ b/lib/Alchemy/Phrasea/Core/Provider/ORMServiceProvider.php @@ -53,7 +53,7 @@ class ORMServiceProvider implements ServiceProviderInterface } AnnotationRegistry::registerFile( - $app['root.path'] .'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' + $app['root.path'].'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' ); $opCodeCacheType = $app['phraseanet.configuration']['main']['opcodecache']['type']; @@ -62,7 +62,7 @@ class ORMServiceProvider implements ServiceProviderInterface $cacheType = $app['phraseanet.configuration']['main']['cache']['type']; $cacheOptions = $app['phraseanet.configuration']['main']['cache']['options']; - $annotationReader = new AnnotationReader; + $annotationReader = new AnnotationReader(); $fileCacheReader = new FileCacheReader( $annotationReader, $app['root.path']."/tmp/doctrine", From d4dced5264b74f34c2c5af8032cc4d19db292423 Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 6 Aug 2013 12:25:16 +0200 Subject: [PATCH 6/7] Replaced mappedBy with inversedBy in oneToOne relations --- lib/Doctrine/Entities/Basket.php | 2 +- lib/Doctrine/Entities/ValidationSession.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/Entities/Basket.php b/lib/Doctrine/Entities/Basket.php index c024fecb9b..2308384251 100644 --- a/lib/Doctrine/Entities/Basket.php +++ b/lib/Doctrine/Entities/Basket.php @@ -75,7 +75,7 @@ class Basket private $updated; /** - * @ORM\OneToOne(targetEntity="ValidationSession", mappedBy="basket", cascade={"ALL"}) + * @ORM\OneToOne(targetEntity="ValidationSession", inversedBy="basket", cascade={"ALL"}) */ private $validation; diff --git a/lib/Doctrine/Entities/ValidationSession.php b/lib/Doctrine/Entities/ValidationSession.php index d3a51aa40a..c0159536be 100644 --- a/lib/Doctrine/Entities/ValidationSession.php +++ b/lib/Doctrine/Entities/ValidationSession.php @@ -52,7 +52,7 @@ class ValidationSession private $expires; /** - * @ORM\OneToOne(targetEntity="Basket", mappedBy="validation", cascade={"persist"}) + * @ORM\OneToOne(targetEntity="Basket", inversedBy="validation", cascade={"persist"}) * @ORM\JoinColumn(name="basket_id", referencedColumnName="id") */ private $basket; From 1693de2d72dc757c002f4b34cc59606a593843eb Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 6 Aug 2013 16:19:00 +0200 Subject: [PATCH 7/7] Fixed mappedBy confusion in Basket --- lib/Doctrine/Entities/Basket.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Doctrine/Entities/Basket.php b/lib/Doctrine/Entities/Basket.php index 2308384251..c024fecb9b 100644 --- a/lib/Doctrine/Entities/Basket.php +++ b/lib/Doctrine/Entities/Basket.php @@ -75,7 +75,7 @@ class Basket private $updated; /** - * @ORM\OneToOne(targetEntity="ValidationSession", inversedBy="basket", cascade={"ALL"}) + * @ORM\OneToOne(targetEntity="ValidationSession", mappedBy="basket", cascade={"ALL"}) */ private $validation;