Beispiel #1
0
 public function postFoo(IEvent $e)
 {
     $this->postFooInvoked = true;
     $e->stopPropagation();
 }
Beispiel #2
0
 /**
  * Handles the exception() dynamic call.
  *
  * @throws \RuntimeException With message passed to exception()
  *
  * @param \BLW\Type\IEvent $Event
  *            Event triggered by exception().
  * @return void
  */
 public function doException(IEvent $Event)
 {
     // Validate Arguments
     if (isset($Event->Arguments) ? count($Event->Arguments) > 0 : false) {
         // Get arguments
         list($Message) = $Event->Arguments;
         // Stop further event triggers
         $Event->stopPropagation();
         // Is $Message a string?
         if (is_string($Message) ?: is_callable(array($Message, '__toString'))) {
             // Does logger exist? Log
             if ($this->logger instanceof LoggerInterface) {
                 $this->logger->critical($Message);
             }
             // Exception
             throw new RuntimeException($Message, E_USER_ERROR);
         }
     }
 }
Beispiel #3
0
 /**
  * Handles Browser.Page.Download Event
  *
  * <h4>Note</h4>
  *
  * <p>This functions disables the browsers own handling
  * of this event by stopping propagation of event passed.</p>
  *
  * <hr>
  *
  * @param \BLW\Type\IEvent $Event
  *            Event object
  */
 public function doPageDownload(IEvent $Event)
 {
     // Validate $Request
     if (!isset($Event->Request) ?: !$Event->Request instanceof IRequest) {
         // Missing request
         $Event->Subject->exception('IBrowser::Event(Page.Download) Invalid or missing IEvent::$Request');
     } else {
         // Navigate to requested page
         $Browser = $Event->Subject;
         $Request = $Event->Request;
         $Response = $this->send($Request);
         // Is response known
         if ($Response->isValidCode($Response->Status)) {
             $Browser->debug(sprintf('Response for (%s) answered with code (%d).', $Request->URI, $Response->Status));
             // Create page
             $Page = $Browser->createPage($Request, $Response);
             // Unkown response
         } else {
             // @codeCoverageIgnoreStart
             $Browser->warning(sprintf('Invalid response code (%s) for url (%s).', $Response->Status, $Request->URI));
             // Create page
             $Page = $Browser->createUnkownPage();
             // @codeCoverageIgnoreEnd
         }
         // Update page
         $Browser->setPage($Page);
         // Update History
         $Browser->addHistory($Page);
         // Browser.Page.Load Event
         $Browser->_do('Page.Ready', new Event($Browser));
         // Stop native handling of Browser.Page.Download event
         $Event->stopPropagation();
     }
 }