Commit 9b1e23c9 authored by jaapjansma's avatar jaapjansma

Added two extra conditions

parent bd6cf679
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\ActionProvider\Condition;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use \Civi\ActionProvider\Parameter\ParameterBag;
use Civi\ActionProvider\Parameter\Specification;
use \Civi\ActionProvider\Parameter\SpecificationBag;
use CRM_ActionProvider_ExtensionUtil as E;
class ParametersDontMatch extends AbstractCondition {
/**
* @param \Civi\ActionProvider\Parameter\ParameterBagInterface $parameterBag
*
* @return bool
*/
public function isConditionValid(ParameterBagInterface $parameterBag) {
$parameter1 = $parameterBag->getParameter('parameter1');
$parameter2 = $parameterBag->getParameter('parameter2');
if ($parameter1 == $parameter2) {
return false;
}
return true;
}
/**
* Returns the specification of the configuration options for the actual condition.
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag(array());
}
/**
* Returns the specification of the parameters of the actual condition.
*
* @return SpecificationBag
*/
public function getParameterSpecification() {
return new SpecificationBag(array(
new Specification('parameter1', 'String', E::ts('Parameter 1')),
new Specification('parameter2', 'String', E::ts('Parameter 2')),
));
}
/**
* Returns the human readable title of this condition
*/
public function getTitle() {
return E::ts('Parameters don\'t match');
}
}
\ No newline at end of file
<?php
/**
* @author Jaap Jansma <jaap.jansma@civicoop.org>
* @license AGPL-3.0
*/
namespace Civi\ActionProvider\Condition;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
use \Civi\ActionProvider\Parameter\ParameterBag;
use Civi\ActionProvider\Parameter\Specification;
use \Civi\ActionProvider\Parameter\SpecificationBag;
use CRM_ActionProvider_ExtensionUtil as E;
class ParametersMatch extends AbstractCondition {
/**
* @param \Civi\ActionProvider\Parameter\ParameterBagInterface $parameterBag
*
* @return bool
*/
public function isConditionValid(ParameterBagInterface $parameterBag) {
$parameter1 = $parameterBag->getParameter('parameter1');
$parameter2 = $parameterBag->getParameter('parameter2');
if ($parameter1 == $parameter2) {
return true;
}
return false;
}
/**
* Returns the specification of the configuration options for the actual condition.
*
* @return SpecificationBag
*/
public function getConfigurationSpecification() {
return new SpecificationBag(array());
}
/**
* Returns the specification of the parameters of the actual condition.
*
* @return SpecificationBag
*/
public function getParameterSpecification() {
return new SpecificationBag(array(
new Specification('parameter1', 'String', E::ts('Parameter 1')),
new Specification('parameter2', 'String', E::ts('Parameter 2')),
));
}
/**
* Returns the human readable title of this condition
*/
public function getTitle() {
return E::ts('Parameters match');
}
}
\ No newline at end of file
......@@ -84,6 +84,8 @@ class Provider {
new \Civi\ActionProvider\Condition\ParameterIsEmpty(),
new \Civi\ActionProvider\Condition\ParameterIsNotEmpty(),
new \Civi\ActionProvider\Condition\ParameterHasValue(),
new \Civi\ActionProvider\Condition\ParametersMatch(),
new \Civi\ActionProvider\Condition\ParametersDontMatch(),
);
foreach($actions as $action) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment