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
af4383db
Commit
af4383db
authored
10 years ago
by
Erik Hommel
Browse files
Options
Downloads
Patches
Plain Diff
cleanup Action and Condition classes
parent
3c7eed58
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Civirules/Action.php
+27
-3
27 additions, 3 deletions
CRM/Civirules/Action.php
CRM/Civirules/Condition.php
+20
-2
20 additions, 2 deletions
CRM/Civirules/Condition.php
with
47 additions
and
5 deletions
CRM/Civirules/Action.php
+
27
−
3
View file @
af4383db
<?php
<?php
/**
* Abstract Class for CiviRules action
*
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
abstract
class
CRM_Civirules_Action
{
abstract
class
CRM_Civirules_Action
{
...
@@ -6,6 +12,12 @@ abstract class CRM_Civirules_Action {
...
@@ -6,6 +12,12 @@ abstract class CRM_Civirules_Action {
protected
$action
=
array
();
protected
$action
=
array
();
/**
* Method to set RuleActionData
*
* @param $ruleAction
* @access public
*/
public
function
setRuleActionData
(
$ruleAction
)
{
public
function
setRuleActionData
(
$ruleAction
)
{
$this
->
ruleAction
=
array
();
$this
->
ruleAction
=
array
();
if
(
is_array
(
$ruleAction
))
{
if
(
is_array
(
$ruleAction
))
{
...
@@ -13,6 +25,12 @@ abstract class CRM_Civirules_Action {
...
@@ -13,6 +25,12 @@ abstract class CRM_Civirules_Action {
}
}
}
}
/**
* Method to set actionData
*
* @param $action
* @access public
*/
public
function
setActionData
(
$action
)
{
public
function
setActionData
(
$action
)
{
$this
->
action
=
$action
;
$this
->
action
=
$action
;
}
}
...
@@ -23,9 +41,10 @@ abstract class CRM_Civirules_Action {
...
@@ -23,9 +41,10 @@ abstract class CRM_Civirules_Action {
* @param array $parameters
* @param array $parameters
* @param CRM_Civirules_EventData_EventData $eventData
* @param CRM_Civirules_EventData_EventData $eventData
* @return array
* @return array
* @access protected
*/
*/
protected
function
alterApiParameters
(
$parameters
,
CRM_Civirules_EventData_EventData
$eventData
)
{
protected
function
alterApiParameters
(
$parameters
,
CRM_Civirules_EventData_EventData
$eventData
)
{
//this
function
could be overridden in subclasses to alter parameters to meet certain criter
a
ia
//this
method
could be overridden in subclasses to alter parameters to meet certain criteria
return
$parameters
;
return
$parameters
;
}
}
...
@@ -33,6 +52,7 @@ abstract class CRM_Civirules_Action {
...
@@ -33,6 +52,7 @@ abstract class CRM_Civirules_Action {
* Process the action
* Process the action
*
*
* @param CRM_Civirules_EventData_EventData $eventData
* @param CRM_Civirules_EventData_EventData $eventData
* @access public
*/
*/
public
function
processAction
(
CRM_Civirules_EventData_EventData
$eventData
)
{
public
function
processAction
(
CRM_Civirules_EventData_EventData
$eventData
)
{
$entity
=
$this
->
action
[
'api_entity'
];
$entity
=
$this
->
action
[
'api_entity'
];
...
@@ -50,11 +70,12 @@ abstract class CRM_Civirules_Action {
...
@@ -50,11 +70,12 @@ abstract class CRM_Civirules_Action {
/**
/**
* Executes the action
* Executes the action
*
*
* This
function
could be overriden if needed
* This
method
could be overrid
d
en if needed
*
*
* @param $entity
* @param $entity
* @param $action
* @param $action
* @param $parameters
* @param $parameters
* @access protected
*/
*/
protected
function
executeApiAction
(
$entity
,
$action
,
$parameters
)
{
protected
function
executeApiAction
(
$entity
,
$action
,
$parameters
)
{
civicrm_api3
(
$entity
,
$action
,
$parameters
);
civicrm_api3
(
$entity
,
$action
,
$parameters
);
...
@@ -64,6 +85,7 @@ abstract class CRM_Civirules_Action {
...
@@ -64,6 +85,7 @@ abstract class CRM_Civirules_Action {
* Convert parameters to an array of parameters
* Convert parameters to an array of parameters
*
*
* @return array
* @return array
* @access protected
*/
*/
protected
function
getActionParameters
()
{
protected
function
getActionParameters
()
{
$params
=
array
();
$params
=
array
();
...
@@ -80,16 +102,18 @@ abstract class CRM_Civirules_Action {
...
@@ -80,16 +102,18 @@ abstract class CRM_Civirules_Action {
*
*
* @param int $ruleActionId
* @param int $ruleActionId
* @return bool|string
* @return bool|string
* $access public
*/
*/
public
function
getExtraDataInputUrl
(
$ruleActionId
)
{
public
function
getExtraDataInputUrl
(
$ruleActionId
)
{
return
false
;
return
false
;
}
}
/**
/**
* Ret
r
uns a user friendly text explaining the condition params
* Retu
r
ns a user friendly text explaining the condition params
* e.g. 'Older than 65'
* e.g. 'Older than 65'
*
*
* @return string
* @return string
* @access public
*/
*/
public
function
userFriendlyConditionParams
()
{
public
function
userFriendlyConditionParams
()
{
return
''
;
return
''
;
...
...
This diff is collapsed.
Click to expand it.
CRM/Civirules/Condition.php
+
20
−
2
View file @
af4383db
<?php
<?php
/**
* Abstract Class for CiviRules condition
*
* @author Jaap Jansma (CiviCooP) <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
abstract
class
CRM_Civirules_Condition
{
abstract
class
CRM_Civirules_Condition
{
protected
$ruleCondition
=
array
();
protected
$ruleCondition
=
array
();
/**
* Method to set RuleConditionData
*
* @param $ruleCondition
* @access public
*/
public
function
setRuleConditionData
(
$ruleCondition
)
{
public
function
setRuleConditionData
(
$ruleCondition
)
{
$this
->
ruleCondition
=
array
();
$this
->
ruleCondition
=
array
();
if
(
is_array
(
$ruleCondition
))
{
if
(
is_array
(
$ruleCondition
))
{
...
@@ -12,10 +24,12 @@ abstract class CRM_Civirules_Condition {
...
@@ -12,10 +24,12 @@ abstract class CRM_Civirules_Condition {
}
}
/**
/**
* This
function
returns true or false when an condition is valid or not
* This
method
returns true or false when an condition is valid or not
*
*
* @param CRM_Civirules_EventData_EventData $eventData
* @param CRM_Civirules_EventData_EventData $eventData
* @return bool
* @return bool
* @access public
* @abstract
*/
*/
public
abstract
function
isConditionValid
(
CRM_Civirules_EventData_EventData
$eventData
);
public
abstract
function
isConditionValid
(
CRM_Civirules_EventData_EventData
$eventData
);
...
@@ -26,14 +40,17 @@ abstract class CRM_Civirules_Condition {
...
@@ -26,14 +40,17 @@ abstract class CRM_Civirules_Condition {
*
*
* @param int $ruleConditionId
* @param int $ruleConditionId
* @return bool|string
* @return bool|string
* @access public
* @abstract
*/
*/
abstract
public
function
getExtraDataInputUrl
(
$ruleConditionId
);
abstract
public
function
getExtraDataInputUrl
(
$ruleConditionId
);
/**
/**
* Ret
r
uns a user friendly text explaining the condition params
* Retu
r
ns a user friendly text explaining the condition params
* e.g. 'Older than 65'
* e.g. 'Older than 65'
*
*
* @return string
* @return string
* @access public
*/
*/
public
function
userFriendlyConditionParams
()
{
public
function
userFriendlyConditionParams
()
{
return
''
;
return
''
;
...
@@ -43,6 +60,7 @@ abstract class CRM_Civirules_Condition {
...
@@ -43,6 +60,7 @@ abstract class CRM_Civirules_Condition {
* Returns an array with required entity names
* Returns an array with required entity names
*
*
* @return array
* @return array
* @access public
*/
*/
public
function
requiredEntities
()
{
public
function
requiredEntities
()
{
return
array
();
return
array
();
...
...
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