Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
esokullu committed Jul 18, 2017
1 parent bb8edf8 commit f393709
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
27 changes: 23 additions & 4 deletions src/Pho/Framework/Loaders/OutgoingEdgeLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,30 @@ public static function pack(Framework\ParticleInterface $particle): AbstractLoad
foreach ($locator as $file) {
$filename = str_replace($edge_dir . DIRECTORY_SEPARATOR, '', $file->getRealPath());
foreach ($file->getClasses() as $class) {
self::registerOutgoingEdgeClass($obj->cargo, $class);
self::registerOutgoingEdgeClass($particle, $obj->cargo, $class);
}
}
return $obj;
}

/**
* Calculates how many arguments in constructor to skip
*
* Used with formative predicates.
* The default value is 2 for framework, 3 for microkernel.
*
* @param Framework\ParticleInterface $particle
*
* @return int
*/
protected static function getFormativeTrim(Framework\ParticleInterface $particle): int
{
$trim = 2;
if(defined(get_class($particle)."::FORMATIVE_TRIM_CUT"))
$trim = $particle::FORMATIVE_TRIM_CUT;
return $trim;
}

/**
* Registers an Edge Out class that meets the requirements.
*
Expand All @@ -73,11 +91,11 @@ public static function pack(Framework\ParticleInterface $particle): AbstractLoad
* @return void
*/
public static function registerOutgoingEdgeClass(
ParticleInterface $particle,
OutgoingEdgeCargo & $cargo,
string $class,
int $formative_trim = 2
string $class
): void
{
{
$reflector = new \ReflectionClass($class);
if(!$reflector->isSubclassOf(Framework\AbstractEdge::class)) {
return;
Expand Down Expand Up @@ -109,6 +127,7 @@ public static function registerOutgoingEdgeClass(
)
)->getParameters();
}
$formative_trim = self::getFormativeTrim($particle);
for($i=0;$i<$formative_trim;$i++) {
@array_shift($formable_params);
}
Expand Down
7 changes: 2 additions & 5 deletions src/Pho/Framework/ParticleTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,10 @@ public function getRegisteredIncomingEdges(): array
*/
public function registerOutgoingEdgeClass(string $class): void
{
$trim = 2;
if(defined("static::FORMATIVE_TRIM_CUT"))
$trim = static::FORMATIVE_TRIM_CUT;
Loaders\OutgoingEdgeLoader::registerOutgoingEdgeClass(
$this,
$this->handler->cargo_out,
$class,
$trim
$class
);
}

Expand Down

0 comments on commit f393709

Please sign in to comment.