コード例 #1
0
ファイル: Subject.php プロジェクト: kornelek/lms
 /**
  * {@inheritDoc}
  */
 public function notifyObservers()
 {
     if ($this->updating) {
         throw SubjectException::alreadyUpdating();
     }
     $this->resetInterrupt();
     $this->updating = true;
     /** @var ObserverInterface $observer */
     foreach ($this->getObservers() as $observers) {
         foreach ($observers as $observer) {
             try {
                 $observer->receiveUpdate($this);
             } catch (Exception $exception) {
                 $this->updating = false;
                 throw $exception;
             }
             if ($this->reason) {
                 $this->updating = false;
                 throw $this->reason;
             }
         }
     }
     $this->updating = false;
 }
コード例 #2
0
ファイル: SubjectExceptionTest.php プロジェクト: kornelek/lms
 /**
  * Make sure that we get the message we are expecting.
  */
 public function testNotUpdating()
 {
     $this->assertEquals('There is no update in progress to interrupt.', SubjectException::notUpdating()->getMessage(), 'Make sure we get the right message.');
 }