From bd073626d62c0a3620a6147b13a30b4e598ac6b7 Mon Sep 17 00:00:00 2001 From: Tim Otten <totten@civicrm.org> Date: Fri, 3 Nov 2017 17:40:15 -0700 Subject: [PATCH] asset-builder.md - In first example, distinguish CLI+PHP --- docs/framework/asset-builder.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/docs/framework/asset-builder.md b/docs/framework/asset-builder.md index 765afe86..74b3e166 100644 --- a/docs/framework/asset-builder.md +++ b/docs/framework/asset-builder.md @@ -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 -- GitLab