2012-02-11 03:26:26 +01:00
|
|
|
<?php
|
2016-08-19 00:51:35 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\View;
|
|
|
|
|
2012-02-11 03:26:26 +01:00
|
|
|
/**
|
2015-07-28 18:57:56 +02:00
|
|
|
* Interface that is implemented by any classes that want to expose a method that can be called in any
|
2012-09-26 23:34:00 +02:00
|
|
|
* scope in a template that returns values dependant on the state of the iterator of the current scope.
|
2012-02-21 01:36:34 +01:00
|
|
|
*
|
2012-02-11 03:26:26 +01:00
|
|
|
* SSViewer_BasicIteratorSupport is an example of this. See also @TemplateGlobalProvider
|
|
|
|
*/
|
|
|
|
interface TemplateIteratorProvider {
|
2012-02-21 01:36:34 +01:00
|
|
|
|
2012-02-11 03:26:26 +01:00
|
|
|
/**
|
2012-09-26 23:34:00 +02:00
|
|
|
* Called by SSViewer to get a list of iterator variables to expose to the template, the instance method to call
|
|
|
|
* on an instance of this class to get the value for those variables, and the class to use for casting the returned
|
|
|
|
* value for use in a template
|
2012-02-21 01:36:34 +01:00
|
|
|
*
|
2012-09-26 23:34:00 +02:00
|
|
|
* If the method to call is not included for a particular template variable, a method named the same as the
|
|
|
|
* template variable will be called
|
2012-02-21 01:36:34 +01:00
|
|
|
*
|
|
|
|
* If the casting class is not specified for a particular template variable, ViewableData::$default_cast is used
|
|
|
|
*
|
|
|
|
* The first letter of the template variable is case-insensitive. However the method name is always case sensitive.
|
|
|
|
*
|
2012-02-11 03:26:26 +01:00
|
|
|
* @abstract
|
2012-02-21 01:36:34 +01:00
|
|
|
* @return array Returns an array of items. Each key => value pair is one of three forms:
|
|
|
|
* - template name (no key)
|
|
|
|
* - template name => method name
|
|
|
|
* - template name => array(), where the array can contain these key => value pairs
|
|
|
|
* - "method" => method name
|
2016-06-03 10:51:02 +02:00
|
|
|
* - "casting" => casting class to use (i.e., Varchar, HTMLFragment, etc)
|
2012-02-11 03:26:26 +01:00
|
|
|
*/
|
2012-02-21 01:36:34 +01:00
|
|
|
public static function get_template_iterator_variables();
|
2012-02-11 03:26:26 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the current iterator properties - where we are on the iterator.
|
2012-02-21 01:36:34 +01:00
|
|
|
*
|
|
|
|
* This is called by SSViewer prior to calling any of the variables exposed to the template (that is, as returned
|
|
|
|
* from a call to get_template_iterator_variables)
|
|
|
|
*
|
2012-02-11 03:26:26 +01:00
|
|
|
* @abstract
|
|
|
|
* @param int $pos position in iterator
|
|
|
|
* @param int $totalItems total number of items
|
|
|
|
*/
|
|
|
|
public function iteratorProperties($pos, $totalItems);
|
|
|
|
}
|
|
|
|
|