3408fea35be52113567bf5f1ca100d51a036dcf8
[civicrm-core.git] / Civi / Api4 / Action / Entity / GetLinks.php
1 <?php
2
3 /*
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
6 | |
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 +--------------------------------------------------------------------+
11 */
12
13 namespace Civi\Api4\Action\Entity;
14
15 use Civi\Api4\Utils\CoreUtil;
16
17 /**
18 * Get a list of FK links between entities.
19 *
20 * This action is deprecated; the API no longer uses these links to determine available joins.
21 * @deprecated
22 */
23 class GetLinks extends \Civi\Api4\Generic\BasicGetAction {
24
25 public function getRecords() {
26 \CRM_Core_Error::deprecatedWarning('APIv4 Entity::getLinks is deprecated.');
27 $result = [];
28 $schema = CoreUtil::getSchemaMap();
29 foreach ($schema->getTables() as $table) {
30 $entity = CoreUtil::getApiNameFromTableName($table->getName());
31 // Since this is an api function, exclude tables that don't have an api
32 if ($entity) {
33 $item = [
34 'entity' => $entity,
35 'table' => $table->getName(),
36 'links' => [],
37 ];
38 foreach ($table->getTableLinks() as $link) {
39 if (!$link->isDeprecated()) {
40 $item['links'][] = $link->toArray();
41 }
42 }
43 $result[] = $item;
44 }
45 }
46 return $result;
47 }
48
49 public function fields() {
50 return [
51 [
52 'name' => 'entity',
53 ],
54 [
55 'name' => 'table',
56 ],
57 [
58 'name' => 'links',
59 'data_type' => 'Array',
60 ],
61 ];
62 }
63
64 }