2011-04-19 09:03:23 +02:00
|
|
|
<?php
|
2016-06-15 06:03:16 +02:00
|
|
|
|
|
|
|
namespace SilverStripe\ORM;
|
|
|
|
|
|
|
|
use ArrayAccess;
|
|
|
|
use Countable;
|
|
|
|
use IteratorAggregate;
|
|
|
|
|
2011-04-19 09:03:23 +02:00
|
|
|
/**
|
|
|
|
* An interface that a class can implement to be treated as a list container.
|
|
|
|
*/
|
|
|
|
interface SS_List extends ArrayAccess, Countable, IteratorAggregate {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns all the items in the list in an array.
|
|
|
|
*
|
2015-05-18 00:24:24 +02:00
|
|
|
* @return array
|
2011-04-19 09:03:23 +02:00
|
|
|
*/
|
|
|
|
public function toArray();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the contents of the list as an array of maps.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function toNestedArray();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds an item to the list, making no guarantees about where it will
|
|
|
|
* appear.
|
|
|
|
*
|
|
|
|
* @param mixed $item
|
|
|
|
*/
|
|
|
|
public function add($item);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Removes an item from the list.
|
|
|
|
*
|
|
|
|
* @param mixed $item
|
|
|
|
*/
|
|
|
|
public function remove($item);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the first item in the list.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function first();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the last item in the list.
|
|
|
|
*
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function last();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a map of a key field to a value field of all the items in the
|
|
|
|
* list.
|
|
|
|
*
|
|
|
|
* @param string $keyfield
|
|
|
|
* @param string $titlefield
|
2016-01-21 21:29:53 +01:00
|
|
|
* @return SS_Map
|
2011-04-19 09:03:23 +02:00
|
|
|
*/
|
2011-10-22 15:42:46 +02:00
|
|
|
public function map($keyfield = 'ID', $titlefield = 'Title');
|
2011-04-19 09:03:23 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the first item in the list where the key field is equal to the
|
|
|
|
* value.
|
|
|
|
*
|
|
|
|
* @param string $key
|
|
|
|
* @param mixed $value
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function find($key, $value);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns an array of a single field value for all items in the list.
|
|
|
|
*
|
2011-12-07 02:35:30 +01:00
|
|
|
* @param string $colName
|
2011-04-19 09:03:23 +02:00
|
|
|
* @return array
|
|
|
|
*/
|
2011-10-22 15:42:46 +02:00
|
|
|
public function column($colName = "ID");
|
2014-08-15 08:53:05 +02:00
|
|
|
|
2012-11-03 02:14:04 +01:00
|
|
|
/**
|
|
|
|
* Walks the list using the specified callback
|
|
|
|
*
|
|
|
|
* @param callable $callback
|
2016-08-19 00:51:35 +02:00
|
|
|
* @return $this
|
2012-11-03 02:14:04 +01:00
|
|
|
*/
|
|
|
|
public function each($callback);
|
2012-03-24 04:04:52 +01:00
|
|
|
}
|