Developers may want to amend a gridfield (either by modifying its
components or amending the list) after it has been transformed to be
readonly.
One such modification may be replacing the GridFieldViewButton
with something else - because components are instantiated with the "new"
keyword this would be the only way to do that.
GridField has onBeforeRender in its Field method, but that hardly ever gets called.
This commit adds the onBeforeRenderHolder extension hook that is normally available via FormField::FieldHolder().
See `SSViewer::templates()`and `SSViewer::setTemplateFile()`
Methods assume this variable should be an array. If you call `setTemplateFile()` directly prior / instead of any `setTemplate` call then a PHP warning is generated `[Warning] array_merge(): Expected parameter 2 to be an array, null given`
If the content is invalid for whatever reason e.g. when instantiating
a DBText field to get a summary of text through
`DBField::create_field('Text', $content)->Summary(10)`, preg_split returns
false and the rest of the code expects an array.
This tweak ensures an array is always returned even when preg_split fails.
* DOCS Clearer sysadmin guidance for "packaging"
We have all kinds of fun fallbacks that attempt to create supporting files in production environments.
The latest point of contention is dev/build automatically creating files in .graphql/ and public/_graphql/
if those don't exist. That should be regarded as a last resort option to allow introduction of GraphQL v4 in the CMS 4.x release line.
At least since CMS 4.1, we need some form of "packaging" for generated files (public/_resources),
or committing these into the codebase, so let's call that out for anyone running CMS infra.
* Add trailing slash
Co-authored-by: Aaron Carlino <unclecheese@leftandmain.com>
- I believe the YAML file should be included for the completeness of this example.
- Added details on Caching, I know this is duplication, but I believe it reinforces this requirement by example.
- The example **phpunit.xml** file is a basic working example.
I propose this as a more complete how-to, my thinking is someone new reading this how-to documentation, can follow the instructions and successfully run the example test. I hope this is acceptable.
- The Silverstripe 4 folder structure has been changed from **app/code/** to **app/src/**
- Renamed Silverstripe in text. I assume `api:` and `Namespace`, should remain SilverStripe
- Added some missing semicolons