silverstripe-framework/tests/php/View/SSViewerTest/LevelTestData.php
Guy Sartorelli e2e32317d6
API Move various classes to more appropriate namespaces (#11370)
Also rename ViewableData to ModelData ahead of the template layer
lift-and-shift
2024-09-23 14:31:50 +12:00

38 lines
746 B
PHP

<?php
namespace SilverStripe\View\Tests\SSViewerTest;
use SilverStripe\Dev\TestOnly;
use SilverStripe\Model\List\ArrayList;
use SilverStripe\Model\ModelData;
class LevelTestData extends ModelData implements TestOnly
{
protected $depth;
public function __construct($depth = 1)
{
parent::__construct();
$this->depth = $depth;
}
public function output($val)
{
return "$this->depth-$val";
}
public function forLoop($number)
{
$ret = [];
for ($i = 0; $i < (int)$number; ++$i) {
$ret[] = new TestObject("!$i");
}
return new ArrayList($ret);
}
public function forWith($number)
{
return new LevelTestData($number);
}
}