silverstripe-framework/core/ArrayData.php
Sean Harvey fdddb348c3 Fixed up strange code formatting. Now in line with coding conventions at doc.silverstripe.com/doku.php?id=coding-conventions
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@43645 467b73ca-7a2a-4603-9d3b-597d59a354a9
2007-10-20 08:36:47 +00:00

36 lines
682 B
PHP
Executable File

<?php
/**
* Lets you wrap a bunch of array data into a ViewableData object.
* This is useful when you want to pass data to a template in the "SilverStripe 1" way of giving a
* big data array.
*
* Usage:
* new ArrayData(array(
* "ClassName" => "Page",
* "AddAction" => "Add a new Page page",
* ));
*/
class ArrayData extends ViewableData {
protected $array;
public function __construct($array) {
$this->array = $array;
}
public function getField($f) {
if(is_array($this->array[$f])) {
return new ArrayData($this->array[$f]);
} else {
return $this->array[$f];
}
}
public function hasField($f) {
return isset($this->array[$f]);
}
}
?>