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

38 lines
740 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;
2016-10-14 03:30:05 +02:00
public function __construct($depth = 1)
{
parent::__construct();
$this->depth = $depth;
}
2016-10-14 03:30:05 +02:00
public function output($val)
{
return "$this->depth-$val";
}
2016-10-14 03:30:05 +02:00
public function forLoop($number)
{
$ret = array();
for ($i = 0; $i < (int)$number; ++$i) {
$ret[] = new TestObject("!$i");
}
return new ArrayList($ret);
}
2016-10-14 03:30:05 +02:00
public function forWith($number)
{
return new self($number);
}
2016-10-14 03:30:05 +02:00
}