silverstripe-framework/tests/php/View/SSTemplateEngineTest/LevelTestData.php
Guy Sartorelli d18c931ecf
API Refactor template layer into its own module
Includes the following large-scale changes:
- Impoved barrier between model and view layers
- Improved casting of scalar to relevant DBField types
- Improved capabilities for rendering arbitrary data in templates
2024-10-22 16:15:39 +13:00

38 lines
754 B
PHP

<?php
namespace SilverStripe\View\Tests\SSTemplateEngineTest;
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);
}
}