diff --git a/src/Pho/Framework/AclCore.php b/src/Pho/Framework/AclCore.php index a4a08f8..71179ac 100644 --- a/src/Pho/Framework/AclCore.php +++ b/src/Pho/Framework/AclCore.php @@ -38,13 +38,21 @@ class AclCore { */ protected $context; + /** + * A reference to the node itself + * + * @var ParticleInterface + */ + protected $node; + /** * Constructor. * * @param Actor $creator The creator of this node. * @param ContextInterface $context The context in which this node is created and will exist */ - public function __construct(Actor $creator, ContextInterface $context) { + public function __construct(ParticleInterface $node, Actor $creator, ContextInterface $context) { + $this->node = $node; $this->creator = $creator; $this->context = $context; } @@ -69,6 +77,16 @@ public function context(): ContextInterface return $this->context; } + /** + * Getter for the node object. + * + * @return ParticleInterface + */ + public function node(): ParticleInterface + { + return $this->node; + } + /** * Converts the object into a portable PHP array * @@ -80,6 +98,7 @@ public function toArray(): array { //eval(\Psy\sh()); return [ + "node" => (string) $this->node->id(), "creator" => (string) $this->creator->id(), "context" => ($this->context instanceof Graph) ? Graph::class : (string) $this->context->id() ]; diff --git a/src/Pho/Framework/Actor.php b/src/Pho/Framework/Actor.php index ac91d29..f87eb7d 100644 --- a/src/Pho/Framework/Actor.php +++ b/src/Pho/Framework/Actor.php @@ -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, $context); + $this->acl = new AclCore($this, $this, $context); $this->enter($context); $this->setupEdges(); } diff --git a/src/Pho/Framework/Frame.php b/src/Pho/Framework/Frame.php index f0d0766..9937361 100644 --- a/src/Pho/Framework/Frame.php +++ b/src/Pho/Framework/Frame.php @@ -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($creator, $context); + $this->acl = new AclCore($this, $creator, $context); $this->setupEdges(); } diff --git a/src/Pho/Framework/Object.php b/src/Pho/Framework/Object.php index 73cd832..761826a 100644 --- a/src/Pho/Framework/Object.php +++ b/src/Pho/Framework/Object.php @@ -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($creator, $context); + $this->acl = new AclCore($this, $creator, $context); $this->setupEdges(); } diff --git a/tests/Pho/Framework/SimpleTest.php b/tests/Pho/Framework/SimpleTest.php index 0b5cc65..167672d 100644 --- a/tests/Pho/Framework/SimpleTest.php +++ b/tests/Pho/Framework/SimpleTest.php @@ -104,9 +104,10 @@ public function testActorToArray() { $this->assertCount(1, $actor->toArray()["attributes"]); $this->assertArrayHasKey("edge_list", $array); $this->assertArrayHasKey("acl", $array); - $this->assertCount(2, $array["acl"]); + $this->assertCount(3, $array["acl"]); $this->assertArrayHasKey("context", $array["acl"]); $this->assertArrayHasKey("creator", $array["acl"]); + $this->assertArrayHasKey("node", $array["acl"]); } public function testFrameToArray() { @@ -122,9 +123,10 @@ public function testFrameToArray() { $this->assertCount(1, $actor->toArray()["attributes"]); $this->assertArrayHasKey("edge_list", $array); $this->assertArrayHasKey("acl", $array); - $this->assertCount(2, $array["acl"]); + $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"]); }