How to get a unique identifier of a page blueprint

i have a set of pages with similar blueprints: message.yml, message-a.yml, message-b.yml.
In a hook page.changeStatus:after i have to make decicions depending the exact type of the blueprint. so i thought $page->blueprint()->name() should do the job:

surprisingly that gives me the complete path, but not the (file-)name:

$page->blueprint()->name(); //'pages/message' or 'pages/message-a'

My current solution is to explode that path to an array and use the last item as the identifier,
but that seems a bit hackish to me and i am actually not sure it that will work on windows-machines too.

$array = explode("/", $page->blueprint()->name());          
$name = end($array);

$page->intendedTemplate() does not work, because all pages/blueprints are using the same template by the ‘shared-templates’ plugin feature… $page->blueprint()->title() for some reasons is also not my favorite.

so, is there a better way to identify the blueprint of a page, rather than exploding the path and use the last item?


Why not?

But the actually used template is different from the intendedTemplate. so if you don’t want to use the blueprint title, intendedTemplate would be right.

Oh yeah, you are right!
I doublechecked the intendedTemplate and it works now.

The error was in the if statement:

if ($page->intendedTemplate() == 'message-a')
  // works now
if ($page->intendedTemplate() === 'message-a')
  // doesn't work of course, while intendedTemplate() is not Type String
  // but the explode result was

I was blended by the ‘shared-templates’ stuff!
But i am still wondering, why $page->blueprint()->name() returns the path instead of the name.
Anyway: Thanks @texnixe

That because that is the full namespace of the blueprint, as opposed to other types of blueprint, i.e. the key you also register them with in a plugin file.