silverstripe-framework/tests/php/View/SSViewerTest/LevelTestData.php

38 lines
644 B
PHP
Raw Normal View History

2016-10-14 03:30:05 +02:00
<?php
namespace SilverStripe\View\Tests\SSViewerTest;
use SilverStripe\Dev\TestOnly;
use SilverStripe\ORM\ArrayList;
use SilverStripe\View\ViewableData;
class LevelTestData extends ViewableData 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 = array();
for ($i = 0; $i < (int)$number; ++$i) {
$ret[] = new TestObject("!$i");
}
return new ArrayList($ret);
}
public function forWith($number)
{
return new self($number);
}
}