| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
// Disallow direct access. |
| 7 |
defined('ABSPATH') or die("Access denied"); |
| 8 |
|
| 9 |
/** |
| 10 |
* |
| 11 |
*/ |
| 12 |
abstract class CJT_Framework_Developer_Interface_Block_Parameters_Parameters { |
| 13 |
|
| 14 |
/** |
| 15 |
* put your comment there... |
| 16 |
* |
| 17 |
* @var mixed |
| 18 |
*/ |
| 19 |
protected $contentParameter = null; |
| 20 |
|
| 21 |
/** |
| 22 |
* put your comment there... |
| 23 |
* |
| 24 |
* @var mixed |
| 25 |
*/ |
| 26 |
protected $params = array(); |
| 27 |
|
| 28 |
/** |
| 29 |
* put your comment there... |
| 30 |
* |
| 31 |
* @param mixed $parameters |
| 32 |
* @param mixed $fatory |
| 33 |
* @return CJT_Framework_Developer_Interface_Block_Parameters_Parameters |
| 34 |
*/ |
| 35 |
public function __construct($parameters) { |
| 36 |
// Validate parameters. |
| 37 |
foreach ($parameters as $parameter) { |
| 38 |
// Create type object. |
| 39 |
$parameterModel = $this->params[$parameter->getName(true)] = $this->getFactory()->create($parameter->getType(), $parameter); |
| 40 |
// Hold reference to the CONTENT PARAMETER. |
| 41 |
$parameter->getContentParameter() && ($this->contentParameter = $parameterModel); |
| 42 |
} |
| 43 |
} |
| 44 |
|
| 45 |
/** |
| 46 |
* put your comment there... |
| 47 |
* |
| 48 |
*/ |
| 49 |
public function getContentParameter() { |
| 50 |
return $this->contentParameter; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* put your comment there... |
| 55 |
* |
| 56 |
*/ |
| 57 |
protected abstract function getFactory(); |
| 58 |
|
| 59 |
/** |
| 60 |
* put your comment there... |
| 61 |
* |
| 62 |
*/ |
| 63 |
public function & getParams() { |
| 64 |
return $this->params; |
| 65 |
} |
| 66 |
|
| 67 |
/** |
| 68 |
* put your comment there... |
| 69 |
* |
| 70 |
*/ |
| 71 |
public function getMessages() { |
| 72 |
|
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* put your comment there... |
| 77 |
* |
| 78 |
*/ |
| 79 |
public function hasParams() { |
| 80 |
return !empty($this->params); |
| 81 |
} |
| 82 |
|
| 83 |
/** |
| 84 |
* put your comment there... |
| 85 |
* |
| 86 |
* @param mixed $values |
| 87 |
*/ |
| 88 |
public function setValue($values) { |
| 89 |
foreach ($this->getParams() as $name => $param) { |
| 90 |
if (isset($values[$name])) { |
| 91 |
$param->setValue($values[$name]); |
| 92 |
} |
| 93 |
} |
| 94 |
return $this; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* put your comment there... |
| 99 |
* |
| 100 |
*/ |
| 101 |
public function validate() { |
| 102 |
return true; |
| 103 |
} |
| 104 |
|
| 105 |
} // End class. |