Commit 3fb58b82 authored by colemanw's avatar colemanw
Browse files

APIv4 - Add warning and fix image

parent 6ca4ee16
......@@ -81,7 +81,7 @@ There are two ways to call the api from PHP - which one you choose is a matter o
For example, you may prefer OOP syntax because IDE code editors provide autocompletion.
Or if you need to work with the parameters as an array, traditional syntax will be more convenient.
[APIv4 PHP Examples](../../img/Api4-PHP-Styles.svg)
![APIv4 PHP Examples](../../img/Api4-PHP-Styles.svg)
#### Traditional (Procedural)
......@@ -119,6 +119,14 @@ $result = \Civi\Api4\Contact::get()
->execute();
```
!!! warning "Warning: Class names don't always match entity names!"
For example, the entity "Case" is a reserved word in PHP and therefore could not be the name of a class, so it had to be named something else ("CiviCase").
Internally, calling `civicrm_api4('Case', 'getFields')` will translate to `Civi\Api4\CiviCase::getFields`.
[Custom data entities](custom-data.md) are another example.
When writing generic functions that work with multiple entities, we strongly recommend against clever code like this: `call_user_func(['\Civi\Api4\' . $entity, 'get'], ...)`,
and suggest using this more reliable alternative: `civicrm_api4($entity, 'get', ...)`.
### AJAX
The AJAX interface is automatically available for web-pages generated through CiviCRM (such as standard CiviCRM web-pages, CiviCRM extensions and custom CiviCRM templates).
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment