implements user-scope-role-scope first work

This commit is contained in:
Julien Fastré 2014-10-24 12:19:30 +02:00
parent d9aa417e3c
commit 445daecfc0
11 changed files with 197 additions and 70 deletions

1
.gitignore vendored
View File

@ -14,6 +14,7 @@ web/bundles/*
# Configuration files # Configuration files
app/config/parameters.ini app/config/parameters.ini
app/config/parameters.yml app/config/parameters.yml
Tests/Fixtures/App/config/parameters.yml
#composer #composer
composer.lock composer.lock

View File

@ -1,64 +0,0 @@
<?php
namespace Chill\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Agent
*/
class Agent {
/**
* @var integer
*/
protected $id;
/**
* @var string
*/
private $name;
public function __construct() {
parent::__construct();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->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();
}
}

108
Entity/User.php Normal file
View File

@ -0,0 +1,108 @@
<?php
namespace Chill\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
/**
* Agent
*/
class User implements UserInterface {
/**
* @var integer
*/
protected $id;
/**
* @var string
*/
private $username;
private $password;
private $salt;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->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;
}
}

View File

@ -1,6 +1,6 @@
Chill\MainBundle\Entity\Agent: Chill\MainBundle\Entity\Center:
type: entity type: entity
table: agents table: centers
id: id:
id: id:
type: integer type: integer
@ -9,6 +9,4 @@ Chill\MainBundle\Entity\Agent:
strategy: AUTO strategy: AUTO
fields: fields:
name: name:
type: string type: json_array
length: 80

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -13,6 +13,7 @@ class AppKernel extends Kernel
new Symfony\Bundle\SecurityBundle\SecurityBundle(), new Symfony\Bundle\SecurityBundle\SecurityBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(), new Symfony\Bundle\TwigBundle\TwigBundle(),
new \Symfony\Bundle\AsseticBundle\AsseticBundle(), new \Symfony\Bundle\AsseticBundle\AsseticBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
); );
} }

View File

@ -1,3 +1,6 @@
imports:
- { resource: parameters.yml }
framework: framework:
secret: Not very secret secret: Not very secret
router: { resource: "%kernel.root_dir%/config/routing.yml" } router: { resource: "%kernel.root_dir%/config/routing.yml" }
@ -9,3 +12,14 @@ framework:
profiler: { only_exceptions: false } profiler: { only_exceptions: false }
templating: templating:
engines: ['twig'] 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

View File

@ -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

View File

@ -21,7 +21,11 @@
"symfony/monolog-bundle": "~2.4", "symfony/monolog-bundle": "~2.4",
"symfony/framework-bundle": "2.5.*", "symfony/framework-bundle": "2.5.*",
"symfony/yaml": "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": { "require-dev": {
"symfony/dom-crawler": "2.5" "symfony/dom-crawler": "2.5"