Skip to content
Snippets Groups Projects
Commit bd073626 authored by totten's avatar totten
Browse files

asset-builder.md - In first example, distinguish CLI+PHP

parent c5bcd3cb
No related branches found
No related tags found
No related merge requests found
......@@ -55,16 +55,23 @@ function mymodule_civicrm_buildAsset($asset, $params, &$mimeType, &$content) {
}
```
Check it is functioning correctly with:
To quickly test if the asset is defined correctly, run this on the command-line:
```
$ cv ev '$x = \Civi::service("asset_builder")->render("api-fields.json"); echo $x["content"];'
```
Get the generated URL:
Or run this command to obtain the asset's URL:
```
$ cv ev 'return \Civi::service("asset_builder")->getURL("api-fields.json");'
$ cv ev 'return \Civi::service("asset_builder")->getUrl("api-fields.json");'
```
Notice that these commands use `Civi::service("asset_builder")` and the
functions `render(...)` or `getUrl(...)` to manage the asset. You can call
these functions in your PHP code. Further down, the fully formed CSS
example will demonstrate this.
!!! note "What does `getUrl(...)` do?"
In normal/production mode, `getUrl(...)` checks to see if the asset
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment