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 +--------------------------------------------------------------------+
16 * @copyright CiviCRM LLC https://civicrm.org/licensing
22 namespace Civi\Api4\Action\Entity
;
24 use Civi\Api4\Utils\CoreUtil
;
27 * Get a list of FK links between entities
29 class GetLinks
extends \Civi\Api4\Generic\BasicGetAction
{
31 public function getRecords() {
33 /** @var \Civi\Api4\Service\Schema\SchemaMap $schema */
34 $schema = \Civi
::container()->get('schema_map');
35 foreach ($schema->getTables() as $table) {
36 $entity = CoreUtil
::getApiNameFromTableName($table->getName());
37 // Since this is an api function, exclude tables that don't have an api
38 if (class_exists('\Civi\Api4\\' . $entity)) {
41 'table' => $table->getName(),
44 foreach ($table->getTableLinks() as $link) {
45 $link = $link->toArray();
46 $link['entity'] = CoreUtil
::getApiNameFromTableName($link['targetTable']);
47 $item['links'][] = $link;
55 public function fields() {
65 'data_type' => 'Array',