Last active
March 10, 2020 16:51
-
-
Save bnomei/362eb7c7cc9f808d3335434298a0935f to your computer and use it in GitHub Desktop.
Generate Field-Method intellisense hints for Kirby Models from Blueprint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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