Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
civirules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ayduns
civirules
Commits
8e78e695
Commit
8e78e695
authored
10 years ago
by
jaapjansma
Browse files
Options
Downloads
Patches
Plain Diff
created a more generic action base class and a generic api action class
parent
10a0af2a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Civirules/Action.php
+4
-58
4 additions, 58 deletions
CRM/Civirules/Action.php
CRM/CivirulesActions/Generic/Api.php
+67
-0
67 additions, 0 deletions
CRM/CivirulesActions/Generic/Api.php
CRM/CivirulesActions/GroupContact.php
+1
-1
1 addition, 1 deletion
CRM/CivirulesActions/GroupContact.php
with
72 additions
and
59 deletions
CRM/Civirules/Action.php
+
4
−
58
View file @
8e78e695
...
...
@@ -13,20 +13,12 @@ abstract class CRM_Civirules_Action {
protected
$action
=
array
();
/**
* Method to get the api entity to process in this CiviRule action
*
* @access protected
* @abstract
*/
protected
abstract
function
getApiEntity
();
/**
* Method to get the api action to process in this CiviRule action
* Process the action
*
* @
access protected
* @a
bstract
* @
param CRM_Civirules_EventData_EventData $eventData
* @a
ccess public
*/
protected
abstract
function
getApiAction
(
);
abstract
public
function
processAction
(
CRM_Civirules_EventData_EventData
$eventData
);
/**
* Method to set RuleActionData
...
...
@@ -51,52 +43,6 @@ abstract class CRM_Civirules_Action {
$this
->
action
=
$action
;
}
/**
* Returns an array with parameters used for processing an action
*
* @param array $parameters
* @param CRM_Civirules_EventData_EventData $eventData
* @return array
* @access protected
*/
protected
function
alterApiParameters
(
$parameters
,
CRM_Civirules_EventData_EventData
$eventData
)
{
//this method could be overridden in subclasses to alter parameters to meet certain criteria
return
$parameters
;
}
/**
* Process the action
*
* @param CRM_Civirules_EventData_EventData $eventData
* @access public
*/
public
function
processAction
(
CRM_Civirules_EventData_EventData
$eventData
)
{
$entity
=
$this
->
getApiEntity
();
$action
=
$this
->
getApiAction
();
$params
=
$this
->
getActionParameters
();
//alter parameters by subclass
$params
=
$this
->
alterApiParameters
(
$params
,
$eventData
);
//execute the action
$this
->
executeApiAction
(
$entity
,
$action
,
$params
);
}
/**
* Executes the action
*
* This method could be overridden if needed
*
* @param $entity
* @param $action
* @param $parameters
* @access protected
*/
protected
function
executeApiAction
(
$entity
,
$action
,
$parameters
)
{
civicrm_api3
(
$entity
,
$action
,
$parameters
);
}
/**
* Convert parameters to an array of parameters
*
...
...
This diff is collapsed.
Click to expand it.
CRM/CivirulesActions/Generic/Api.php
0 → 100644
+
67
−
0
View file @
8e78e695
<?php
abstract
class
CRM_CivirulesActions_Generic_Api
extends
CRM_Civirules_Action
{
/**
* Method to get the api entity to process in this CiviRule action
*
* @access protected
* @abstract
*/
protected
abstract
function
getApiEntity
();
/**
* Method to get the api action to process in this CiviRule action
*
* @access protected
* @abstract
*/
protected
abstract
function
getApiAction
();
/**
* Returns an array with parameters used for processing an action
*
* @param array $parameters
* @param CRM_Civirules_EventData_EventData $eventData
* @return array
* @access protected
*/
protected
function
alterApiParameters
(
$parameters
,
CRM_Civirules_EventData_EventData
$eventData
)
{
//this method could be overridden in subclasses to alter parameters to meet certain criteria
return
$parameters
;
}
/**
* Process the action
*
* @param CRM_Civirules_EventData_EventData $eventData
* @access public
*/
public
function
processAction
(
CRM_Civirules_EventData_EventData
$eventData
)
{
$entity
=
$this
->
getApiEntity
();
$action
=
$this
->
getApiAction
();
$params
=
$this
->
getActionParameters
();
//alter parameters by subclass
$params
=
$this
->
alterApiParameters
(
$params
,
$eventData
);
//execute the action
$this
->
executeApiAction
(
$entity
,
$action
,
$params
);
}
/**
* Executes the action
*
* This method could be overridden if needed
*
* @param $entity
* @param $action
* @param $parameters
* @access protected
*/
protected
function
executeApiAction
(
$entity
,
$action
,
$parameters
)
{
civicrm_api3
(
$entity
,
$action
,
$parameters
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
CRM/CivirulesActions/GroupContact.php
+
1
−
1
View file @
8e78e695
...
...
@@ -6,7 +6,7 @@
* @license AGPL-3.0
*/
class
CRM_CivirulesActions_GroupContact
extends
CRM_Civirules
_
Action
{
class
CRM_CivirulesActions_GroupContact
extends
CRM_CivirulesAction
s_Generic_Api
{
/**
* Returns an array with parameters used for processing an action
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment