-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21106 from eileenmcnaughton/order
dev/core#2634 Add v4 Membership api, access it via order
- Loading branch information
Showing
12 changed files
with
292 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\Api4; | ||
|
||
/** | ||
* Membership entity. | ||
* | ||
* @searchable primary | ||
* @since 5.42 | ||
* @package Civi\Api4 | ||
*/ | ||
class Membership extends Generic\DAOEntity { | ||
use Generic\Traits\OptionList; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\Api4; | ||
|
||
/** | ||
* MembershipBlock entity. | ||
* | ||
* @searchable secondary | ||
* @since 5.42 | ||
* @package Civi\Api4 | ||
*/ | ||
class MembershipBlock extends Generic\DAOEntity { | ||
use Generic\Traits\OptionList; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
namespace Civi\Api4; | ||
|
||
/** | ||
* MembershipStatus entity. | ||
* | ||
* @searchable secondary | ||
* @since 5.42 | ||
* @package Civi\Api4 | ||
*/ | ||
class MembershipStatus extends Generic\DAOEntity { | ||
use Generic\Traits\OptionList; | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
Civi/Api4/Service/Spec/Provider/MembershipCreationSpecProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
/* | ||
+--------------------------------------------------------------------+ | ||
| Copyright CiviCRM LLC. All rights reserved. | | ||
| | | ||
| This work is published under the GNU AGPLv3 license with some | | ||
| permitted exceptions and without any warranty. For full license | | ||
| and copyright information, see https://civicrm.org/licensing | | ||
+--------------------------------------------------------------------+ | ||
*/ | ||
|
||
namespace Civi\Api4\Service\Spec\Provider; | ||
|
||
use Civi\Api4\Service\Spec\FieldSpec; | ||
use Civi\Api4\Service\Spec\RequestSpec; | ||
|
||
class MembershipCreationSpecProvider implements Generic\SpecProviderInterface { | ||
|
||
/** | ||
* @param \Civi\Api4\Service\Spec\RequestSpec $spec | ||
*/ | ||
public function modifySpec(RequestSpec $spec): void { | ||
$spec->getFieldByName('status_id')->setRequired(FALSE); | ||
// This is a bit of dark-magic - the membership BAO code is particularly | ||
// nasty. It has a lot of logic in it that does not belong there in | ||
// terms of our current expectations. Removing it is difficult | ||
// so the plan is that new api v4 membership.create users will either | ||
// use the Order api flow when financial code should kick in. Otherwise | ||
// the crud flow will bypass all the financial processing in membership.create. | ||
// The use of the 'version' parameter to drive this is to be sure that | ||
// we know the bypass will not affect the v3 api to the extent | ||
// it cannot be reached by the v3 api at all (in time we can move some | ||
// of the code we are deprecating into the v3 api, to die of natural deprecation). | ||
$spec->addFieldSpec(new FieldSpec('version', 'Membership', 'Integer')); | ||
$spec->getFieldByName('version')->setDefaultValue(4)->setRequired(TRUE); | ||
} | ||
|
||
/** | ||
* When does this apply. | ||
* | ||
* @param string $entity | ||
* @param string $action | ||
* | ||
* @return bool | ||
*/ | ||
public function applies($entity, $action): bool { | ||
return $entity === 'Membership' && $action === 'create'; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.