Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
upd
  • Loading branch information
valentint committed Feb 20, 2017
commit ddbdbfe3e532a7a7d2c7cae3a0fe9240656f0277
16 changes: 7 additions & 9 deletions Server/App/Registry/HandshakeMiddlewareRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
namespace Gos\Bundle\WebSocketBundle\Server\App\Registry;

use Gos\Bundle\WebSocketBundle\Server\App\Stack\HandshakeMiddlewareInterface;
use Ratchet\Http\HttpServerInterface;

/**
* @author Tkachew <[email protected]>
*/
class HandshakeMiddlewareRegistry
{
/**
* @var []
* @var HandshakeMiddlewareInterface[]
*/
protected $middlewares;

Expand All @@ -26,19 +25,18 @@ public function __construct()
*/
public function addMiddleware($middleware)
{
$interfaces = class_implements($middleware['class']);
$interfaces = class_implements($middleware);

if (!isset($interfaces['Ratchet\Http\HttpServerInterface'])) {
throw new \Exception("'Ratchet\\Http\\HttpServerInterface' in not implemented by '{$middleware['class']}'");
if (!isset($interfaces['Gos\Bundle\WebSocketBundle\Server\App\Stack\HandshakeMiddlewareInterface'])) {
$className = get_class($middleware);
throw new \Exception('"Gos\Bundle\WebSocketBundle\Server\App\Stack\HandshakeMiddlewareInterface" in not implemented by "' . $className . '"');
}

$arguments = array_merge([$middleware['class']], $middleware['arguments']);

$this->middlewares[] = $arguments;
$this->middlewares[] = $middleware;
}

/**
* @return []
* @return HandshakeMiddlewareInterface[]
*/
public function getMiddlewares()
{
Expand Down