diff --git a/DataFixtures/ORM/LoadAgents.php b/DataFixtures/ORM/LoadAgents.php
deleted file mode 100644
index 80c7a841d..000000000
--- a/DataFixtures/ORM/LoadAgents.php
+++ /dev/null
@@ -1,63 +0,0 @@
-
- */
-class LoadAgents extends AbstractFixture implements ContainerAwareInterface {
-
- /**
- *
- * @var ContainerInterface
- */
- private $container;
-
- const AGENT_STRING = 'agent';
-
- public function getOrder() {
- return 1000;
- }
-
- public function setContainer(ContainerInterface $container = null) {
- $this->container = $container;
- }
-
- public function load(ObjectManager $manager) {
-
- echo "creating agents... \n";
-
- $userManager = $this->container->get('fos_user.user_manager');
-
- for ($i = 0; $i < 10; $i++) {
- $username = 'agent'.$i;
- echo "creating agent $username (password $username) \n";
-
- $user = $userManager->createUser();
-
- $user->setUsername($username)
- ->setPassword($username)
- ->setName($username)
- ->setEmail($username.'@chill.be');
-
- $this->container->get('fos_user.user_manager')->updateUser($user, false);
-
- $this->addReference($username, $user);
- }
-
- $manager->flush();
- }
-
-
-
-
-}
diff --git a/DataFixtures/ORM/LoadCenters.php b/DataFixtures/ORM/LoadCenters.php
new file mode 100644
index 000000000..e1a7f0873
--- /dev/null
+++ b/DataFixtures/ORM/LoadCenters.php
@@ -0,0 +1,59 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\DataFixtures\ORM;
+
+use Doctrine\Common\DataFixtures\AbstractFixture;
+use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
+use Doctrine\Common\Persistence\ObjectManager;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\ContainerAwareInterface;
+use Chill\MainBundle\Entity\Center;
+
+/**
+ *
+ *
+ * @author Julien Fastré
+ */
+class LoadCenters extends AbstractFixture implements OrderedFixtureInterface
+{
+ public function getOrder()
+ {
+ return 100;
+ }
+
+ public function load(ObjectManager $manager)
+ {
+ $centerA = new Center();
+ $centerA->setName('Center A');
+
+ $manager->persist($centerA);
+ $this->addReference('centerA', $centerA);
+
+ $centerB = new Center();
+ $centerB->setName('center B');
+
+ $manager->persist($centerB);
+ $this->addReference('centerB', $centerB);
+
+ $manager->flush();
+
+ }
+}
diff --git a/DataFixtures/ORM/LoadRoleScopes.php b/DataFixtures/ORM/LoadRoleScopes.php
new file mode 100644
index 000000000..a6330bcb9
--- /dev/null
+++ b/DataFixtures/ORM/LoadRoleScopes.php
@@ -0,0 +1,79 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\DataFixtures\ORM;
+
+use Doctrine\Common\DataFixtures\AbstractFixture;
+use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
+use Doctrine\Common\Persistence\ObjectManager;
+use Chill\MainBundle\Entity\RoleScope;
+use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
+
+/**
+ *
+ *
+ * @author Julien Fastré
+ */
+class LoadRoleScopes extends AbstractFixture implements OrderedFixtureInterface
+{
+ public function getOrder()
+ {
+ return 300;
+ }
+
+ public static $permissions = array(
+ 'CHILL_FOO_SEE' => array(
+ 'names' => array(
+ 'fr' => 'voir foo',
+ 'en' => 'see foo',
+ 'nl' => 'zie foo'
+ )
+ ),
+ 'CHILL_FOO_EDIT' => array(
+ 'names' => array(
+ 'fr' => 'modifier foo',
+ 'en' => 'edit foo',
+ 'nl' => 'editie foo'
+ )
+ )
+ );
+
+ public static $references = array();
+
+ public function load(ObjectManager $manager)
+ {
+ foreach (static::$permissions as $key => $permission) {
+ foreach(LoadScopes::$references as $scopeReference) {
+ $roleScope = new RoleScope();
+ $roleScope->setRole($key)
+ ->setScope($this->getReference($scopeReference))
+ ;
+ $reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference)->getName()['en'];
+ var_dump($reference);
+ $this->addReference($reference, $roleScope);
+ $manager->persist($roleScope);
+ static::$references[] = $reference;
+ }
+ }
+
+ $manager->flush();
+ }
+
+}
diff --git a/DataFixtures/ORM/LoadScopes.php b/DataFixtures/ORM/LoadScopes.php
new file mode 100644
index 000000000..d3a7f16fd
--- /dev/null
+++ b/DataFixtures/ORM/LoadScopes.php
@@ -0,0 +1,82 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\DataFixtures\ORM;
+
+use Doctrine\Common\DataFixtures\AbstractFixture;
+use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
+use Doctrine\Common\Persistence\ObjectManager;
+
+/**
+ * Create scopes
+ *
+ * @author Julien Fastré
+ */
+class LoadScopes extends AbstractFixture implements OrderedFixtureInterface
+{
+ public function getOrder()
+ {
+ return 200;
+ }
+
+ public $scopes = array(
+ array(
+ 'names' => array(
+ 'fr' => 'tous',
+ 'en' => 'all',
+ 'nl' => 'algemeen'
+ ),
+ ),
+ array(
+ 'names' => array(
+ 'fr' => 'social',
+ 'en' => 'social',
+ 'nl' => 'sociaal'
+ )
+ ),
+ array(
+ 'names' => array(
+ 'fr' => 'administratif',
+ 'en' => 'administrative',
+ 'nl' => 'administratief'
+ )
+ )
+ );
+
+ public static $references = array();
+
+ public function load(ObjectManager $manager)
+ {
+
+ $scopesReferences = array();
+
+ foreach ($this->scopes as $new) {
+ $scope = new \Chill\MainBundle\Entity\Scope();
+ $scope->setName($new['names']);
+
+ $manager->persist($scope);
+ $reference = 'scope_'.$new['names']['en'];
+ $this->addReference($reference, $scope);
+ static::$references[] = $reference;
+ }
+
+ $manager->flush();
+ }
+}
diff --git a/DataFixtures/ORM/LoadUsers.php b/DataFixtures/ORM/LoadUsers.php
new file mode 100644
index 000000000..222b8d03d
--- /dev/null
+++ b/DataFixtures/ORM/LoadUsers.php
@@ -0,0 +1,40 @@
+
+ */
+class LoadUsers extends AbstractFixture implements ContainerAwareInterface
+{
+
+ /**
+ *
+ * @var ContainerInterface
+ */
+ private $container;
+
+ public function getOrder()
+ {
+ return 1000;
+ }
+
+ public function setContainer(ContainerInterface $container = null)
+ {
+ $this->container = $container;
+ }
+
+ public function load(ObjectManager $manager)
+ {
+
+ }
+
+}
diff --git a/Entity/Center.php b/Entity/Center.php
new file mode 100644
index 000000000..75edd18c4
--- /dev/null
+++ b/Entity/Center.php
@@ -0,0 +1,59 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\Entity;
+
+/**
+ *
+ *
+ * @author Julien Fastré
+ */
+class Center
+{
+ /**
+ *
+ * @var string
+ */
+ private $name;
+
+ /**
+ *
+ * @var int
+ */
+ private $id;
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+
+}
diff --git a/Entity/PermissionGroup.php b/Entity/PermissionGroup.php
new file mode 100644
index 000000000..cf2b76b05
--- /dev/null
+++ b/Entity/PermissionGroup.php
@@ -0,0 +1,84 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\Entity;
+
+use Chill\MainBundle\Entity\RoleScope;
+
+
+
+/**
+ *
+ *
+ * @author Julien Fastré
+ */
+class PermissionGroup
+{
+ /**
+ *
+ * @var int
+ */
+ private $id;
+
+ /**
+ *
+ * @var array
+ */
+ private $name;
+
+ /**
+ *
+ * @var \Doctrine\Common\Collections\Collection
+ */
+ private $roleScopes;
+
+ public function __construct()
+ {
+ $this->roleScopes = new \Doctrine\Common\Collections\ArrayCollection();
+ }
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function getRoleScopes()
+ {
+ return $this->roleScopes;
+ }
+
+ public function setName(array $name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ public function addRoleScope(RoleScope $roleScope)
+ {
+ $this->roleScopes->add($roleScope);
+ }
+
+
+}
diff --git a/Entity/RoleScope.php b/Entity/RoleScope.php
new file mode 100644
index 000000000..8d85ff4a9
--- /dev/null
+++ b/Entity/RoleScope.php
@@ -0,0 +1,94 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\Entity;
+
+/**
+ *
+ *
+ * @author Julien Fastré
+ */
+class RoleScope
+{
+ /**
+ *
+ * @var int
+ */
+ private $id;
+
+ /**
+ *
+ * @var string
+ */
+ private $role;
+
+ /**
+ *
+ * @var Scope
+ */
+ private $scope;
+
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ *
+ * @return string
+ */
+ public function getRole()
+ {
+ return $this->role;
+ }
+
+ /**
+ *
+ * @return Scope
+ */
+ public function getScope()
+ {
+ return $this->scope;
+ }
+
+ /**
+ *
+ * @param type $role
+ * @return \Chill\MainBundle\Entity\RoleScope
+ */
+ public function setRole($role)
+ {
+ $this->role = $role;
+ return $this;
+ }
+
+ /**
+ *
+ * @param \Chill\MainBundle\Entity\Scope $scope
+ * @return \Chill\MainBundle\Entity\RoleScope
+ */
+ public function setScope(Scope $scope)
+ {
+ $this->scope = $scope;
+ return $this;
+ }
+
+
+}
diff --git a/Entity/Scope.php b/Entity/Scope.php
new file mode 100644
index 000000000..4a55d3c26
--- /dev/null
+++ b/Entity/Scope.php
@@ -0,0 +1,93 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+namespace Chill\MainBundle\Entity;
+
+use Chill\MainBundle\Entity\RoleScope;
+
+/**
+ *
+ *
+ * @author Julien Fastré
+ */
+class Scope
+{
+ /**
+ *
+ * @var int
+ */
+ private $id;
+
+ /**
+ * translatable names
+ *
+ * @var array
+ */
+ private $name = array();
+
+ /**
+ *
+ * @var \Doctrine\Common\Collections\Collection
+ */
+ private $roleScopes;
+
+ public function __construct()
+ {
+ $this->roleScopes = new \Doctrine\Common\Collections\ArrayCollection();
+ }
+
+ /**
+ *
+ * @return int
+ */
+ public function getId()
+ {
+ return $this->id;
+ }
+
+ /**
+ *
+ * @return array
+ */
+ public function getName()
+ {
+ return $this->name;
+ }
+
+ public function setName($name)
+ {
+ $this->name = $name;
+ return $this;
+ }
+
+ /**
+ *
+ * @return \Doctrine\Common\Collections\Collection
+ */
+ public function getRoleScopes()
+ {
+ return $this->roleScopes;
+ }
+
+ public function addRoleScope(RoleScope $roleScope)
+ {
+ $this->roleScopes->add($roleScope);
+ }
+}
diff --git a/Entity/User.php b/Entity/User.php
index 16c09063b..1eeac1060 100644
--- a/Entity/User.php
+++ b/Entity/User.php
@@ -7,7 +7,7 @@ use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
- * Agent
+ * User
*/
class User implements UserInterface {
diff --git a/Resources/config/doctrine/Center.orm.yml b/Resources/config/doctrine/Center.orm.yml
index 16856e519..491495faf 100644
--- a/Resources/config/doctrine/Center.orm.yml
+++ b/Resources/config/doctrine/Center.orm.yml
@@ -9,4 +9,5 @@ Chill\MainBundle\Entity\Center:
strategy: AUTO
fields:
name:
- type: json_array
\ No newline at end of file
+ type: string
+ length: 255
\ No newline at end of file
diff --git a/Resources/config/doctrine/PermissionGroup.orm.yml b/Resources/config/doctrine/PermissionGroup.orm.yml
new file mode 100644
index 000000000..f7c7de5ec
--- /dev/null
+++ b/Resources/config/doctrine/PermissionGroup.orm.yml
@@ -0,0 +1,16 @@
+Chill\MainBundle\Entity\PermissionGroup:
+ type: entity
+ table: permission_groups
+ id:
+ id:
+ type: integer
+ id: true
+ generator:
+ strategy: AUTO
+ fields:
+ name:
+ type: json_array
+ manyToMany:
+ roleScopes:
+ targetEntity: Chill\MainBundle\Entity\RoleScope
+
\ No newline at end of file
diff --git a/Resources/config/doctrine/Scope.orm.yml b/Resources/config/doctrine/Scope.orm.yml
index a79ab3d29..188d8c307 100644
--- a/Resources/config/doctrine/Scope.orm.yml
+++ b/Resources/config/doctrine/Scope.orm.yml
@@ -10,7 +10,7 @@ Chill\MainBundle\Entity\Scope:
fields:
name:
type: json_array
- manyToOne:
+ oneToMany:
roleScopes:
targetEntity: Chill\MainBundle\Entity\RoleScope
- inversedBy: scope
\ No newline at end of file
+ mappedBy: scope
\ No newline at end of file
diff --git a/composer.json b/composer.json
index c09d49c25..7aa6cfe73 100644
--- a/composer.json
+++ b/composer.json
@@ -28,6 +28,7 @@
"doctrine/doctrine-bundle": "~1.2@dev"
},
"require-dev": {
- "symfony/dom-crawler": "2.5"
+ "symfony/dom-crawler": "2.5",
+ "doctrine/doctrine-fixtures-bundle": "~2.2"
}
}