Stud.IP  trunk Revision
SimpleORMapCollection Class Reference
Inheritance diagram for SimpleORMapCollection:
Inheritance graph
Collaboration diagram for SimpleORMapCollection:
Collaboration graph

Public Member Functions

 __construct (Closure $finder=null, Array $options=null, SimpleORMap $record=null)
 
 offsetSet ($index, $newval)
 
 setClassName ($class_name)
 
 setRelatedRecord (SimpleORMap $record)
 
 getClassName ()
 
 refresh ()
 
 find ($value)
 
 toGroupedArray ($group_by='id', $only_these_fields=null, Closure $group_func=null)
 
 unsetByPk ($id)
 
 merge (SimpleCollection $a_collection)
 
- Public Member Functions inherited from SimpleCollection
 __construct ($data=[])
 
 exchangeArray ($input)
 
 toArray ()
 
 append ($newval)
 
 offsetSet ($index, $newval)
 
 offsetUnset ($index)
 
 setFinder (Closure $finder)
 
 getDeleted ()
 
 refresh ()
 
 findBy ($key, $values, $op='==')
 
 findOneBy ($key, $values, $op='==')
 
 each (Closure $func)
 
 map (Closure $func)
 
 filter (Closure $func=null, $limit=null)
 
 pluck ($columns)
 
 toGroupedArray ($group_by='id', $only_these_fields=null, Closure $group_func=null)
 
 first ()
 
 last ()
 
 val ($key)
 
 unsetBy ($key, $values, $op='==')
 
 orderBy ($order, $sort_flags=SORT_LOCALE_STRING)
 
 limit ($arg1, $arg2=null)
 
 sendMessage ($method, $params=[])
 
 __call ($method, $params)
 
 merge (SimpleCollection $a_collection)
 
- Public Member Functions inherited from StudipArrayObject
 __construct ($input=[], $flags=self::STD_PROP_LIST, $iteratorClass='ArrayIterator')
 
 __isset ($key)
 
 __set ($key, $value)
 
 __unset ($key)
 
 __get ($key)
 
 append ($value)
 
 asort ()
 
 count ()
 
 exchangeArray ($data)
 
 getArrayCopy ()
 
 getFlags ()
 
 getIterator ()
 
 getIteratorClass ()
 
 ksort ()
 
 natcasesort ()
 
 natsort ()
 
 offsetExists ($key)
 
 offsetGet ($key)
 
 offsetSet ($key, $value)
 
 offsetUnset ($key)
 
 serialize ()
 
 setFlags ($flags)
 
 setIteratorClass ($class)
 
 uasort ($function)
 
 uksort ($function)
 
 unserialize ($data)
 

Static Public Member Functions

static createFromArray (Array $data, $strict=true)
 
- Static Public Member Functions inherited from SimpleCollection
static createFromArray (Array $data)
 
static arrayToArrayObject ($a)
 
static getCompFunc ($operator, $args)
 
static translitLatin1 ($text)
 

Data Fields

const WRONG_OBJECT_TYPE = 1
 
const OBJECT_EXISTS = 2
 
- Data Fields inherited from StudipArrayObject
const STD_PROP_LIST = 1
 
const ARRAY_AS_PROPS = 2
 

Protected Attributes

 $related_record
 
 $relation_options = []
 
- Protected Attributes inherited from SimpleCollection
 $finder
 
 $last_count
 
 $deleted
 
- Protected Attributes inherited from StudipArrayObject
 $storage
 
 $flag
 
 $iteratorClass
 
 $protectedProperties
 

Additional Inherited Members

- Protected Member Functions inherited from StudipArrayObject
 validateKeyUsage ($key)
 

Constructor & Destructor Documentation

◆ __construct()

__construct ( Closure  $finder = null,
Array  $options = null,
SimpleORMap  $record = null 
)

Constructor

Parameters
Closure$findercallable to fill collection
array$optionsrelationship options
SimpleORMap$recordrelated record

Member Function Documentation

◆ createFromArray()

static createFromArray ( Array  $data,
  $strict = true 
)
static

creates a collection from an array of objects all objects should be of the same type

Exceptions
InvalidArgumentExceptionif first entry is not SimpleOrMap
Parameters
array$dataarray with SimpleORMap objects
bool$strictcheck every element for correct type and unique pk
Returns
SimpleORMapCollection
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find()

find (   $value)

returns element with given primary key value

Parameters
string$valueprimary key value to search for
Returns
SimpleORMap
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getClassName()

getClassName ( )

gets the allowed classname

Returns
string
Here is the caller graph for this function:

◆ merge()

merge ( SimpleCollection  $a_collection)

merge in another collection, elements must be of the same type, if an element already exists it is replaced or ignored depending on second param

Parameters
SimpleORMapCollection$a_collection
string$mode'replace' or 'ignore'
Here is the call graph for this function:

◆ offsetSet()

offsetSet (   $index,
  $newval 
)

Sets the value at the specified index checks if the value is an object of specified class

See also
ArrayObject::offsetSet()
Exceptions
InvalidArgumentExceptionif the given model does not fit (wrong type or id)
Here is the call graph for this function:

◆ refresh()

refresh ( )

reloads the elements of the collection by calling the finder function

Exceptions
InvalidArgumentException
Returns
number of records after refresh
Here is the call graph for this function:

◆ setClassName()

setClassName (   $class_name)

sets the allowed class name

Parameters
string$class_name

◆ setRelatedRecord()

setRelatedRecord ( SimpleORMap  $record)

sets the related record

Parameters
SimpleORMap$record

◆ toGroupedArray()

toGroupedArray (   $group_by = 'id',
  $only_these_fields = null,
Closure  $group_func = null 
)

returns the collection as grouped array first param is the column to group by, it becomes the key in the resulting array, default is pk. Limit returned fields with second param The grouped entries can optoionally go through the given callback. If no callback is provided, only the first grouped entry is returned, suitable for grouping by unique column

Parameters
string$group_bythe column to group by, pk if ommitted
mixed$only_these_fieldslimit returned fields
Closure$group_funcclosure to aggregate grouped entries
Returns
array assoc array

◆ unsetByPk()

unsetByPk (   $id)

mark element(s) for deletion element(s) with given primary key are moved to internal deleted collection

Parameters
string$idprimary key of element
Returns
number of unsetted elements
Here is the call graph for this function:
Here is the caller graph for this function:

Field Documentation

◆ $related_record

$related_record
protected

◆ $relation_options

$relation_options = []
protected

◆ OBJECT_EXISTS

const OBJECT_EXISTS = 2

◆ WRONG_OBJECT_TYPE

const WRONG_OBJECT_TYPE = 1

The documentation for this class was generated from the following file: