Hello everybody !
I’m new to cockpit (and PHP) and i need your help.
I’m using v2.8.3.
I need a endpoint similar to localhost:80/api/content/item/ITEMNAME
but who will return all items, all my singletons.
I created a /config/api/singletons/find.php file and i’m trying to make this work.
See below my files, with all my unsuccessfull attempts :
<?php
// custom api endpoint in `/config/api/singletons/find.php`
require 'cockpit/bootstrap.php';
$singletons = Cockpit::instance()->module('content')->find($this->param('collection')); // 404 when calling the route
// $singletons = $this->storage->find('singletons', $options); // created the route but crashes on storage
// $singletons = $this->module('collections')->find('content-singletons'); // creates the route but crashes "find on null"
// $singletons = $this->module('singletons') // 404 when calling the route
// $count = cockpit('collections')->count($this->param('collection')); // creates the route but crashes "cockpit unknown function"
return $singletons;
Thanks !