Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix implements HandlerRegistryInterface.getHandler #2387

Open
wants to merge 1 commit into
base: 3.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
71 changes: 36 additions & 35 deletions Serializer/JMSHandlerRegistry.php
Expand Up @@ -23,39 +23,40 @@
*/
class JMSHandlerRegistry implements HandlerRegistryInterface
{
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

/**
* {@inheritdoc}
*/
public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler($direction, $typeName, $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}

/**
* {@inheritdoc}
*/
public function getHandler($direction, $typeName, $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));
}
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler($direction, $typeName, $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}

/**
* {@inheritdoc}
*
* @return callable|object
*/
public function getHandler($direction, $typeName, $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));

return null;
}
}
72 changes: 37 additions & 35 deletions Serializer/JMSHandlerRegistryV2.php
Expand Up @@ -23,39 +23,41 @@
*/
final class JMSHandlerRegistryV2 implements HandlerRegistryInterface
{
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

/**
* {@inheritdoc}
*/
public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler(int $direction, string $typeName, string $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}

/**
* {@inheritdoc}
*/
public function getHandler(int $direction, string $typeName, string $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));
}
private $registry;

public function __construct(HandlerRegistryInterface $registry)
{
$this->registry = $registry;
}

public function registerSubscribingHandler(SubscribingHandlerInterface $handler): void
{
$this->registry->registerSubscribingHandler($handler);
}

/**
* {@inheritdoc}
*/
public function registerHandler(int $direction, string $typeName, string $format, $handler): void
{
$this->registry->registerHandler($direction, $typeName, $format, $handler);
}


/**
* {@inheritdoc}
*
* @return callable|object
*/
public function getHandler(int $direction, string $typeName, string $format)
{
do {
$handler = $this->registry->getHandler($direction, $typeName, $format);
if (null !== $handler) {
return $handler;
}
} while ($typeName = get_parent_class($typeName));

return null;
}
}