Created
April 12, 2023 19:11
-
-
Save montchr/eac9e3a25efaff74ed55c1f117f14a87 to your computer and use it in GitHub Desktop.
Bedrock/Acorn Tinkerwell Driver
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// @phpstan-ignore-file | |
use Illuminate\Support\Collection; | |
class BedrockTinkerwellDriver extends TinkerwellDriver | |
{ | |
public function canBootstrap($projectPath) | |
{ | |
return "{$projectPath}/web/index.php"; | |
} | |
public function bootstrap($projectPath) | |
{ | |
// Mirrors the contents of `wp-config.php`. | |
require_once "{$projectPath}/vendor/autoload.php"; | |
require_once "{$projectPath}/config/application.php"; | |
require_once ABSPATH . '/wp-settings.php'; | |
} | |
public function getAvailableVariables() | |
{ | |
return [ | |
'__options' => wp_load_alloptions(), | |
'__posts' => (new WP_Query(['posts_per_page' => -1]))->get_posts(), | |
'__sage' => function ($service = null) { | |
return app($service); | |
}, | |
'collection' => Collection::class, | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment