Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate APIv4 into civicrm-core #15309

Merged
merged 24 commits into from
Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f2f0f5f
Obsolete api4 extension
colemanw Sep 14, 2019
f74361a
Handle new flattened custom field return format
colemanw Sep 14, 2019
0e0f741
api4 - Port PHPUnit autoloading hacks
Sep 15, 2019
f0b90b0
api4 - Add civicrm_api4() and CRM.api4() entry-points
Sep 15, 2019
caaeea3
api4 - Enable services
Sep 15, 2019
19b53e5
api4 - Import CRM/, Civi/, templates/, ang/, css/, js/, xml/menu
Sep 15, 2019
cdeee72
api4 - Adjust to new name
Sep 15, 2019
e96f62c
api4 - Update test init
Sep 15, 2019
23c2d07
Search for entity-specific actions in core
colemanw Sep 15, 2019
bd2669e
Scan core as well as extensions for api4 entities & services
colemanw Sep 15, 2019
a2fa26f
(NFC) Pass both civilint and ReflectionUtilsTest
totten Sep 15, 2019
235e322
api4 - Fix computation of core path
totten Sep 15, 2019
c1e9641
api4 - Fix container cache/reload behavior
totten Sep 15, 2019
425c975
api4 - Search for entities in core (for realz)
totten Sep 15, 2019
2c07402
Test fixes
colemanw Sep 16, 2019
1d10c3c
Update namespace for phpunit6 compat
colemanw Sep 16, 2019
cddf293
Api4 generated code improvements
colemanw Sep 16, 2019
0b873c9
Fix api explorer module loading
colemanw Sep 16, 2019
13e9117
Add api4 menu item
colemanw Sep 17, 2019
1938279
composer.json - Add "ignore" list for js-yaml
totten Sep 18, 2019
d20bb06
distmaker - Remove steps to download api4 as extension
totten Sep 18, 2019
2e704b9
api4 - Update civicrm_generated.mysql for new nav item
totten Sep 20, 2019
6872a65
Fix number fields in api explorer
colemanw Sep 22, 2019
6f97b1d
Remove extension-specific ts()
colemanw Sep 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 44 additions & 20 deletions CRM/Upgrade/Incremental/php/FiveNineteen.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,27 +61,51 @@ public function setPostUpgradeMessage(&$postUpgradeMessage, $rev) {
// }
}

/*
* Important! All upgrade functions MUST add a 'runSql' task.
* Uncomment and use the following template for a new upgrade version
* (change the x in the function name):
/**
* Upgrade function.
*
* @param string $rev
*/
public function upgrade_5_19_alpha1($rev) {
$this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
$this->addTask('Add api4 menu', 'api4Menu');
}

// /**
// * Upgrade function.
// *
// * @param string $rev
// */
// public function upgrade_5_0_x($rev) {
// $this->addTask(ts('Upgrade DB to %1: SQL', [1 => $rev]), 'runSql', $rev);
// $this->addTask('Do the foo change', 'taskFoo', ...);
// // Additional tasks here...
// // Note: do not use ts() in the addTask description because it adds unnecessary strings to transifex.
// // The above is an exception because 'Upgrade DB to %1: SQL' is generic & reusable.
// }

// public static function taskFoo(CRM_Queue_TaskContext $ctx, ...) {
// return TRUE;
// }
/**
* Add menu item for api4 explorer; rename v3 explorer menu item.
*
* @param \CRM_Queue_TaskContext $ctx
* @return bool
*/
public static function api4Menu(CRM_Queue_TaskContext $ctx) {
try {
$v3Item = civicrm_api3('Navigation', 'get', [
'name' => 'API Explorer',
'return' => ['id', 'parent_id', 'weight'],
'sequential' => 1,
'domain_id' => CRM_Core_Config::domainID(),
'api.Navigation.create' => ['label' => ts("Api Explorer v3")],
]);
$existing = civicrm_api3('Navigation', 'getcount', [
'name' => "Api Explorer v4",
'domain_id' => CRM_Core_Config::domainID(),
]);
if (!$existing) {
civicrm_api3('Navigation', 'create', [
'parent_id' => $v3Item['values'][0]['parent_id'] ?? 'Developer',
'label' => ts("Api Explorer v4"),
'weight' => $v3Item['values'][0]['weight'] ?? 2,
'name' => "Api Explorer v4",
'permission' => "administer CiviCRM",
'url' => "civicrm/api4#/explorer",
'is_active' => 1,
]);
}
}
catch (Exception $e) {
// Couldn't create menu item.
}
return TRUE;
}

}
3 changes: 2 additions & 1 deletion xml/templates/civicrm_navigation.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,8 @@ SET @devellastID:=LAST_INSERT_ID();
INSERT INTO civicrm_navigation
( domain_id, url, label, name, permission, permission_operator, parent_id, is_active, has_separator, weight )
VALUES
( @domainID, 'civicrm/api', '{ts escape="sql" skip="true"}API Explorer{/ts}','API Explorer', 'administer CiviCRM', '', @devellastID, '1', NULL, 1 ),
( @domainID, 'civicrm/api', '{ts escape="sql" skip="true"}Api Explorer v3{/ts}', 'API Explorer', 'administer CiviCRM', '', @devellastID, '1', NULL, 1 ),
( @domainID, 'civicrm/api4#/explorer', '{ts escape="sql" skip="true"}Api Explorer v4{/ts}', 'Api Explorer v4', 'administer CiviCRM', '', @devellastID, '1', NULL, 2 ),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before we merge, I think we'll need to regenerate civicrm_generated.mysql. (But I think it's OK if that waits until the "WIP" flag is done.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@totten could you generate that file pls?

( @domainID, 'https://civicrm.org/developer-documentation?src=iam', '{ts escape="sql" skip="true"}Developer Docs{/ts}', 'Developer Docs', 'administer CiviCRM', '', @devellastID, '1', NULL, 3 );

INSERT INTO civicrm_navigation
Expand Down