Newer
Older
<?php
namespace Civi\ActionProvider\Parameter;
use \Civi\ActionProvider\Parameter\ParameterBagInterface;
class ParameterBag implements ParameterBagInterface, \IteratorAggregate {
/**
* Get the parameter.
*/
public function getParameter($name) {
if (isset($this->parameters[$name])) {
return $this->parameters[$name];
}
return null;
/**
* Tests whether the parameter with the name exists.
*/
public function doesParameterExists($name) {
* Sets parameter.
*/
public function setParameter($name, $value) {
$this->parameters[$name] = $value;
}
public function getIterator() {
return new \ArrayIterator($this->parameters);
}
/**
* Converts the object to an array.
* @return array
*/
public function toArray() {
return $this->parameters;
}
/**
* @param array $data
*
* @return \Civi\ActionProvider\Parameter\ParameterBag
*/
public function fromArray($data, SpecificationBag $specificationBag=null) {
$spec = null;
if ($specificationBag) {
$spec = $specificationBag->getSpecificationByName($key);
}
if ($spec && $spec->isMultiple() && !is_array($val)) {
$val = explode(",", $val);
}