/**
  * @covers Brickoo\Component\Routing\Route\Collector\MessageRouteCollector::collect
  * @covers Brickoo\Component\Routing\Route\Collector\MessageRouteCollector::extractRouteCollections
  */
 public function testRouteCollectorReturnsCollection()
 {
     $routeCollection = new RouteCollection();
     $messageDispatcher = new MessageDispatcher(new ListenerCollection(), new MessageRecursionDepthList());
     $messageDispatcher->attach(new RouteCollectorListenerFixture($routeCollection));
     $messageRouteCollector = new MessageRouteCollector($messageDispatcher);
     $this->assertInstanceOf("Brickoo\\Component\\Common\\Collection", $collection = $messageRouteCollector->collect());
     $this->assertSame($routeCollection, $collection->shift());
 }
Esempio n. 2
0
 /**
  * Handles the error reported by the user or system.
  * Converts the error to an exception if configured.
  * @param integer $errorCode the error code number
  * @param string $errorMessage the error message
  * @param string $errorFile the error file name
  * @param integer $errorLine the error line number
  * @throws \Brickoo\Component\Error\Exception\ErrorOccurredException
  * @return boolean true to block php error message forwarding
  */
 public function handleError($errorCode, $errorMessage, $errorFile, $errorLine)
 {
     $message = sprintf("%s in %s on line %s", $errorMessage, $errorFile, $errorLine);
     if ($this->convertToException) {
         throw new ErrorOccurredException($message, $errorCode);
     }
     $this->messageDispatcher->dispatch(new ErrorMessage($message));
     return true;
 }
 /** {@inheritDoc} */
 public function handleMessage(Message $message, MessageDispatcher $messageDispatcher)
 {
     if ($message instanceof ErrorMessage) {
         $messageDispatcher->dispatch(new LogMessage([$message->getErrorMessage()], Logger::SEVERITY_ERROR));
     }
 }
Esempio n. 4
0
 /**
  * Handles the exception thrown by the user or system.
  * Dispatch a log message containing the exception message.
  * @param \Exception $exception the exception thrown
  * @return \Brickoo\Component\Error\ExceptionHandler
  */
 public function handleException(\Exception $exception)
 {
     $this->messageDispatcher->dispatch(new ExceptionMessage($exception));
     return $this;
 }
 /** {@inheritDoc} */
 public function handleMessage(Message $message, MessageDispatcher $messageDispatcher)
 {
     if ($message instanceof ExceptionMessage) {
         $messageDispatcher->dispatch(new LogMessage($this->getExceptionMessage($message->getException()), Logger::SEVERITY_CRITICAL));
     }
 }
 /**
  * Attach the listener for flushing messages.
  * @param MessageDispatcher $dispatcher
  * @return void
  */
 private function attachFlushMessageListener(MessageDispatcher $dispatcher)
 {
     $dispatcher->attach(new MessageListener(Messages::FLUSH, $this->listenerPriority, [$this, "handleFlushMessage"]));
 }
 /**
  * @covers Brickoo\Component\Messaging\MessageDispatcher::dispatch
  * @covers Brickoo\Component\Messaging\MessageDispatcher::processMessage
  * @covers Brickoo\Component\Messaging\Exception\MaxRecursionDepthReachedException
  * @expectedException \Brickoo\Component\Messaging\Exception\MaxRecursionDepthReachedException
  */
 public function testProcessRecursionDepthLimitIsDetected()
 {
     $messageDispatcher = new MessageDispatcher(new ListenerCollection(), new MessageRecursionDepthList());
     $messageDispatcher->attach(new MessageListenerInfiniteRecursionFixture());
     $message = new GenericMessage("message.test");
     $this->assertSame($messageDispatcher, $messageDispatcher->dispatch($message));
     $messageDispatcher->dispatch($message);
 }
 /** {@inheritDoc} */
 public function collect()
 {
     $message = new GenericMessage(Messages::COLLECT_ROUTES, $this);
     $this->messageDispatcher->dispatch($message);
     return $this->extractRouteCollections($message->getResponseList());
 }
 public function attachListeners(MessageDispatcher $messageManager)
 {
     $messageManager->attach(new MessageListener("test.message", 100, [$this, "listenerCallback"]));
 }