Skip to content

Instantly share code, notes, and snippets.

@bnomei
Last active March 10, 2020 16:51
Show Gist options
  • Save bnomei/362eb7c7cc9f808d3335434298a0935f to your computer and use it in GitHub Desktop.
Save bnomei/362eb7c7cc9f808d3335434298a0935f to your computer and use it in GitHub Desktop.
Generate Field-Method intellisense hints for Kirby Models from Blueprint
<?php
// add this to 'pageMethods' in a plugin
'intellisense' => function () {
// $page->intellisense()
return implode(PHP_EOL, array_merge(['/**'], array_map(function($key) {
return " * @method \Kirby\Cms\Field {$key}()";
}, array_keys($this->blueprint()->fields())), [' */']));
},
// add the output before the class in your model
/**
* @method \Kirby\Cms\Field date()
* @method \Kirby\Cms\Field location()
* @method \Kirby\Cms\Field tags()
* @method \Kirby\Cms\Field text()
* @method \Kirby\Cms\Field autoid()
*/
class MyCustomPage extends Page {
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment