فهرست منبع

Make sure flowdock handler is configured correctly, fixes #597

Jordi Boggiano 10 سال پیش
والد
کامیت
d17cf064af
1فایلهای تغییر یافته به همراه23 افزوده شده و 0 حذف شده
  1. 23 0
      src/Monolog/Handler/FlowdockHandler.php

+ 23 - 0
src/Monolog/Handler/FlowdockHandler.php

@@ -12,6 +12,7 @@
 namespace Monolog\Handler;
 
 use Monolog\Logger;
+use Monolog\Formatter\FlowdockFormatter;
 
 /**
  * Sends notifications through the Flowdock push API
@@ -48,6 +49,28 @@ class FlowdockHandler extends SocketHandler
         $this->apiToken = $apiToken;
     }
 
+    /**
+     * {@inheritdoc}
+     */
+    public function setFormatter(FormatterInterface $formatter)
+    {
+        if (!$formatter instanceof FlowdockFormatter) {
+            throw new \InvalidArgumentException('The FlowdockHandler requires an instance of Monolog\Formatter\FlowdockFormatter to function correctly');
+        }
+
+        return parent::setFormatter($formatter);
+    }
+
+    /**
+     * Gets the default formatter.
+     *
+     * @return FormatterInterface
+     */
+    protected function getDefaultFormatter()
+    {
+        throw new \InvalidArgumentException('The FlowdockHandler must be configured (via setFormatter) with an instance of Monolog\Formatter\FlowdockFormatter to function correctly');
+    }
+
     /**
      * {@inheritdoc}
      *