Exemplo n.º 1
0
 /**
  * Applies the result of the callback
  *
  * @param callback $callback A callback function
  * @param mixed $targetName  A fieldname or array of field names set to the output of the function
  * @param mixed $targetKey   Optional fields set by callback, otherwise callback should return array
  * @param mixed $sourceName  Optional parameter input names for the callback, passed in order
  * @throws \MUtil\Model\Dependency\DependencyException
  */
 public function __construct($callback, $targetName, $targetKey = null, $sourceName = null)
 {
     if (!is_callable($callback)) {
         throw new DependencyException(__CLASS__ . " requires a valid callback.");
     }
     $this->_callback = $callback;
     $this->_dependentOn = $sourceName;
     if (is_array($targetName)) {
         $this->_effecteds = array_fill_keys($targetName, (array) $targetKey);
     } else {
         $this->_effecteds[$targetName] = (array) $targetKey;
     }
     parent::__construct();
 }
Exemplo n.º 2
0
 /**
  *
  * @param array $switches
  */
 public function __construct(array $switches = null)
 {
     parent::__construct();
     if ($switches) {
         $this->addSwitches($switches);
     }
 }