Skip to content

Commit

Permalink
renamed AclCore as Existentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Emre Sokullu committed May 3, 2017
1 parent 38d9f7a commit 119b2f4
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/Pho/Framework/Actor.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Actor extends \Pho\Lib\Graph\Node implements ParticleInterface {

public function __construct(ContextInterface $context) {
parent::__construct($context);
$this->acl = new AclCore($this, $this, $context);
$this->existentials = new Existentials($this, $this, $context);
$this->enter($context);
$this->setupEdges();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,19 @@
namespace Pho\Framework;

/**
* AclCore (Access Control Lists Core)
* Existentials
*
* Access Control List is a gateway authority between graph nodes.
* Pho Framework introduces the core of this authority as an
* abstract implementation and expects the higher level packages
* to extend itself. The core is by default immutable; meaning
* the two values (creator and context) cannot be altered.
* Existentials is an immutable list of properties that constitute
* the basis of the node.
*
* Existentials may be used by Access Control List(ACL) as a gateway
* authority between graph nodes.The actual ACL is expected to be
* implemented separately in higher levels (optional) and the
* Existentials would behave as its core.
*
* @author Emre Sokullu <[email protected]>
*/
class AclCore {
class Existentials {

/**
* Who created this node. Must point to an Actor.
Expand Down
2 changes: 1 addition & 1 deletion src/Pho/Framework/Frame.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Frame extends \Pho\Lib\Graph\SubGraph implements ParticleInterface, Contex

public function __construct(Actor $creator, ContextInterface $context) {
parent::__construct($context);
$this->acl = new AclCore($this, $creator, $context);
$this->existentials = new Existentials($this, $creator, $context);
$this->setupEdges();
}

Expand Down
2 changes: 1 addition & 1 deletion src/Pho/Framework/Object.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Object extends \Pho\Lib\Graph\Node implements ParticleInterface {

public function __construct(Actor $creator, ContextInterface $context) {
parent::__construct($context);
$this->acl = new AclCore($this, $creator, $context);
$this->existentials = new Existentials($this, $creator, $context);
$this->setupEdges();
}

Expand Down
13 changes: 10 additions & 3 deletions src/Pho/Framework/ParticleInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,17 @@
interface ParticleInterface {

/**
* Retrieves the object's ACL
* Retrieves the object's existential properties
*
* @return AclCore
* Existential properties are:
* * The node itself ($this)
* * Its context
* * Its creator
*
* These properties can never be altered.
*
* @return Existentials
*/
public function acl(): AclCore;
public function existentials(): Existentials;

}
13 changes: 8 additions & 5 deletions src/Pho/Framework/ParticleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,12 @@ trait ParticleTrait {

/**
* Access Control List object
*
* Null since it is not implemented at this level.
*
* @var Acl
* @var null
*/
protected $acl;
// protected $acl = null;

/**
* Trait constructor.
Expand Down Expand Up @@ -272,7 +274,8 @@ protected function _callGetter(string $name, array $args): array
public function toArray(): array
{
$array = parent::toArray();
$array["acl"] = $this->acl->toArray();
$array["acl"] = [];
$array["acl"]["core"] = $this->existentials->toArray();
return $array;
}

Expand All @@ -281,9 +284,9 @@ public function toArray(): array
*
* @return AclCore
*/
public function acl(): AclCore
public function existentials(): Existentials
{
return $this->acl;
return $this->existentials;
}

}
22 changes: 13 additions & 9 deletions tests/Pho/Framework/SimpleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,12 @@ public function testActorToArray() {
$this->assertCount(1, $actor->toArray()["attributes"]);
$this->assertArrayHasKey("edge_list", $array);
$this->assertArrayHasKey("acl", $array);
$this->assertCount(3, $array["acl"]);
$this->assertArrayHasKey("context", $array["acl"]);
$this->assertArrayHasKey("creator", $array["acl"]);
$this->assertArrayHasKey("node", $array["acl"]);
$this->assertCount(1, $array["acl"]);
$this->assertArrayHasKey("core", $array["acl"]);
$this->assertCount(3, $array["acl"]["core"]);
$this->assertArrayHasKey("context", $array["acl"]["core"]);
$this->assertArrayHasKey("creator", $array["acl"]["core"]);
$this->assertArrayHasKey("node", $array["acl"]["core"]);
}

public function testFrameToArray() {
Expand All @@ -123,11 +125,13 @@ public function testFrameToArray() {
$this->assertCount(1, $actor->toArray()["attributes"]);
$this->assertArrayHasKey("edge_list", $array);
$this->assertArrayHasKey("acl", $array);
$this->assertCount(3, $array["acl"]);
$this->assertArrayHasKey("context", $array["acl"]);
$this->assertArrayHasKey("creator", $array["acl"]);
$this->assertArrayHasKey("node", $array["acl"]);
$this->assertEquals($actor->id(), $array["acl"]["creator"]);
$this->assertCount(1, $array["acl"]);
$this->assertArrayHasKey("core", $array["acl"]);
$this->assertCount(3, $array["acl"]["core"]);
$this->assertArrayHasKey("context", $array["acl"]["core"]);
$this->assertArrayHasKey("creator", $array["acl"]["core"]);
$this->assertArrayHasKey("node", $array["acl"]["core"]);
$this->assertEquals($actor->id(), $array["acl"]["core"]["creator"]);
}

public function testContextInterface() {
Expand Down

0 comments on commit 119b2f4

Please sign in to comment.