ConfigProvider.php
· 401 B · PHP
Raw
<?php
namespace SomeModule;
use Mezzio\Router\RouteCollectorInterface;
class ConfigProvider
{
public function getConfig(): array
{
}
public function getDependencies(): array
{
return [
'delegators' => [
RouteCollectorInterface::class => [
RegisterRoutesFactory::class,
],
],
];
}
}
| 1 | <?php |
| 2 | |
| 3 | namespace SomeModule; |
| 4 | |
| 5 | use Mezzio\Router\RouteCollectorInterface; |
| 6 | |
| 7 | class ConfigProvider |
| 8 | { |
| 9 | public function getConfig(): array |
| 10 | { |
| 11 | } |
| 12 | |
| 13 | public function getDependencies(): array |
| 14 | { |
| 15 | return [ |
| 16 | 'delegators' => [ |
| 17 | RouteCollectorInterface::class => [ |
| 18 | RegisterRoutesFactory::class, |
| 19 | ], |
| 20 | ], |
| 21 | ]; |
| 22 | } |
| 23 | } |
RegisterRoutesFactory.php
· 398 B · PHP
Raw
<?php
namespace SomeModule;
use Psr\Container\ContainerInterface;
class RegisterRoutesFactory
{
public function __invoke(
ContainerInterface $container,
string $serviceName,
callable $factory,
): RouteCollectorInterface {
/** @var RouteCollectorInterface $routes */
$routes = $factory();
$routes->get(...)
return $routes;
}
}
| 1 | <?php |
| 2 | |
| 3 | namespace SomeModule; |
| 4 | |
| 5 | use Psr\Container\ContainerInterface; |
| 6 | |
| 7 | class RegisterRoutesFactory |
| 8 | { |
| 9 | public function __invoke( |
| 10 | ContainerInterface $container, |
| 11 | string $serviceName, |
| 12 | callable $factory, |
| 13 | ): RouteCollectorInterface { |
| 14 | /** @var RouteCollectorInterface $routes */ |
| 15 | $routes = $factory(); |
| 16 | |
| 17 | $routes->get(...) |
| 18 | |
| 19 | return $routes; |
| 20 | } |
| 21 | } |