Example #1
0
 public function testPath()
 {
     $fn1 = function () {
         return "actual";
     };
     $fn2 = function () {
         return "setup";
     };
     $injectionParams = new InjectionParams();
     $exec = new Executable($fn1, $injectionParams, $fn2);
     $exec->getInjectionParams();
     $callable = $exec->getCallable();
     $setupCallable = $exec->getSetupCallable();
     $this->assertEquals("setup", $setupCallable());
     $this->assertEquals("actual", $callable());
 }
Example #2
0
 /**
  * @param Executable $tier
  * @param Injector $injector
  * @return mixed
  */
 public static function executeExecutable(Executable $tier, Injector $injector)
 {
     // Setup the information created by the previous Tier.
     if (($injectionParams = $tier->getInjectionParams()) !== null) {
         $injectionParams->addToInjector($injector);
     }
     // If the next Tier has a setup function, call it.
     $setupCallable = $tier->getSetupCallable();
     if ($setupCallable !== null) {
         $injector->execute($setupCallable);
     }
     // Call this Tier's callable.
     return $injector->execute($tier->getCallable());
 }