Skip to content

Instantly share code, notes, and snippets.

@montchr
Created April 12, 2023 19:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save montchr/eac9e3a25efaff74ed55c1f117f14a87 to your computer and use it in GitHub Desktop.
Save montchr/eac9e3a25efaff74ed55c1f117f14a87 to your computer and use it in GitHub Desktop.
Bedrock/Acorn Tinkerwell Driver
<?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