This will allow the addition of a CiviCase API which cannot have the className "Case" because that is a reserved php keyword
Also cleans up other entities that use `static::class` in place of entityName because it's not a good pattern to replicate.
* @return \Civi\Api4\Action\GetActions
*/
public static function getActions($checkPermissions = TRUE) {
- return (new \Civi\Api4\Action\GetActions(self::getEntityName(), __FUNCTION__))
+ return (new \Civi\Api4\Action\GetActions(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @throws NotImplementedException
*/
public static function __callStatic($action, $args) {
- $entity = self::getEntityName();
+ $entity = static::getEntityName();
$nameSpace = str_replace('Civi\Api4\\', 'Civi\Api4\Action\\', static::class);
// Find class for this action
$entityAction = "$nameSpace\\" . ucfirst($action);
* @return BasicGetAction
*/
public static function get($checkPermissions = TRUE) {
- return (new BasicGetAction(static::class, __FUNCTION__, static::$getter))
+ return (new BasicGetAction(static::getEntityName(), __FUNCTION__, static::$getter))
->setCheckPermissions($checkPermissions);
}
* @return BasicCreateAction
*/
public static function create($checkPermissions = TRUE) {
- return (new BasicCreateAction(static::class, __FUNCTION__, static::$setter))
+ return (new BasicCreateAction(static::getEntityName(), __FUNCTION__, static::$setter))
->setCheckPermissions($checkPermissions);
}
* @return BasicSaveAction
*/
public static function save($checkPermissions = TRUE) {
- return (new BasicSaveAction(static::class, __FUNCTION__, static::$idField, static::$setter))
+ return (new BasicSaveAction(static::getEntityName(), __FUNCTION__, static::$idField, static::$setter))
->setCheckPermissions($checkPermissions);
}
* @return BasicUpdateAction
*/
public static function update($checkPermissions = TRUE) {
- return (new BasicUpdateAction(static::class, __FUNCTION__, static::$idField, static::$setter))
+ return (new BasicUpdateAction(static::getEntityName(), __FUNCTION__, static::$idField, static::$setter))
->setCheckPermissions($checkPermissions);
}
* @return BasicBatchAction
*/
public static function delete($checkPermissions = TRUE) {
- return (new BasicBatchAction(static::class, __FUNCTION__, static::$idField, static::$deleter))
+ return (new BasicBatchAction(static::getEntityName(), __FUNCTION__, static::$idField, static::$deleter))
->setCheckPermissions($checkPermissions);
}
* @return BasicReplaceAction
*/
public static function replace($checkPermissions = TRUE) {
- return (new BasicReplaceAction(static::class, __FUNCTION__))
+ return (new BasicReplaceAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOGetAction
*/
public static function get($checkPermissions = TRUE) {
- return (new DAOGetAction(static::class, __FUNCTION__))
+ return (new DAOGetAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOSaveAction
*/
public static function save($checkPermissions = TRUE) {
- return (new DAOSaveAction(static::class, __FUNCTION__))
+ return (new DAOSaveAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOGetFieldsAction
*/
public static function getFields($checkPermissions = TRUE) {
- return (new DAOGetFieldsAction(static::class, __FUNCTION__))
+ return (new DAOGetFieldsAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOCreateAction
*/
public static function create($checkPermissions = TRUE) {
- return (new DAOCreateAction(static::class, __FUNCTION__))
+ return (new DAOCreateAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAOUpdateAction
*/
public static function update($checkPermissions = TRUE) {
- return (new DAOUpdateAction(static::class, __FUNCTION__))
+ return (new DAOUpdateAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return DAODeleteAction
*/
public static function delete($checkPermissions = TRUE) {
- return (new DAODeleteAction(static::class, __FUNCTION__))
+ return (new DAODeleteAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return BasicReplaceAction
*/
public static function replace($checkPermissions = TRUE) {
- return (new BasicReplaceAction(static::class, __FUNCTION__))
+ return (new BasicReplaceAction(static::getEntityName(), __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return \Civi\Api4\Action\MailSettings\TestConnection
*/
public static function testConnection($checkPermissions = TRUE) {
- $action = new \Civi\Api4\Action\MailSettings\TestConnection(static::class, __FUNCTION__);
+ $action = new \Civi\Api4\Action\MailSettings\TestConnection(__CLASS__, __FUNCTION__);
return $action->setCheckPermissions($checkPermissions);
}
* @return Generic\DAOGetAction
*/
public static function get($checkPermissions = TRUE) {
- return (new Generic\DAOGetAction(static::class, __FUNCTION__))
+ return (new Generic\DAOGetAction(__CLASS__, __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
* @return Generic\DAOGetFieldsAction
*/
public static function getFields($checkPermissions = TRUE) {
- return (new Generic\DAOGetFieldsAction(static::class, __FUNCTION__))
+ return (new Generic\DAOGetFieldsAction(__CLASS__, __FUNCTION__))
->setCheckPermissions($checkPermissions);
}
// Format oop params
function formatOOP(entity, action, params, indent) {
- var code = '',
+ var info = getEntity(entity),
newLine = "\n" + _.repeat(' ', indent),
+ code = '\\' + info.class + '::' + action + '(',
perm = params.checkPermissions === false ? 'FALSE' : '';
if (entity.substr(0, 7) !== 'Custom_') {
- code = "\\Civi\\Api4\\" + entity + '::' + action + '(' + perm + ')';
+ code += perm + ')';
} else {
- code = "\\Civi\\Api4\\CustomValue::" + action + "('" + entity.substr(7) + "'" + (perm ? ', ' : '') + perm + ")";
+ code += "'" + entity.substr(7) + "'" + (perm ? ', ' : '') + perm + ")";
}
_.each(params, function(param, key) {
var val = '';