Skip to content

Fix https://github.com/php-pm/php-pm-httpkernel/issues/34 #35

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

Merged
merged 1 commit into from
May 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
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
15 changes: 0 additions & 15 deletions Bootstraps/AbstractBootstrap.php

This file was deleted.

2 changes: 1 addition & 1 deletion Bootstraps/Drupal.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @see \PHPPM\Bootstraps\Symfony
* @see \PHPPM\Bridges\HttpKernel
*/
class Drupal extends AbstractBootstrap
class Drupal implements BootstrapInterface
{
/**
* The PHP environment in which to bootstrap (such as 'dev' or 'production').
Expand Down
2 changes: 1 addition & 1 deletion Bootstraps/Laravel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* A default bootstrap for the Laravel framework
*/
class Laravel implements BootstrapInterface, HooksInterface
class Laravel implements BootstrapInterface, HooksInterface, RequestClassProviderInterface
{
/**
* @var string|null The application environment
Expand Down
11 changes: 11 additions & 0 deletions Bootstraps/RequestClassProviderInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace PHPPM\Bootstraps;

/**
* Implement this interface if HttpKernel bridge needs to return a specialized request class
*/
interface RequestClassProviderInterface
{
public function requestClass();
}
2 changes: 1 addition & 1 deletion Bootstraps/Symfony.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* A default bootstrap for the Symfony framework
*/
class Symfony extends AbstractBootstrap implements HooksInterface
class Symfony implements BootstrapInterface, HooksInterface
{
/**
* @var string|null The application environment
Expand Down
11 changes: 8 additions & 3 deletions Bridges/HttpKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace PHPPM\Bridges;

use PHPPM\Bootstraps\AbstractBootstrap;
use PHPPM\Bootstraps\BootstrapInterface;
use PHPPM\Bootstraps\HooksInterface;
use PHPPM\Bootstraps\RequestClassProviderInterface;
use PHPPM\React\HttpResponse;
use PHPPM\Utils;
use React\Http\Request as ReactRequest;
Expand All @@ -23,7 +23,7 @@ class HttpKernel implements BridgeInterface
protected $application;

/**
* @var AbstractBootstrap
* @var BootstrapInterface
*/
protected $bootstrap;

Expand Down Expand Up @@ -146,7 +146,12 @@ protected function mapRequest(ReactRequest $reactRequest)
$files = $reactRequest->getFiles();
$post = $reactRequest->getPost();

$class = $this->bootstrap->requestClass();
if ($this->bootstrap instanceof RequestClassProviderInterface) {
$class = $this->bootstrap->requestClass();
}
else {
$class = '\Symfony\Component\HttpFoundation\Request';
}

$syRequest = new $class($query, $post, $attributes = [], $cookies, $files, $_SERVER, $reactRequest->getBody());

Expand Down