Skip to content

Commit

Permalink
Merge pull request #106 from alleyinteractive/refactor-from-bootstrap
Browse files Browse the repository at this point in the history
Refactoring to bootstrap file
  • Loading branch information
srtfisher authored Jun 6, 2022
2 parents b3508f6 + 7595cc4 commit ced068a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
11 changes: 0 additions & 11 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

use Mantle\Contracts;
use Mantle\Framework\Application;
use Mantle\Http\Request;

/**
* Instantiate the application
Expand All @@ -32,14 +31,4 @@
App\Exceptions\Handler::class
);

// Load the Application's Kernel depending on the context it was called.
if ( defined( 'WP_CLI' ) && \WP_CLI ) {
$app_kernel = $app->make( Contracts\Console\Kernel::class );
$app_kernel->handle();
} else {
// Boot up the HTTP Kernel.
$app_kernel = $app->make( Contracts\Http\Kernel::class );
$app_kernel->handle( Request::capture() );
}

return $app;
18 changes: 17 additions & 1 deletion mantle.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@

namespace App;

use Mantle\Contracts;
use Mantle\Http\Request;

/**
* Mantle Application Base Directory
*
Expand Down Expand Up @@ -53,4 +56,17 @@ function() {
/**
* Load the Mantle Application
*/
require_once __DIR__ . '/bootstrap/app.php';
$app = require_once __DIR__ . '/bootstrap/app.php';

/*
* Run the application.
*/
// Load the Application's Kernel depending on the context it was called.
if ( defined( 'WP_CLI' ) && \WP_CLI ) {
$app_kernel = $app->make( Contracts\Console\Kernel::class );
$app_kernel->handle();
} else {
// Boot up the HTTP Kernel.
$app_kernel = $app->make( Contracts\Http\Kernel::class );
$app_kernel->handle( Request::capture() );
}
7 changes: 6 additions & 1 deletion tests/trait-create-application.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace App\Tests;

use App\Http\Kernel;
use Mantle\Framework\Application;

/**
Expand All @@ -25,6 +26,10 @@ public function create_application(): \Mantle\Contracts\Application {
return new Application( __DIR__ . '/../', home_url( '/' ) );
}

return require __DIR__ . '/../bootstrap/app.php';
$app = require __DIR__ . '/../bootstrap/app.php';

$app->make( Kernel::class )->bootstrap();

return $app;
}
}

0 comments on commit ced068a

Please sign in to comment.