4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
13 namespace Civi\Api4\Generic
;
16 * Base class for DAO entities (sql tables).
18 * This is one of 3 possible base classes for an APIv4 Entity
19 * (the others are `BasicEntity` and `AbstractEntity`).
21 * This base class is used for entities that have an associated DAO and support CRUD operations.
23 * Entities that extend this class can override actions and add others on an ad-hoc basis.
25 * DAO entities which do not support all CRUD operations should instead extend AbstractEntity
26 * in order to implement just the actions appropriate to that entity.
28 abstract class DAOEntity
extends AbstractEntity
{
31 * @param bool $checkPermissions
32 * @return DAOGetAction
34 public static function get($checkPermissions = TRUE) {
35 return (new DAOGetAction(static::getEntityName(), __FUNCTION__
))
36 ->setCheckPermissions($checkPermissions);
40 * @param bool $checkPermissions
41 * @return DAOSaveAction
43 public static function save($checkPermissions = TRUE) {
44 return (new DAOSaveAction(static::getEntityName(), __FUNCTION__
))
45 ->setCheckPermissions($checkPermissions);
49 * @param bool $checkPermissions
50 * @return DAOGetFieldsAction
52 public static function getFields($checkPermissions = TRUE) {
53 return (new DAOGetFieldsAction(static::getEntityName(), __FUNCTION__
))
54 ->setCheckPermissions($checkPermissions);
58 * @param bool $checkPermissions
59 * @return DAOCreateAction
61 public static function create($checkPermissions = TRUE) {
62 return (new DAOCreateAction(static::getEntityName(), __FUNCTION__
))
63 ->setCheckPermissions($checkPermissions);
67 * @param bool $checkPermissions
68 * @return DAOUpdateAction
70 public static function update($checkPermissions = TRUE) {
71 return (new DAOUpdateAction(static::getEntityName(), __FUNCTION__
))
72 ->setCheckPermissions($checkPermissions);
76 * @param bool $checkPermissions
77 * @return DAODeleteAction
79 public static function delete($checkPermissions = TRUE) {
80 return (new DAODeleteAction(static::getEntityName(), __FUNCTION__
))
81 ->setCheckPermissions($checkPermissions);
85 * @param bool $checkPermissions
86 * @return BasicReplaceAction
88 public static function replace($checkPermissions = TRUE) {
89 return (new BasicReplaceAction(static::getEntityName(), __FUNCTION__
))
90 ->setCheckPermissions($checkPermissions);