RampageObject
in package
implements
Rampage
Tags
Interfaces, Classes, Traits and Enums
Table of Contents
- $fields : array<string|int, mixed>
- This object's fields.
- $mapper : Mapper
- The Mapper instance associated with this Rdo object. The Mapper takes care of all backend access.
- __clone() : mixed
- When Rdo objects are cloned, unset the unique id that identifies them so that they can be modified and saved to the backend as new objects. If you don't really want a new object, don't clone.
- __construct() : mixed
- Constructor. Can be called directly by a programmer, or is called in Mapper::map(). Takes an associative array of initial object values.
- __get() : mixed
- Fetch fields that haven't yet been loaded. Lazy-loaded fields and lazy-loaded relationships are handled this way. Once a field is retrieved, it is cached in the $fields array so it doesn't need to be fetched again.
- __isset() : mixed
- Allow using isset($rdo->foo) to check for field or relationship presence.
- __set() : mixed
- Set a field's value.
- __unset() : mixed
- Allow using unset($rdo->foo) to unset a basic field. Relationships cannot be unset in this way.
- addRelation() : mixed
- Adds a relation to one of the relationships defined in the mapper.
- getIterator() : Iterator
- Implement the IteratorAggregate interface. Looping over an Rdo object goes through each property of the object in turn.
- getMapper() : Mapper
- Get a Mapper instance that can be used to manage this object. The Mapper instance can come from a few places:
- hasRelation() : bool
- Checks whether a relation to a peer is defined through one of the relationships in the mapper.
- offsetExists() : mixed
- Implements isset() for ArrayAccess interface.
- offsetGet() : mixed
- Implements getter for ArrayAccess interface.
- offsetSet() : mixed
- Implements setter for ArrayAccess interface.
- offsetUnset() : mixed
- Implements unset() for ArrayAccess interface.
- removeRelation() : int
- Removes a relation to one of the relationships defined in the mapper.
- setFields() : mixed
- Set field values for the object
- setIterator() : mixed
- Change the default iterator
- setMapper() : mixed
- Associate this Rdo object with the Mapper instance that will manage it. Called automatically by Mapper:map().
- toArray() : array<string|int, mixed>
- Converts the entity to an Array.
- _fillPlaceholders() : array<string|int, mixed>
- Take a query array and replace @field@ placeholders with values from this object.
Properties
$fields
This object's fields.
protected
array<string|int, mixed>
$fields
= []
$mapper
The Mapper instance associated with this Rdo object. The Mapper takes care of all backend access.
protected
Mapper
$mapper
Tags
Methods
__clone()
When Rdo objects are cloned, unset the unique id that identifies them so that they can be modified and saved to the backend as new objects. If you don't really want a new object, don't clone.
public
__clone() : mixed
Return values
mixed —__construct()
Constructor. Can be called directly by a programmer, or is called in Mapper::map(). Takes an associative array of initial object values.
public
__construct([array<string|int, mixed> $fields = [] ][, string $iterator = '' ]) : mixed
Parameters
- $fields : array<string|int, mixed> = []
-
Initial values for the new object.
- $iterator : string = ''
Tags
Return values
mixed —__get()
Fetch fields that haven't yet been loaded. Lazy-loaded fields and lazy-loaded relationships are handled this way. Once a field is retrieved, it is cached in the $fields array so it doesn't need to be fetched again.
public
__get(string $field) : mixed
Parameters
- $field : string
-
The name of the field to access.
Return values
mixed —The value of $field or null.
__isset()
Allow using isset($rdo->foo) to check for field or relationship presence.
public
__isset(string $field) : mixed
Parameters
- $field : string
-
The field name to check existence of.
Return values
mixed —__set()
Set a field's value.
public
__set(string $field, mixed $value) : mixed
Parameters
- $field : string
-
The field to set
- $value : mixed
-
The field's new value
Return values
mixed —__unset()
Allow using unset($rdo->foo) to unset a basic field. Relationships cannot be unset in this way.
public
__unset(string $field) : mixed
Parameters
- $field : string
-
The field name to unset.
Return values
mixed —addRelation()
Adds a relation to one of the relationships defined in the mapper.
public
addRelation(string $relationship, Rampage $peer) : mixed
- For one-to-one relations, simply updates the relation field.
- For one-to-many relations, updates the related object's relation field.
- For many-to-many relations, adds an entry in the "through" table.
- Performs a no-op if the peer is already related.
This is a proxy to the mapper's addRelation() method.
Parameters
- $relationship : string
-
The relationship key in the mapper.
- $peer : Rampage
-
The object to add the relation.
Tags
Return values
mixed —getIterator()
Implement the IteratorAggregate interface. Looping over an Rdo object goes through each property of the object in turn.
public
getIterator() : Iterator
Return values
Iterator —The Iterator instance.
getMapper()
Get a Mapper instance that can be used to manage this object. The Mapper instance can come from a few places:
public
getMapper() : Mapper
-
If the class <RdoClassName>Mapper exists, it will be used automatically.
-
Any Rdo instance created with Mapper::map() will have a $mapper object set automatically.
-
Subclasses can override getMapper() to return the correct mapper object.
-
The programmer can call $rdoObject->setMapper($mapper) to provide a mapper object.
A RdoException will be thrown if none of these conditions are met.
Return values
Mapper —The Mapper instance managing this object.
hasRelation()
Checks whether a relation to a peer is defined through one of the relationships in the mapper.
public
hasRelation(string $relationship[, Rampage $peer = null ]) : bool
Parameters
- $relationship : string
-
The relationship key in the mapper.
- $peer : Rampage = null
-
The object to check for the relation. If this is null, check if there is any peer for this relation.
Tags
Return values
bool —True if related.
offsetExists()
Implements isset() for ArrayAccess interface.
public
offsetExists(mixed $field) : mixed
Parameters
- $field : mixed
Tags
Return values
mixed —offsetGet()
Implements getter for ArrayAccess interface.
public
offsetGet(mixed $field) : mixed
Parameters
- $field : mixed
Tags
Return values
mixed —offsetSet()
Implements setter for ArrayAccess interface.
public
offsetSet(mixed $field, mixed $value) : mixed
Parameters
- $field : mixed
- $value : mixed
Tags
Return values
mixed —offsetUnset()
Implements unset() for ArrayAccess interface.
public
offsetUnset(mixed $field) : mixed
Parameters
- $field : mixed
Tags
Return values
mixed —removeRelation()
Removes a relation to one of the relationships defined in the mapper.
public
removeRelation(string $relationship[, Rampage $peer = null ]) : int
- For one-to-one and one-to-many relations, simply sets the relation field to 0.
- For many-to-many, either deletes all relations to this object or just the relation to a given peer object.
- Performs a no-op if the peer is already unrelated.
This is a proxy to the mapper's removeRelation method.
Parameters
- $relationship : string
-
The relationship key in the mapper
- $peer : Rampage = null
-
The object to remove from the relation
Tags
Return values
int —The number of relations affected
setFields()
Set field values for the object
public
setFields([array<string|int, mixed> $fields = [] ]) : mixed
Parameters
- $fields : array<string|int, mixed> = []
-
Initial values for the new object.
Tags
Return values
mixed —setIterator()
Change the default iterator
public
setIterator([string $iterator = '' ]) : mixed
Parameters
- $iterator : string = ''
Tags
Return values
mixed —setMapper()
Associate this Rdo object with the Mapper instance that will manage it. Called automatically by Mapper:map().
public
setMapper(Mapper $mapper) : mixed
Parameters
- $mapper : Mapper
-
The Mapper to manage this Rdo object.
Tags
Return values
mixed —toArray()
Converts the entity to an Array.
public
toArray([bool $lazy = false ][, bool $relationships = false ]) : array<string|int, mixed>
This method can be used when handing it over to Horde_Variables so that the database is not unnecessarily queried because of lazyFields/lazyRelationships.
Parameters
- $lazy : bool = false
-
Whether lazy elements should be added.
- $relationships : bool = false
-
Whether relationships should be added.
Tags
Return values
array<string|int, mixed> —All selected fields and relationships.
_fillPlaceholders()
Take a query array and replace @field@ placeholders with values from this object.
protected
_fillPlaceholders(array<string|int, mixed> $query) : array<string|int, mixed>
Parameters
- $query : array<string|int, mixed>
-
The query to process placeholders on.
Return values
array<string|int, mixed> —The query with placeholders filled in.