protected $includeCustom;
/**
- * Returns all APIv4 entities
+ * Returns all APIv4 entities from core, enabled components and enabled extensions.
*/
protected function getRecords() {
$provider = \Civi::service('action_object_provider');
- return $provider->getEntities();
+ return array_filter($provider->getEntities(), function($entity) {
+ // Only include DAO entities from enabled components
+ $daoName = $entity['dao'] ?? NULL;
+ return (!$daoName || !defined("{$daoName}::COMPONENT") || \CRM_Core_Component::isEnabled($daoName::COMPONENT));
+ });
}
}
if (!$entities) {
// Load entities declared in API files
foreach ($this->getAllApiClasses() as $className) {
- $this->loadEntity($className, $entities);
+ $info = $className::getInfo();
+ $entities[$info['name']] = $info;
}
// Allow extensions to modify the list of entities
$event = GenericHookEvent::create(['entities' => &$entities]);
return $entities;
}
- /**
- * @param \Civi\Api4\Generic\AbstractEntity $className
- * @param array $entities
- */
- private function loadEntity($className, array &$entities) {
- $info = $className::getInfo();
- $daoName = $info['dao'] ?? NULL;
- // Only include DAO entities from enabled components
- if (!$daoName || !defined("{$daoName}::COMPONENT") || \CRM_Core_Component::isEnabled($daoName::COMPONENT)) {
- $entities[$info['name']] = $info;
- }
- }
-
/**
* Scan all api directories to discover entities
* @return \Civi\Api4\Generic\AbstractEntity[]