Jarves\Configuration\Model::fromArray PHP Method

fromArray() public method

public fromArray ( mixed $values, string $arrayKeyValue = null )
$values mixed
$arrayKeyValue string
    public function fromArray($values, $arrayKeyValue = null)
    {
        if ($this->arrayKey && null !== $arrayKeyValue) {
            $this->setArrayKeyValue($arrayKeyValue);
        }
        if (!is_array($values)) {
            if (null !== $this->nodeValueVar) {
                $setter = 'set' . ucfirst($this->nodeValueVar);
                if (method_exists($this, $setter)) {
                    $this->{$setter}($values);
                }
            }
        } else {
            foreach ($values as $key => $value) {
                $this->propertyFromArray($key, $value);
            }
        }
    }

Usage Example

Example #1
0
 /**
  * @param array $values
  * @param string $key
  */
 public function fromArray($values, $key = null)
 {
     parent::fromArray($values, $key);
     if (is_string($key)) {
         $this->setId($key);
     }
 }