Apiv4 Entity.get - no caching
If you call
Entity::get(FALSE)->addWhere('name', '=', 'xyx')->execute());
Mote that once it will do expensive file scans more than once from the looks @colemanw
protected function getRecords() {
$entities = [];
$toGet = $this->_itemsToGet('name');
$locations = array_merge([\Civi::paths()->getPath('[civicrm.root]/Civi.php')],
array_column(\CRM_Extension_System::singleton()->getMapper()->getActiveModuleFiles(), 'filePath')
);
$enabledComponents = array_keys(\CRM_Core_Component::getEnabledComponents());
foreach ($locations as $location) {
$dir = \CRM_Utils_File::addTrailingSlash(dirname($location)) . 'Civi/Api4';
if (is_dir($dir)) {
foreach (glob("$dir/*.php") as $file) {
$matches = [];
preg_match('/(\w*)\.php$/', $file, $matches);
$className = '\Civi\Api4\\' . $matches[1];
if (is_a($className, '\Civi\Api4\Generic\AbstractEntity', TRUE)) {
$info = $className::getInfo();
$entityName = $info['name'];
$daoName = $info['dao'] ?? NULL;
// Only include DAO entities from enabled components
if ((!$toGet || in_array($entityName, $toGet)) &&
(!$daoName || !defined("{$daoName}::COMPONENT") || in_array($daoName::COMPONENT, $enabledComponents))
) {
$entities[$info['name']] = $info;
}
}
}
}
}
// Fetch custom entities unless we've already fetched everything requested
if ($this->includeCustom && (!$toGet || array_diff($toGet, array_keys($entities)))) {
$this->addCustomEntities($entities);
}
ksort($entities);
return $entities;
}