Returns

An implementation of the factory method, allows you to create an instance of
a class

An implementation of the factory method, allows you to create an instance of
a class

This method first for strong class overloads (singletons & DB
interaction), then custom class overloads. If an overload is found, an instance
of this is returned rather than the original class. To overload a class, use
Object::useCustomClass()

This can be called in one of two ways - either calling via the class
directly, or calling on Object and passing the class name as the first
parameter. The following are equivalent: $list = DataList::create('SiteTree');
$list = SiteTree::get();

Returns

Get a static variable, taking into account SS's inbuild static caches and
pseudo-statics

Get a static variable, taking into account SS's inbuild static caches and
pseudo-statics

This method first checks for any extra values added by Object::add_static_var(), and attemps to traverse up the extra static var chain
until it reaches the top, or it reaches a replacement static.

If any extra values are discovered, they are then merged with the default PHP
static values, or in some cases completely replace the default PHP static when
you set $replace = true, and do not define extra data on any child classes

Parameters

$class

string $class

$name

string $name the property name

$uncached

bool $uncached if set to TRUE, force a regeneration of the static cache

Add a static variable without replacing it completely if possible, but
merging in with both existing PHP statics and existing psuedo-statics. Uses
PHP's array_merge_recursive() with if the $replace argument is FALSE.

Add a static variable without replacing it completely if possible, but
merging in with both existing PHP statics and existing psuedo-statics. Uses
PHP's array_merge_recursive() with if the $replace argument is FALSE.

Documentation from http://php.net/array_merge_recursive:
If the input arrays have the same string keys, then the values for these keys
are merged together into an array, and this is done recursively, so that if one
of the values is an array itself, the function will merge it with a
corresponding entry in another array too. If, however, the arrays have the same
numeric key, the later value will not overwrite the original value, but will be
appended.

Parameters

Add an extension to a specific class. As an alternative, extensions can be
added to a specific class directly in the Object::$extensions array. See
SiteTree::$extensions for examples. Keep in mind that the extension will
only be applied to new instances, not existing ones (including all instances
created through singleton()).

Add an extension to a specific class. As an alternative, extensions can be
added to a specific class directly in the Object::$extensions array. See
SiteTree::$extensions for examples. Keep in mind that the extension will
only be applied to new instances, not existing ones (including all instances
created through singleton()).

Parameters

$class

string $class Class that should be extended - has to be a subclass of Object

$extension

string $extension Subclass of Extension with optional parameters as a
string, e.g. "Versioned" or "Translatable('Param')"

Remove an extension from a class. Keep in mind that this won't revert any
datamodel additions of the extension at runtime, unless its used before the
schema building kicks in (in your _config.php). Doesn't remove the extension
from any Object instances which are already created, but will have an
effect on new extensions. Clears any previously created singletons through
singleton() to avoid side-effects from stale extension information.

Remove an extension from a class. Keep in mind that this won't revert any
datamodel additions of the extension at runtime, unless its used before the
schema building kicks in (in your _config.php). Doesn't remove the extension
from any Object instances which are already created, but will have an
effect on new extensions. Clears any previously created singletons through
singleton() to avoid side-effects from stale extension information.

Parameters

$class

string $class

$extension

string $extension Classname of an Extension subclass, without parameters

Parameters

Returns

Adds any methods from Extension instances attached to this object.
All these methods can then be called directly on the instance (transparently
mapped through Object::__call()), or called explicitly through Object::extend().

Adds any methods from Extension instances attached to this object.
All these methods can then be called directly on the instance (transparently
mapped through Object::__call()), or called explicitly through Object::extend().

Parameters

$method

string $method the method name

$code

string $code the PHP code - arguments will be in an array called $args, while
you can access this object by using $obj. Note that you cannot call protected
methods, as the method is actually an external function

Returns

Run the given function on all of this object's extensions. Note that this
method originally returned void, so if you wanted to return results, you're
hosed

Run the given function on all of this object's extensions. Note that this
method originally returned void, so if you wanted to return results, you're
hosed

Currently returns an array, with an index resulting every time the function
is called. Only adds returns if they're not NULL, to avoid bogus results from
methods just defined on the parent extension. This is important for
permission-checks through extend, as they use min() to determine if any of the
returns is FALSE. As min() doesn't do type checking, an included NULL return
would fail the permission checks.

Parameters

Returns

Uses

Returns TRUE if this object instance has a specific extension applied in
Object::$extension_instances. Extension instances are initialized at constructor
time, meaning if you use Object::add_extension() afterwards, the added extension
will just be added to new instances of the extended class. Use the static method
Object::has_extension() to check if a class (not an instance) has a specific
extension. Caution: Don't use singleton(<class>)->hasExtension() as it
will give you inconsistent results based on when the singleton was first
accessed.

Returns TRUE if this object instance has a specific extension applied in
Object::$extension_instances. Extension instances are initialized at constructor
time, meaning if you use Object::add_extension() afterwards, the added extension
will just be added to new instances of the extended class. Use the static method
Object::has_extension() to check if a class (not an instance) has a specific
extension. Caution: Don't use singleton(<class>)->hasExtension() as it
will give you inconsistent results based on when the singleton was first
accessed.

Parameters

$extension

string $extension Classname of an Extension subclass without parameters

Comments

Comment policy: Please use comments for tips and corrections about the described
functionality. Comments are moderated, we reserve the right to remove comments that are inappropriate or are no longer relevant.
Use the Silverstripe Forum to ask questions.