Fetching a complete php-based page blueprint

I’m trying to get a page tabs definition of a page blueprint using php for a plugin I’m developing:

However, I’m getting this incomplete blueprint, which makes sense because it’s a lazy-loaded php-based blueprint (cookbook).

// getting a specific tab of a page blueprint
$value = $newPage->blueprint()->tab("dynamic");

// $value
[
  {
    "columns":[],
    "icon":null,
    "label":"Dynamic",
    "link":"\/pages\/projects+myproject\/?tab=dynamic", // api link to load
    "name":"dynamic"
  }
];

The question is, how do I fetch the blueprint of this specific php-based tab?
I tried hacking the Panel Fiber request, but I’m getting an empty object:
I would guess it’s an authentification issue?

// Set Fiber Header
$_SERVER['HTTP_X_FIBER'] = 'true';

// new App Instance
$app = kirby()->clone([
  'request' => [
    'method' => 'GET',
    'url' => '/pages/projects+myproject',
  ]
], true);

// Request
$value = Panel::router('/pages/projects+myproject');
unset($_SERVER['HTTP_X_FIBER']);

// $value
{}

Is there a simpler way?

I just tried it with a blueprint I had and was getting an error because my PHP blueprint show tabs, fields etc depending on the current user’s role, so had to impersonate my user before I got the correct output. But that looked fine then.

Could you post your example blueprint for testing?

Ah gosh, it was actually the PageBlueprint cache messing with my page :grinning_face: . It works now

use Kirby\Cms\PageBlueprint;

// ...

kirby()->impersonate('kirby');

// empty blueprint cache
array_splice(PageBlueprint::$loaded, 0);

// purge cached page blueprint
$newPage->purge();

// correct tab blueprint
$newPage->blueprint()->tab("dynamic");

// ...