-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Emre Sokullu
committed
May 1, 2017
1 parent
0c78e05
commit 75e309d
Showing
8 changed files
with
144 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,6 @@ | |
|
||
namespace Pho\Framework; | ||
|
||
use Pho\Lib\Graph; | ||
|
||
/** | ||
* The Actor Particle | ||
* | ||
|
@@ -25,10 +23,17 @@ | |
* | ||
* @author Emre Sokullu <[email protected]> | ||
*/ | ||
class Actor extends Graph\Node implements ParticleInterface { | ||
class Actor extends \Pho\Lib\Graph\Node implements ParticleInterface { | ||
|
||
use ParticleTrait; | ||
|
||
/** | ||
* Current context that this actor is in. | ||
* | ||
* @var ContextInterface | ||
*/ | ||
protected $current_context; | ||
|
||
/** | ||
* Incoming Edges | ||
* | ||
|
@@ -38,10 +43,73 @@ class Actor extends Graph\Node implements ParticleInterface { | |
*/ | ||
const EDGES_IN = [ActorOut\Reads::class, ActorOut\Subscribes::class, ObjectOut\Transmits::class]; | ||
|
||
public function __construct(Graph\GraphInterface $context) { | ||
public function __construct(ContextInterface $context) { | ||
parent::__construct($context); | ||
$this->acl = new AclCore($this, $context); | ||
$this->enter($context); | ||
$this->setupEdges(); | ||
} | ||
|
||
/** | ||
* Puts the Actor into a context | ||
* | ||
* This is importnat because All particles formed by the Actor | ||
* will be associated with their current context. | ||
* | ||
* @see Actor:cwd for UNIX-style alias. | ||
* | ||
* @param ContextInterface $context | ||
* | ||
* @return void | ||
*/ | ||
public function enter(ContextInterface $context): void | ||
{ | ||
$this->current_context = $context; | ||
} | ||
|
||
/** | ||
* Alias to enter() | ||
* | ||
* This is a UNIX alias to the ```enter()``` method. | ||
* | ||
* @see Actor::enter | ||
* | ||
* @param ContextInterface $context | ||
* | ||
* @return void | ||
*/ | ||
public function cwd(ContextInterface $context): void | ||
{ | ||
$this->enter($context); | ||
} | ||
|
||
/** | ||
* Returns which context the Actor is currently operating | ||
* | ||
* This is importnat because All particles formed by the Actor | ||
* will be associated with their current context. | ||
* | ||
* @see Actor:pwd for UNIX-style alias. | ||
* | ||
* @return ContextInterface Current context where the Actor is operating. | ||
*/ | ||
public function where(): ContextInterface | ||
{ | ||
return $this->current_context; | ||
} | ||
|
||
/** | ||
* Alias to where() | ||
* | ||
* This is a UNIX alias to the ```where()``` method. | ||
* | ||
* @see Actor::where | ||
* | ||
* @return ContextInterface Current context where the Actor is operating. | ||
*/ | ||
public function pwd(): ContextInterface | ||
{ | ||
return $this->where(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Pho package. | ||
* | ||
* (c) Emre Sokullu <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Pho\Framework; | ||
|
||
/** | ||
* ContextInterface | ||
* | ||
* This class is a shell to Pho\Lib\Graph's GraphInterface implementation. | ||
* It is used by all Framework particles and graphs that can be used | ||
* as a context object in higher level packages. | ||
* | ||
* @author Emre Sokullu <[email protected]> | ||
*/ | ||
interface ContextInterface extends \Pho\Lib\Graph\GraphInterface { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,6 @@ | |
|
||
namespace Pho\Framework; | ||
|
||
use Pho\Lib\Graph; | ||
|
||
/** | ||
* The Frame Particle | ||
* | ||
|
@@ -24,14 +22,14 @@ | |
* any confusions with Pho\Lib\Graph's nomenclature, this class is called | ||
* Frame instead. | ||
* | ||
* In contrast to other (particles?), Frame doesn't contain edges but | ||
* its **"contains"** edge acts similarly to an edge. | ||
* In contrast to other particles, Frame doesn't contain edges but | ||
* its **"contains"** method acts similarly to an edge. | ||
* | ||
* | ||
* | ||
* @author Emre Sokullu <[email protected]> | ||
*/ | ||
class Frame extends Graph\SubGraph implements ParticleInterface { | ||
class Frame extends \Pho\Lib\Graph\SubGraph implements ParticleInterface, ContextInterface { | ||
|
||
use ParticleTrait; | ||
|
||
|
@@ -44,7 +42,7 @@ class Frame extends Graph\SubGraph implements ParticleInterface { | |
*/ | ||
const EDGES_IN = [ActorOut\Reads::class, ActorOut\Subscribes::class, ActorOut\Writes::class, ObjectOut\Transmits::class]; | ||
|
||
public function __construct(Actor $creator, Graph\GraphInterface $context) { | ||
public function __construct(Actor $creator, ContextInterface $context) { | ||
parent::__construct($context); | ||
$this->acl = new AclCore($creator, $context); | ||
$this->setupEdges(); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Pho package. | ||
* | ||
* (c) Emre Sokullu <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Pho\Framework; | ||
|
||
/** | ||
* The Graph | ||
* | ||
* This class is a shell to Pho\Lib\Graph's Graph implementation | ||
* and it implements ContextInterface to give higher-level | ||
* software access to use both Frame and Graph as context objects. | ||
* | ||
* @author Emre Sokullu <[email protected]> | ||
*/ | ||
class Graph extends \Pho\Lib\Graph\Graph implements ContextInterface { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters