Skip to content

Commit 8b28b88

Browse files
maciejmrozinskimarcj
authored andcommitted
Add usage of ApplicationEnvironmentAwareInterface (#50)
1 parent 7d24719 commit 8b28b88

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

Bootstraps/Drupal.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* @see \PHPPM\Bootstraps\Symfony
1313
* @see \PHPPM\Bridges\HttpKernel
1414
*/
15-
class Drupal implements BootstrapInterface
15+
class Drupal implements BootstrapInterface, ApplicationEnvironmentAwareInterface
1616
{
1717
/**
1818
* The PHP environment in which to bootstrap (such as 'dev' or 'production').
@@ -27,9 +27,12 @@ class Drupal implements BootstrapInterface
2727
protected $debug;
2828

2929
/**
30-
* Instantiate the bootstrap, storing the $appenv.
30+
* Instantiate the bootstrap, storing the $appenv
31+
*
32+
* @param $appenv
33+
* @param $debug
3134
*/
32-
public function __construct($appenv, $debug)
35+
public function initialize($appenv, $debug)
3336
{
3437
$this->appenv = $appenv;
3538
$this->debug = $debug;

Bootstraps/Laravel.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
/**
66
* A default bootstrap for the Laravel framework
77
*/
8-
class Laravel implements BootstrapInterface, HooksInterface, RequestClassProviderInterface
8+
class Laravel implements BootstrapInterface, HooksInterface, RequestClassProviderInterface,
9+
ApplicationEnvironmentAwareInterface
910
{
1011
/**
1112
* @var string|null The application environment
@@ -26,9 +27,11 @@ class Laravel implements BootstrapInterface, HooksInterface, RequestClassProvide
2627

2728
/**
2829
* Instantiate the bootstrap, storing the $appenv
30+
*
2931
* @param string|null $appenv The environment your application will use to bootstrap (if any)
32+
* @param $debug
3033
*/
31-
public function __construct($appenv, $debug)
34+
public function initialize($appenv, $debug)
3235
{
3336
$this->appenv = $appenv;
3437
$this->debug = $debug;

Bootstraps/Symfony.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
/**
1010
* A default bootstrap for the Symfony framework
1111
*/
12-
class Symfony implements BootstrapInterface, HooksInterface
12+
class Symfony implements BootstrapInterface, HooksInterface, ApplicationEnvironmentAwareInterface
1313
{
1414
/**
1515
* @var string|null The application environment
@@ -23,8 +23,11 @@ class Symfony implements BootstrapInterface, HooksInterface
2323

2424
/**
2525
* Instantiate the bootstrap, storing the $appenv
26+
*
27+
* @param $appenv
28+
* @param $debug
2629
*/
27-
public function __construct($appenv, $debug)
30+
public function initialize($appenv, $debug)
2831
{
2932
$this->appenv = $appenv;
3033
$this->debug = $debug;

Bridges/HttpKernel.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace PHPPM\Bridges;
44

5+
use PHPPM\Bootstraps\ApplicationEnvironmentAwareInterface;
56
use PHPPM\Bootstraps\BootstrapInterface;
67
use PHPPM\Bootstraps\HooksInterface;
78
use PHPPM\Bootstraps\RequestClassProviderInterface;
@@ -47,7 +48,10 @@ public function bootstrap($appBootstrap, $appenv, $debug)
4748
{
4849
$appBootstrap = $this->normalizeAppBootstrap($appBootstrap);
4950

50-
$this->bootstrap = new $appBootstrap($appenv, $debug);
51+
$this->bootstrap = new $appBootstrap();
52+
if ($this->bootstrap instanceof ApplicationEnvironmentAwareInterface) {
53+
$this->bootstrap->initialize($appenv, $debug);
54+
}
5155
if ($this->bootstrap instanceof BootstrapInterface) {
5256
$this->application = $this->bootstrap->getApplication();
5357
}

0 commit comments

Comments
 (0)