Ask or search…
K
Links
Comment on page

Importing $blueprint into custom controllers

Learn how to use BlueprintExtensionLibrary in your custom extension admin controllers.
We are moving Blueprint's documentation to a brand new website within the following weeks. This documentation website will phase out in the future.
As part of a breaking change in alpha-F0V you'll need to modify the path you import BlueprintExtensionLibrary from to continue using it, assuming you make use of custom controllers.
- use Pterodactyl\Services\Helpers\BlueprintExtensionLibrary;
+ use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
BlueprintExtensionLibrary or $blueprint for short, is a library your extension can call for easy access to advanced features. In this guide we'll show how to import $blueprint into both your custom controller and your view.
First, we need to go to our custom admin controller and add the following line between the namespace and class in the root of your file.
namespace Pterodactyl\Http\Controllers\Admin\Extensions\Example;
use Illuminate\View\View;
use Illuminate\View\Factory as ViewFactory;
use Pterodactyl\Http\Controllers\Controller;
use Pterodactyl\Services\Helpers\SoftwareVersionService;
+ use Pterodactyl\BlueprintFramework\Libraries\ExtensionLibrary\Admin\BlueprintAdminLibrary as BlueprintExtensionLibrary;
class ExampleExtensionController extends Controller
...
Now we define $blueprint in your class constructor.
/**
* ExampleExtensionController constructor.
*/
public function __construct(
+ private BlueprintExtensionLibrary $blueprint,
private SoftwareVersionService $version,
private ViewFactory $view
){}
Now you can access $blueprint in your controller by using $this->blueprint. But it's recommended to add $blueprint into your view as well.
/**
* Return the extension index view.
*/
public function index(): View
{
return $this->view->make('admin.extensions.example.index', [
+ 'blueprint' => $this->blueprint,
'version' => $this->version,
'root' => "/admin/extensions/example"
]);
}
After adding that, you should be able to use $blueprint in your admin view and controller.
Last modified 27d ago