Stud.IP  2.4 Revision 48548
 All Data Structures Namespaces Files Functions Variables Groups Pages
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)
 append ($value)
 offsetSet ($index, $newval)
 offsetUnset ($index)
 setFinder (Closure $finder)
 setClassName ($class_name)
 setRelatedRecord (SimpleORMap $record)
 getClassName ()
 getDeleted ()
 refresh ()
 sendMessage ($method, $params=array())
 find ($value)
 findBy ($key, $values)
 each (Closure $func)
 map (Closure $func)
 filter (Closure $func=null)
 pluck ($columns)
 toGroupedArray ($group_by= 'id', $only_these_fields=null, Closure $group_func=null)
 first ()
 last ()
 val ($key)
 unsetByPk ($id)
 unsetBy ($key, $values)

Static Public Member Functions

static createFromArray (Array $data)

Protected Attributes

 $related_record
 $relation_options = array()
 $finder
 $last_count
 $deleted

Constructor & Destructor Documentation

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

Constructor

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

Here is the call graph for this function:

Member Function Documentation

append (   $value)
See Also
ArrayObject::append()

Here is the call graph for this function:

static createFromArray ( Array  $data)
static

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

Parameters
array$dataarray with SimpleORMap objects
Returns
SimpleORMapCollection

Here is the caller graph for this function:

each ( Closure  $func)

apply given callback to all elements of collection

Parameters
Closure$functhe function to call
Returns
int addition of return values
filter ( Closure  $func = null)

filter elements if given callback returns true

Parameters
Closure$functhe function to call
Returns
SimpleORMapCollection containing filtered elements

Here is the call graph for this function:

Here is the caller graph for this function:

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:

findBy (   $key,
  $values 
)

returns a new collection containing all elements where given column has given value(s) pass array or space-delimited string for multiple values

Parameters
string$keythe column name
mixed$valuevalue to search for,
Returns
SimpleORMapCollection with found records

Here is the call graph for this function:

Here is the caller graph for this function:

first ( )

get the first element

Returns
SimpleORMap first element or null
getClassName ( )

gets the allowed classname

Returns
string

Here is the caller graph for this function:

getDeleted ( )

get deleted records collection

Returns
SimpleORMapCollection
last ( )

get the last element

Returns
SimpleORMap last element or null
map ( Closure  $func)

apply given callback to all elements of collection and give back array of return values

Parameters
Closure$functhe function to call
Returns
array
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:

Here is the caller graph for this function:

offsetUnset (   $index)

Unsets the value at the specified index value is moved to internal deleted collection

See Also
ArrayObject::offsetUnset()
Exceptions
InvalidArgumentException
pluck (   $columns)

extract array of columns values pass array or space-delimited string for multiple columns

Parameters
string | array$columnsthe column(s) to extract
Returns
array of extracted values

Here is the call graph for this function:

refresh ( )

reloads the elements of the collection by calling the finder function

Exceptions
Exception
Returns
number of records after refresh

Here is the call graph for this function:

Here is the caller graph for this function:

sendMessage (   $method,
  $params = array() 
)

calls the given method on all elements of the collection

Parameters
string$methodmethodname to call
array$paramsparameters for methodcall
Returns
array of all return values
setClassName (   $class_name)

sets the allowed class name

Parameters
string$class_name
setFinder ( Closure  $finder)

sets the finder function

Parameters
Closure$finder
setRelatedRecord ( SimpleORMap  $record)

sets the related record

Parameters
SimpleORMap$record
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
unsetBy (   $key,
  $values 
)

mark element(s) for deletion where given column has given value(s) pass array or space-delimited string for multiple values element(s) are moved to internal deleted collection

Parameters
string$key
mixed$values
Returns
number of unsetted elements

Here is the call graph for this function:

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
val (   $key)

get the the value from given key from first element

Returns
mixed

Field Documentation

$deleted
protected
$finder
protected
$last_count
protected
$related_record
protected
$relation_options = array()
protected

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