/** * @throws TierException */ public function executeInternal() { // Create and share these as they need to be the same // across the application $this->injector->share($this->injector); //yolo $this->initialInjectionParams->addToInjector($this->injector); foreach ($this->executableListByTier as $appStage => $tiersForStage) { foreach ($tiersForStage as $tier) { //Check we haven't got caught in a redirect loop $this->internalExecutions++; if ($this->internalExecutions > $this->maxInternalExecutions) { $message = "Too many tiers executed. You probably have a recursion error in your application."; throw new TierException($message); } /** @var $tier Executable */ if ($tier instanceof Executable) { $skipIfProduced = $tier->getSkipIfProduced(); if ($skipIfProduced && $this->hasExpectedProductBeenProduced($skipIfProduced) == true) { continue; } // Setup the information created by the previous Tier if ($injectionParams = $tier->getInjectionParams()) { $injectionParams->addToInjector($this->injector); } // If the next Tier has a setup function, call it $setupCallable = $tier->getSetupCallable(); if ($setupCallable) { $this->injector->execute($setupCallable); } // Call this Tier's callable $result = $this->injector->execute($tier->getCallable()); } else { $result = $this->injector->execute($tier); } // TODO - if we need to allow user handlers this is the place they would go $finished = $this->processResult($result); if ($finished == self::PROCESS_END_STAGE) { break; } if ($finished == self::PROCESS_END) { return; } } } throw new TierException("Processing did not result in a TierApp::PROCESS_END"); }
public function testDefineParam() { $injectorMock = Mockery::mock('Auryn\\Injector'); $injectorMock->shouldReceive('defineParam')->with('foo', 'bar')->once(); $params = new InjectionParams(); $params->defineParam('foo', 'bar'); $params->addToInjector($injectorMock); }
/** * @throws TierException */ public function executeInternal() { // Create and share these as they need to be the same // across the application $this->injector->share($this->injector); //yolo $this->initialInjectionParams->addToInjector($this->injector); foreach ($this->executableListByTier as $appStage => $tiersForStage) { foreach ($tiersForStage as $tier) { //Check we haven't got caught in a redirect loop $this->internalExecutions++; if ($this->internalExecutions > $this->maxInternalExecutions) { $message = "Too many tiers executed. You probably have a recursion error in your application."; throw new TierException($message); } /** @var $tier Executable */ if ($tier instanceof Executable) { //Some executables shouldn't be run if a certain product //has already been made. This allows very easy caching layers. $skipIfProduced = $tier->getSkipIfExpectedProductProduced(); if ($skipIfProduced !== null && $this->hasExpectedProductBeenProduced($skipIfProduced) === true) { continue; } $result = self::executeExecutable($tier, $this->injector); } else { $result = $this->injector->execute($tier); } $finished = $this->processResult($result, $tier); if ($finished === self::PROCESS_END_STAGE) { break; } if ($finished === self::PROCESS_END) { return; } } } if ($this->warnOnSilentProcessingEnd === true) { throw new TierException("Processing did not result in a TierApp::PROCESS_END"); } }