Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Developer Documentation
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
brienne
Developer Documentation
Commits
d2a222fb
Commit
d2a222fb
authored
7 years ago
by
totten
Browse files
Options
Downloads
Patches
Plain Diff
asset-builder.md - Consistent case for `getUrl`. Tweak prose.
parent
bd073626
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/framework/asset-builder.md
+10
-7
10 additions, 7 deletions
docs/framework/asset-builder.md
with
10 additions
and
7 deletions
docs/framework/asset-builder.md
+
10
−
7
View file @
d2a222fb
...
...
@@ -88,8 +88,7 @@ What should you do if you need to create a series of similar assets, based on sl
different permutations or configurations? Add parameters (aka
`$params`
).
For example, we might want a copy of
`api-fields.json`
which only includes a
handful of chosen entities. Simply pass the chosen entities into
`getUrl()`
, then update the definition to use
`$params['entities']`
.
handful of chosen entities. Simply update the definition to read
`$params['entities']`
:
```
php
// Define the content of `api-fields.json` using `hook_civicrm_buildAsset`.
...
...
@@ -106,14 +105,18 @@ function mymodule_civicrm_buildAsset($asset, $params, &$mimeType, &$content) {
}
```
Get the generated URL for
`api-fields.json`
for a few contact-related entities:
Then, in each call to
`render(...)`
or
`getUrl(...)`
, pass the
`$params`
array with a specific value for
`entities`
.
For example, run this command to get the generated URL for
`api-fields.json`
for a few contact-related entities:
```
$ cv ev 'return \Civi::service("asset_builder")->getU
RL
("api-fields.json", array("entities" => array("Contact", "Phone", "Email", "Address")));'
$ cv ev 'return \Civi::service("asset_builder")->getU
rl
("api-fields.json", array("entities" => array("Contact", "Phone", "Email", "Address")));'
```
Get the generated URL for
`api-fields.json`
for a few case-related entities:
Or, for a few case-related entities, change the
`entities`
list:
```
$ cv ev 'return \Civi::service("asset_builder")->getU
RL
("api-fields.json", array("entities" => array("Case", "Activity", "Relationship")));'
$ cv ev 'return \Civi::service("asset_builder")->getU
rl
("api-fields.json", array("entities" => array("Case", "Activity", "Relationship")));'
```
!!! note "Note: Parameters and caching"
...
...
@@ -202,7 +205,7 @@ $ cv ev '$x = \Civi::service("asset_builder")->render("mycss"); echo $x["content
Get the generated URL:
```
$ cv ev 'return \Civi::service("asset_builder")->getU
RL
("mycss");'
$ cv ev 'return \Civi::service("asset_builder")->getU
rl
("mycss");'
```
Now we can use our newly defined asset in place of a static css file in
`myextension.php`
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment