Example #1
0
 /**
  * @param int $hour
  * @return void
  */
 public function setClock($hour)
 {
     $clockMessage = 'Now:';
     if ($hour < 10) {
         $clockMessage .= '0' . $hour . ':00';
     } else {
         $clockMessage .= $hour . ':00';
     }
     echo $clockMessage . $this->state . PHP_EOL;
     $this->state->doClock($this, $hour);
 }
 /**
  * Clean cache by tags
  *
  * @param  string[] $tags
  * @return void
  */
 private function cleanCacheByTags($tags)
 {
     if (empty($tags)) {
         return;
     }
     foreach ($this->cacheList as $cacheType) {
         if ($this->cacheState->isEnabled($cacheType)) {
             $this->cachePool->get($cacheType)->clean(\Zend_Cache::CLEANING_MODE_MATCHING_TAG, array_unique($tags));
         }
     }
 }
Example #3
0
 /**
  * Get array of all invalidated cache types
  *
  * @return array
  */
 public function getInvalidated()
 {
     $invalidatedTypes = [];
     $types = $this->_getInvalidatedTypes();
     if ($types) {
         $allTypes = $this->getTypes();
         foreach (array_keys($types) as $type) {
             if (isset($allTypes[$type]) && $this->_cacheState->isEnabled($type)) {
                 $invalidatedTypes[$type] = $allTypes[$type];
             }
         }
     }
     return $invalidatedTypes;
 }
Example #4
0
 public function testGetTimeout()
 {
     $date = new \DateTime();
     $event = $this->getMockBuilder('\\StateMachine\\EventInterface')->disableOriginalConstructor()->getMock();
     $event->expects($this->any())->method('getName')->willReturn(Process::ON_TIME_OUT);
     $event->expects($this->any())->method('timeoutAt')->willReturn($date);
     $this->state->expects($this->any())->method('__toString')->willReturn('stateName');
     $this->state->expects($this->any())->method('getName')->willReturn('stateName');
     $this->state->expects($this->any())->method('getEvent')->willReturn($event);
     $this->payload->expects($this->any())->method('getState')->willReturn('stateName');
     $this->payload->expects($this->any())->method('getIdentifier')->willReturn('identifier');
     $process = new Process('processName', '\\stdClass', 'stateName', [$this->state]);
     $timeout = $process->getTimeout($this->payload, $date);
     $this->assertInstanceOf('\\StateMachine\\PayloadTimeout', $timeout);
     $this->assertEquals('stateName', $timeout->getState());
     $this->assertEquals(Process::ON_TIME_OUT, $timeout->getEvent());
     $this->assertEquals('identifier', $timeout->getIdentifier());
     $this->assertEquals($date, $timeout->getExecutionDate());
 }
Example #5
0
 /**
  * If state identical with another
  *
  * @param StateInterface $comparedState
  * @return bool
  */
 public function isIdentical(StateInterface $comparedState)
 {
     return $this->getName() == $comparedState->getName() && $this->getType() == $comparedState->getType();
 }
Example #6
0
 /**
  * @param \Spryker\Zed\Oms\Business\Process\StateInterface $sourceState
  *
  * @return \Spryker\Zed\Oms\Business\Process\TransitionInterface[]
  */
 public function getTransitionsBySource(StateInterface $sourceState)
 {
     $transitions = [];
     foreach ($this->transitions as $transition) {
         if ($transition->getSource()->getName() === $sourceState->getName()) {
             $transitions[] = $transition;
         }
     }
     return $transitions;
 }