Hello,
I'm creating my own plugin for working with data and it doesn't work for me to load an overview of all pages:
public static function getSubscribedEvents() {
return [
'onPluginsInitialized' => ['onPluginsInitialized', 0],
];
}
public function onPluginsInitialized(): void
{
// Don't proceed if we are not in the admin plugin
if (!$this->isAdmin()) {
return;
}
$basename= $this->grav['uri']->basename();
$uri = $this->grav['uri'];
$config = $this->config();
$route = $config['route'] ?? null;
$route == $uri->path();
$this->grav['debugger']->addMessage($route);
if ($basename == 'contacts') {
$this->enable([
'onPageInitialized' => ['onPageInitialized', 0]
]);
}
}
public function onPageInitialized($event): void
{
$this->grav['admin']->enablePages();
$grav = Grav::instance();
$this->grav->fireEvent('onPagesInitialized',$event);
$this->grav['admin']->grav['pages']->init();
$page = $this->grav['admin']->grav['pages'];
$this->grav['debugger']->addMessage('-----------------------------------------');
$this->grav['debugger']->addMessage($page);
$this->grav['debugger']->addMessage('-----------------------------------------');
//$paths = $event['pages']->find('/', true); - null
//$paths = $event['pages']; - null
//$page = $this->grav['admin']->grav['pages']->find('/'); - OK
}
when i call grav['pages] so I'll get back:

but I only need a array of pages with a header and content, what am I doing wrong?