mirror of
https://github.com/kevinveenbirkenbach/infinito.git
synced 2025-01-09 14:07:25 +01:00
Implemented optimistic lock draft
This commit is contained in:
parent
8de52474a5
commit
e066e8b362
@ -1,18 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Attribut\IdAttribut;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
use App\Entity\Attribut\VersionAttribut;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
abstract class AbstractEntity implements EntityInterface
|
||||
{
|
||||
use IdAttribut;
|
||||
use IdAttribut, VersionAttribut;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ORM\Id()
|
||||
* @ORM\GeneratedValue
|
||||
* @ORM\Column(type="integer")(strategy="AUTO")
|
||||
@ -21,8 +23,15 @@ abstract class AbstractEntity implements EntityInterface
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version @ORM\Column(type="integer")
|
||||
* @var int
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
//$this->id = 0;
|
||||
// $this->id = 0;
|
||||
}
|
||||
}
|
||||
|
25
application/src/Entity/Attribut/VersionAttribut.php
Normal file
25
application/src/Entity/Attribut/VersionAttribut.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
trait VersionAttribut
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
public function setVersion(int $version):void{
|
||||
$this->version = $version;
|
||||
}
|
||||
|
||||
public function getVersion():int{
|
||||
return $this->version;
|
||||
}
|
||||
}
|
||||
|
24
application/src/Entity/Attribut/VersionAttributInterface.php
Normal file
24
application/src/Entity/Attribut/VersionAttributInterface.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
namespace App\Entity\Attribut;
|
||||
|
||||
/**
|
||||
* Entities which implement this interface can lock stuff on an optimistic base.
|
||||
* @see https://www.doctrine-project.org/projects/doctrine-orm/en/2.6/reference/transactions-and-concurrency.html
|
||||
* @see https://en.wikipedia.org/wiki/Optimistic_concurrency_control
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
interface VersionAttributInterface
|
||||
{
|
||||
/**
|
||||
* Returns the revision version of the entity
|
||||
* @return int
|
||||
*/
|
||||
public function getVersion():int;
|
||||
|
||||
/**
|
||||
* Sets the revision version of the entity
|
||||
* @param int $version
|
||||
*/
|
||||
public function setVersion(int $version):void;
|
||||
}
|
||||
|
@ -1,12 +1,15 @@
|
||||
<?php
|
||||
namespace App\Entity;
|
||||
|
||||
use App\Entity\Attribut\VersionAttributInterface;
|
||||
use App\Entity\Attribut\IdAttributInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface EntityInterface
|
||||
interface EntityInterface extends VersionAttributInterface, IdAttributInterface
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ use App\Entity\Attribut\IdAttribut;
|
||||
use App\Creator\Modificator\Entity\LawModificator;
|
||||
use App\Entity\Source\UserSourceInterface;
|
||||
use App\Entity\Source\UserSource;
|
||||
use App\Entity\Attribut\VersionAttribut;
|
||||
|
||||
/**
|
||||
* @author kevinfrantz
|
||||
@ -17,7 +18,7 @@ use App\Entity\Source\UserSource;
|
||||
*/
|
||||
class User extends BaseUser implements UserInterface
|
||||
{
|
||||
use SourceAttribut,IdAttribut;
|
||||
use SourceAttribut,IdAttribut, VersionAttribut;
|
||||
|
||||
/**
|
||||
* @var UserSourceInterface
|
||||
@ -38,6 +39,13 @@ class User extends BaseUser implements UserInterface
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @version @ORM\Column(type="integer")
|
||||
* @var int
|
||||
*/
|
||||
protected $version;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
@ -3,13 +3,13 @@ namespace App\Entity;
|
||||
|
||||
use FOS\UserBundle\Model\UserInterface as FOSUserInterface;
|
||||
use App\Entity\Attribut\SourceAttributInterface;
|
||||
use App\Entity\Attribut\VersionAttributInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*
|
||||
*/
|
||||
interface UserInterface extends FOSUserInterface, SourceAttributInterface
|
||||
interface UserInterface extends FOSUserInterface, SourceAttributInterface, VersionAttributInterface
|
||||
{
|
||||
|
||||
}
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
namespace App\Structur\Facade\Security\Source;
|
||||
|
||||
use App\Entity\Source\NameSourceInterface;
|
||||
@ -9,11 +8,14 @@ use App\DBAL\Types\RightType;
|
||||
use App\DBAL\Types\LayerType;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author kevinfrantz
|
||||
*/
|
||||
class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var UserSourceInterface
|
||||
*/
|
||||
protected $source;
|
||||
@ -26,7 +28,7 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
|
||||
public function getNameSource(): NameSourceInterface
|
||||
{
|
||||
if ($this->isNameSourceGranted(RightType::READ, LayerType::SOURCE)) {
|
||||
//FILL! :)
|
||||
// FILL! :)
|
||||
}
|
||||
}
|
||||
|
||||
@ -38,10 +40,26 @@ class UserSourceFacade extends AbstractSourceFacade implements UserSourceInterfa
|
||||
|
||||
return $this->isGranted($right, $layer) && $law->isGranted($userSourceNode, $layer, $right);
|
||||
}
|
||||
|
||||
public function getUser(): UserInterface
|
||||
{}
|
||||
|
||||
public function setUser(UserInterface $user): void
|
||||
{}
|
||||
|
||||
public function getVersion(): int
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @todo Implement
|
||||
*/
|
||||
}
|
||||
|
||||
public function setVersion(int $version): void
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @todo Implement
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user