I thought the use of Collection instead of Pages was because of handling of drafts. It seems the searchForTemplate gathers drafts but they are null in the collection anyway. The problem with collection is that you cant use listed/unlisted and some other methods.
$results = new \Kirby\Cms\Pages;
$str = "SELECT * FROM AUTOID WHERE template = '${template}'" . $rootId;
foreach ($this->database->query($str) as $obj) {
$results->add((new AutoIDItem($obj))->toObject());
}
return $results;
Not sure how Drafts should be handled - Kirby\Cms\Pages seem to be really pesky about including drafts because they have no id. But i think the returned object from searchByTemplate/findByTemplate should be Kirby\Cms\Pages.
I thought the use of
Collection
instead ofPages
was because of handling of drafts. It seems thesearchForTemplate
gathers drafts but they are null in the collection anyway. The problem with collection is that you cant uselisted
/unlisted
and some other methods.https://github.com/bnomei/kirby3-autoid/blob/76372d3b8d6bab5f4c7188944f48e54f9eb33b51/classes/AutoIDDatabase.php#L111-L116
Change could just be
Not sure how Drafts should be handled -
Kirby\Cms\Pages
seem to be really pesky about including drafts because they have no id. But i think the returned object fromsearchByTemplate
/findByTemplate
should beKirby\Cms\Pages
.