* serverurlhelper change
This commit is contained in:
parent
d67b145f56
commit
491e572228
@ -1,5 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use App\Helper as AppHelper;
|
||||||
use Zend\Expressive\Application;
|
use Zend\Expressive\Application;
|
||||||
use Zend\Expressive\Container;
|
use Zend\Expressive\Container;
|
||||||
use Zend\Expressive\Delegate;
|
use Zend\Expressive\Delegate;
|
||||||
@ -21,12 +22,12 @@ return [
|
|||||||
// class name.
|
// class name.
|
||||||
'invokables' => [
|
'invokables' => [
|
||||||
// Fully\Qualified\InterfaceName::class => Fully\Qualified\ClassName::class,
|
// Fully\Qualified\InterfaceName::class => Fully\Qualified\ClassName::class,
|
||||||
Helper\ServerUrlHelper::class => Helper\ServerUrlHelper::class,
|
|
||||||
],
|
],
|
||||||
// Use 'factories' for services provided by callbacks/factory classes.
|
// Use 'factories' for services provided by callbacks/factory classes.
|
||||||
'factories' => [
|
'factories' => [
|
||||||
Application::class => Container\ApplicationFactory::class,
|
Application::class => Container\ApplicationFactory::class,
|
||||||
Delegate\NotFoundDelegate::class => Container\NotFoundDelegateFactory::class,
|
Delegate\NotFoundDelegate::class => Container\NotFoundDelegateFactory::class,
|
||||||
|
Helper\ServerUrlHelper::class => AppHelper\ServerUrlHelperFactory::class,
|
||||||
Helper\ServerUrlMiddleware::class => Helper\ServerUrlMiddlewareFactory::class,
|
Helper\ServerUrlMiddleware::class => Helper\ServerUrlMiddlewareFactory::class,
|
||||||
Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
|
Helper\UrlHelper::class => Helper\UrlHelperFactory::class,
|
||||||
Helper\UrlHelperMiddleware::class => Helper\UrlHelperMiddlewareFactory::class,
|
Helper\UrlHelperMiddleware::class => Helper\UrlHelperMiddlewareFactory::class,
|
||||||
|
|||||||
@ -1,21 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
|
||||||
'los_basepath' => '/cps',
|
'los_basepath' => '/cps',
|
||||||
|
|
||||||
'dependencies' => [
|
'dependencies' => [
|
||||||
'factories' => [
|
'factories' => [
|
||||||
LosMiddleware\BasePath\BasePath::class => LosMiddleware\BasePath\BasePathFactory::class,
|
LosMiddleware\BasePath\BasePath::class => LosMiddleware\BasePath\BasePathFactory::class,
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
|
||||||
'middleware_pipeline' => [
|
|
||||||
'always' => [
|
|
||||||
'middleware' => [
|
|
||||||
LosMiddleware\BasePath\BasePath::class
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
@ -17,6 +17,7 @@ use Zend\Stratigility\Middleware\ErrorHandler;
|
|||||||
// all Exceptions.
|
// all Exceptions.
|
||||||
$app->pipe(ErrorHandler::class);
|
$app->pipe(ErrorHandler::class);
|
||||||
$app->pipe(ServerUrlMiddleware::class);
|
$app->pipe(ServerUrlMiddleware::class);
|
||||||
|
$app->pipe(LosMiddleware\BasePath\BasePath::class);
|
||||||
|
|
||||||
// Pipe more middleware here that you want to execute on every request:
|
// Pipe more middleware here that you want to execute on every request:
|
||||||
// - bootstrapping
|
// - bootstrapping
|
||||||
|
|||||||
34
src/App/Helper/ServerUrlHelperFactory.php
Normal file
34
src/App/Helper/ServerUrlHelperFactory.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Helper;
|
||||||
|
|
||||||
|
|
||||||
|
use Psr\Container\ContainerInterface;
|
||||||
|
use Zend\Diactoros\Uri;
|
||||||
|
use Zend\Expressive\Helper\ServerUrlHelper;
|
||||||
|
|
||||||
|
class ServerUrlHelperFactory
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Create a UrlHelper instance.
|
||||||
|
*
|
||||||
|
* @param ContainerInterface $container
|
||||||
|
* @return ServerUrlHelper
|
||||||
|
* @throws \Psr\Container\ContainerExceptionInterface
|
||||||
|
* @throws \Psr\Container\NotFoundExceptionInterface
|
||||||
|
*/
|
||||||
|
public function __invoke(ContainerInterface $container)
|
||||||
|
{
|
||||||
|
$config = $container->get('config');
|
||||||
|
$path = array_key_exists('los_basepath', $config) && !empty($config['los_basepath'])
|
||||||
|
? $config['los_basepath']
|
||||||
|
: null;
|
||||||
|
|
||||||
|
$serverUrlHelper = new ServerUrlHelper();
|
||||||
|
if ($path) {
|
||||||
|
$uri = (new Uri())->withPath($path);
|
||||||
|
$serverUrlHelper->setUri($uri);
|
||||||
|
}
|
||||||
|
return $serverUrlHelper;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user