From 873e758fef53d27af5216492876202da8c5d1d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 24 Oct 2014 12:19:30 +0200 Subject: [PATCH] implements user-scope-role-scope first work --- .gitignore | 1 + Entity/Agent.php | 64 ----------- Entity/User.php | 108 ++++++++++++++++++ .../{Agent.orm.yml => Center.orm.yml} | 8 +- Resources/config/doctrine/RoleScope.orm.yml | 17 +++ Resources/config/doctrine/Scope.orm.yml | 16 +++ Resources/config/doctrine/User.orm.yml | 21 ++++ Tests/Fixtures/App/AppKernel.php | 1 + Tests/Fixtures/App/config/config.yml | 14 +++ Tests/Fixtures/App/config/parameters.yml.dist | 11 ++ composer.json | 6 +- 11 files changed, 197 insertions(+), 70 deletions(-) delete mode 100644 Entity/Agent.php create mode 100644 Entity/User.php rename Resources/config/doctrine/{Agent.orm.yml => Center.orm.yml} (58%) create mode 100644 Resources/config/doctrine/RoleScope.orm.yml create mode 100644 Resources/config/doctrine/Scope.orm.yml create mode 100644 Resources/config/doctrine/User.orm.yml create mode 100644 Tests/Fixtures/App/config/parameters.yml.dist diff --git a/.gitignore b/.gitignore index 68c0e6f92..8383a1071 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ web/bundles/* # Configuration files app/config/parameters.ini app/config/parameters.yml +Tests/Fixtures/App/config/parameters.yml #composer composer.lock diff --git a/Entity/Agent.php b/Entity/Agent.php deleted file mode 100644 index fe6d63c98..000000000 --- a/Entity/Agent.php +++ /dev/null @@ -1,64 +0,0 @@ -id; - } - - /** - * Set name - * - * @param string $name - * @return Agent - */ - public function setName($name) - { - $this->name = $name; - - return $this; - } - - /** - * Get name - * - * @return string - */ - public function getName() - { - return $this->name; - } - - public function __toString() { - return parent::__toString(); - } -} diff --git a/Entity/User.php b/Entity/User.php new file mode 100644 index 000000000..16c09063b --- /dev/null +++ b/Entity/User.php @@ -0,0 +1,108 @@ +id; + } + + /** + * Set username + * + * @param string $name + * @return Agent + */ + public function setUsername($name) + { + $this->username = $name; + + return $this; + } + + /** + * Get name + * + * @return string + */ + public function getName() + { + return $this->username; + } + + public function __toString() { + return $this->getUsername(); + } + + public function eraseCredentials() + { + + } + + public function getPassword() + { + return $this->password; + } + + public function getRoles() + { + return 'ROLE_USER'; + } + + public function getSalt() + { + return $this->salt; + } + + public function getUsername() + { + return $this->username; + } + + function setPassword($password) + { + $this->password = $password; + return $this; + } + + function setSalt($salt) + { + $this->salt = $salt; + return $this; + } + + + +} diff --git a/Resources/config/doctrine/Agent.orm.yml b/Resources/config/doctrine/Center.orm.yml similarity index 58% rename from Resources/config/doctrine/Agent.orm.yml rename to Resources/config/doctrine/Center.orm.yml index adec421b4..16856e519 100644 --- a/Resources/config/doctrine/Agent.orm.yml +++ b/Resources/config/doctrine/Center.orm.yml @@ -1,6 +1,6 @@ -Chill\MainBundle\Entity\Agent: +Chill\MainBundle\Entity\Center: type: entity - table: agents + table: centers id: id: type: integer @@ -9,6 +9,4 @@ Chill\MainBundle\Entity\Agent: strategy: AUTO fields: name: - type: string - length: 80 - + type: json_array \ No newline at end of file diff --git a/Resources/config/doctrine/RoleScope.orm.yml b/Resources/config/doctrine/RoleScope.orm.yml new file mode 100644 index 000000000..32ecd4f86 --- /dev/null +++ b/Resources/config/doctrine/RoleScope.orm.yml @@ -0,0 +1,17 @@ +Chill\MainBundle\Entity\RoleScope: + type: entity + table: role_scopes + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + role: + type: string + length: 255 + oneToMany: + scope: + targetEntity: Chill\MainBundle\Entity\Scope + mappedBy: roleScopes \ No newline at end of file diff --git a/Resources/config/doctrine/Scope.orm.yml b/Resources/config/doctrine/Scope.orm.yml new file mode 100644 index 000000000..a79ab3d29 --- /dev/null +++ b/Resources/config/doctrine/Scope.orm.yml @@ -0,0 +1,16 @@ +Chill\MainBundle\Entity\Scope: + type: entity + table: scopes + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + name: + type: json_array + manyToOne: + roleScopes: + targetEntity: Chill\MainBundle\Entity\RoleScope + inversedBy: scope \ No newline at end of file diff --git a/Resources/config/doctrine/User.orm.yml b/Resources/config/doctrine/User.orm.yml new file mode 100644 index 000000000..7edb8230a --- /dev/null +++ b/Resources/config/doctrine/User.orm.yml @@ -0,0 +1,21 @@ +Chill\MainBundle\Entity\User: + type: entity + table: users + id: + id: + type: integer + id: true + generator: + strategy: AUTO + fields: + username: + type: string + length: 80 + password: + type: string + length: 255 + salt: + type: string + length: 255 + + diff --git a/Tests/Fixtures/App/AppKernel.php b/Tests/Fixtures/App/AppKernel.php index de2e11b9c..001d9f4a1 100644 --- a/Tests/Fixtures/App/AppKernel.php +++ b/Tests/Fixtures/App/AppKernel.php @@ -13,6 +13,7 @@ class AppKernel extends Kernel new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(), new \Symfony\Bundle\AsseticBundle\AsseticBundle(), + new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), ); } diff --git a/Tests/Fixtures/App/config/config.yml b/Tests/Fixtures/App/config/config.yml index 0046eed72..65d55d368 100644 --- a/Tests/Fixtures/App/config/config.yml +++ b/Tests/Fixtures/App/config/config.yml @@ -1,3 +1,6 @@ +imports: + - { resource: parameters.yml } + framework: secret: Not very secret router: { resource: "%kernel.root_dir%/config/routing.yml" } @@ -9,3 +12,14 @@ framework: profiler: { only_exceptions: false } templating: engines: ['twig'] + +# Doctrine Configuration +doctrine: + dbal: + driver: pdo_pgsql + host: "%database_host%" + port: "%database_port%" + dbname: "%database_name%" + user: "%database_user%" + password: "%database_password%" + charset: UTF8 diff --git a/Tests/Fixtures/App/config/parameters.yml.dist b/Tests/Fixtures/App/config/parameters.yml.dist new file mode 100644 index 000000000..38fab7fd2 --- /dev/null +++ b/Tests/Fixtures/App/config/parameters.yml.dist @@ -0,0 +1,11 @@ +parameters: + database_host: 127.0.0.1 + database_port: 5435 + database_name: chill + database_user: chill + database_password: chill + locale: fr + secret: ThisTokenIsNotSoSecretChangeIt + debug_toolbar: true + debug_redirects: false + use_assetic_controller: true \ No newline at end of file diff --git a/composer.json b/composer.json index 05765c64f..c09d49c25 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,11 @@ "symfony/monolog-bundle": "~2.4", "symfony/framework-bundle": "2.5.*", "symfony/yaml": "2.5.*", - "symfony/symfony": "2.5.*" + "symfony/symfony": "2.5.*", + "doctrine/dbal": "2.5.*@dev", + "doctrine/orm": "2.5.*@dev", + "doctrine/common": "2.4.*@dev", + "doctrine/doctrine-bundle": "~1.2@dev" }, "require-dev": { "symfony/dom-crawler": "2.5"