-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from bankiru/feature/fixes-and-tests
Fix method loader
- Loading branch information
Showing
28 changed files
with
617 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/Bankiru/Api/Rpc/DependencyInjection/Compiler/RouterLoaderPass.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: batanov.pavel | ||
* Date: 17.05.2016 | ||
* Time: 7:42 | ||
*/ | ||
|
||
namespace Bankiru\Api\Rpc\DependencyInjection\Compiler; | ||
|
||
use Bankiru\Api\Rpc\Listener\ExceptionListener; | ||
use Bankiru\Api\Rpc\RpcEvents; | ||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
class RouterLoaderPass implements CompilerPassInterface | ||
{ | ||
/** {@inheritdoc} */ | ||
public function process(ContainerBuilder $container) | ||
{ | ||
if ($container->has('logger')) { | ||
$container | ||
->register('rpc.exception_listener', ExceptionListener::class) | ||
->setArguments([new Reference('logger')]) | ||
->addTag( | ||
'kernel.event_listener', | ||
[ | ||
'event' => RpcEvents::EXCEPTION, | ||
'method' => 'onException', | ||
] | ||
); | ||
} | ||
|
||
$loader = $container->getDefinition('rpc.router.resolver'); | ||
|
||
$taggedServices = $container->findTaggedServiceIds('rpc.route_loader'); | ||
|
||
foreach ($taggedServices as $id => $tags) { | ||
$loader->addMethodCall('addLoader', [new Reference($id)]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: batanov.pavel | ||
* Date: 17.05.2016 | ||
* Time: 8:44 | ||
*/ | ||
|
||
namespace Bankiru\Api\Rpc\Event; | ||
|
||
use Bankiru\Api\Rpc\RpcEvent; | ||
use ScayTrase\Api\Rpc\RpcResponseInterface; | ||
|
||
class RpcResponseEvent extends RpcEvent | ||
{ | ||
/** @var RpcResponseInterface|null */ | ||
protected $response; | ||
|
||
/** @return bool */ | ||
public function hasResponse() | ||
{ | ||
return null !== $this->response; | ||
} | ||
|
||
/** @return RpcResponseInterface */ | ||
public function getResponse() | ||
{ | ||
return $this->response; | ||
} | ||
|
||
/** | ||
* @param RpcResponseInterface $response | ||
*/ | ||
public function setResponse(RpcResponseInterface $response) | ||
{ | ||
$this->response = $response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
src/Bankiru/Api/Rpc/Exception/InvalidMethodParametersException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
/** | ||
* Created by PhpStorm. | ||
* User: batanov.pavel | ||
* Date: 16.05.2016 | ||
* Time: 10:06 | ||
*/ | ||
|
||
namespace Bankiru\Api\Rpc\Exception; | ||
|
||
class InvalidMethodParametersException extends \InvalidArgumentException implements RpcException | ||
{ | ||
/** | ||
* @param string $method | ||
* @param string[] $missing | ||
* | ||
* @return static | ||
*/ | ||
public static function missing($method, array $missing) | ||
{ | ||
return new static( | ||
sprintf( | ||
'Some parameters for method "%s" are missing and do not have the default value: %s', | ||
$method, | ||
implode(', ', $missing) | ||
) | ||
); | ||
} | ||
|
||
/** | ||
* @param string $method | ||
* @param string $name | ||
* @param string $expected | ||
* @param string $actual | ||
* | ||
* @return static | ||
*/ | ||
public static function typeMismatch($method, $name, $expected, $actual) | ||
{ | ||
return new static( | ||
sprintf('Parameter %s for method "%s" has invalid type: %s given, %s expected', $name, $method, $actual, $expected) | ||
); | ||
} | ||
} |
Oops, something went wrong.