mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
5a786624aa
Core.php can rely on composer’s autoloader now that classes are PSR-4 compliant. If you stuck to the core modules, you could even remove ClassLoader’s autoloader, but this would break any module that hasn’t been updated to support PSR-4, so I’ve left it in. In the future, it would be good to apply SilverStripe’s auto-loader only to those modules that aren’t coded to use PSR-4, as it would make class loading more predictable.
93 lines
1.7 KiB
PHP
93 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace SilverStripe\ORM;
|
|
|
|
use ArrayAccess;
|
|
use Countable;
|
|
use IteratorAggregate;
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @return array
|
|
*/
|
|
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
|
|
* @return Map
|
|
*/
|
|
public function map($keyfield = 'ID', $titlefield = 'Title');
|
|
|
|
/**
|
|
* 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.
|
|
*
|
|
* @param string $colName
|
|
* @return array
|
|
*/
|
|
public function column($colName = "ID");
|
|
|
|
/**
|
|
* Walks the list using the specified callback
|
|
*
|
|
* @param callable $callback
|
|
* @return $this
|
|
*/
|
|
public function each($callback);
|
|
}
|