Comments: on this page. Click to read or post your own.

Class Object

Description

A base class for all sapphire objects to inherit from

This class provides a number of pattern implementations, as well as methods and fixes to add extra psuedo-static and method functionality to PHP

  • abstract:

Located in /sapphire/core/Object.php (line 11)


	
			
Direct descendents
Class Description
SearchContext Manages searching of properties on one or more DataObject types, based on a given set of input parameters.
SearchFilter
Filesystem A collection of static methods for manipulating the filesystem.
GD A wrapper class for GD-based images, with lots of manipulation functions.
Archive Class for handling archives.
i18nTest_Object A base class for all sapphire objects to inherit from
i18nTestModule_Addition A base class for all sapphire objects to inherit from
i18nTestSubModule A base class for all sapphire objects to inherit from
i18nOtherModule A base class for all sapphire objects to inherit from
BasicAuth Provides an interface to HTTP basic authentication.
PasswordValidator This class represents a validator for member passwords.
Authenticator Abstract base class for an authentication method
CSVParser Class to handle parsing of CSV files, where the column headers are in the first row.
CSSContentParser CSSContentParser enables parsing & assertion running of HTML content via CSS selectors.
SSCli Class to facilitate command-line output.
BuildTask Interface for a generic build task. Does not support dependencies. This will simply run a chunk of code when called.
BulkLoader_Result Encapsulates the result of a BulkLoader import (usually through the BulkLoader->processAll() method).
Geoip Routines for DNS to country resolution
XML Base class for XML parsers
Form_FieldMap A base class for all sapphire objects to inherit from
FormScaffolder
FormTransformation This class represents "transformations" of a form - such as making it printable or making it readonly.
Validator This validation class handles all form and custom form validation through the use of Required fields.
ReportField_SimpleFilter Assisting class. Determines whether or not a column is hidden.
Extension Add extension that can be added to an object with Object::add_extension().
TokenisedRegularExpression A tokenised regular expression is a parser, similar to a regular expression, that acts on tokens rather than characters.
ViewableData Generic class for all data that will be accessed from a view.
i18n Base-class for storage and retrieval of translated entities.
i18nTextCollector SilverStripe-variant of the "gettext" tool:
ArrayLib Library of static methods for manipulating arrays.
ValidationResult A class that combined as a boolean result with an optional list of error messages.
HTTPResponse Represenets an HTTPResponse returned by a controller.
HTTPRequest Represents a HTTP-request, including a URL that is tokenised for parsing, and a request method (GET/POST/PUT/DELETE).
SSViewer The SSViewer executes a .ss template file.
SQLMap This is a class used to represent key->value pairs generated from database queries.
SQLMap_Iterator A base class for all sapphire objects to inherit from
SQLQuery Object representing a SQL query.
DataObjectLog A DataObjectLog is a log of changes that have been made to the database in this session.
YamlFixture Uses the Spyc library to parse a YAML document (see http://yaml.org).
Database Abstract database connectivity class.
Query Abstract query-result class.
Convert Library of conversion functions, implemented as static methods.
Cookie A set of static methods for manipulating cookies.
Notifications The Notifications class allows you to create email notifications for various events.
Mailer Mailer objects are responsible for actually sending emails.
SQLFormatter Format a SQL Query for better readable output in HTML or Plaintext.
TextParser Parses text in a variety of ways.
DataFormatter A DataFormatter object handles transformation of data from Sapphire model objects to a particular output format, and vice versa.
CMSMenu The object manages the main CMS menu.
SideReport A base class for all sapphire objects to inherit from
BatchProcess Create a process in session which is incremented to calls from the client
CMSMenuItem A simple CMS menu item
ShoppingCart The ShoppingCart class is a 'data handler' for the Order object.
Variable Summary
static array $extensions
string $class
Method Summary
static void addStaticVars (string $class, array $properties, [bool $replace = false])
static void add_extension (string $class, string $extension)
static void add_static_var (string $class, string $name, mixed $value, [bool $replace = false])
static mixed combined_static (string $class, string $name, [string $ceiling = false])
static Object create (string $class, mixed $arguments,...)
static string getCustomClass (string $class)
static mixed get_static (string $class, string $name, [bool $uncached = false])
static void has_extension (string $class, string $requiredExtension)
static void remove_extension (string $class, string $extension)
static void set_static (string $class, string $name, mixed $value)
static Object strong_create (string $class, mixed $arguments,...)
static mixed uninherited_static (string $class, string $name)
static void useCustomClass (string $oldClass, string $newClass, [bool $strong = false])
Object __construct ()
void addMethodsFrom (string $property, [string|int $index = null])
void addWrapperMethod (string $method, string $wrap)
array allMethodNames ([bool $custom = false])
void buildMethodList ()
mixed cacheToFile (string $method, [int $lifetime = 3600], [string $ID = false], [array $arguments = array()])
void cacheToFileWithArgs ( $callback, [ $arguments = array()], [ $lifetime = 3600], [ $ID = false])
void clearCache ( $method, [ $ID = false], [ $arguments = array()])
void createMethod (string $method, string $code)
void defineMethods ()
bool exists ()
array extend (string $method, [ &$a1 = null], [ &$a2 = null], [ &$a3 = null], [ &$a4 = null], [ &$a5 = null], [ &$a6 = null], [ &$a7 = null], mixed $a1,...)
Extension extInstance (string $extension)
bool hasExtension (string $extension)
bool hasMethod (string $method)
mixed invokeWithExtensions (string $method, [mixed $argument = null])
bool is_a (string $class)
mixed loadCache (string $cache, [int $lifetime = 3600])
string parentClass ()
string sanitiseCachename (string $name)
void saveCache (string $cache, mixed $data)
void set_stat ( $name,  $value)
void set_uninherited ()
void stat ( $name, [ $uncached = false])
void uninherited ( $name)
mixed __call (string $method, array $arguments)
string __toString ()
Variables
static array $extensions = null (line 25)

An array of extension names and parameters to be applied to this object upon construction. For example:

  1.  public static $extensions array (
  2.    'Hierachy',
  3.    "Version('Stage', 'Live')"
  4.  );

  • access: public

Redefined in descendants as:
string $class (line 55)
  • var: the class name
  • access: public
array $extension_instances = array() (line 60)
  • var: all current extension instances
  • access: protected
Methods
static method addStaticVars (line 292)

Merge in a set of additional static variables

  • access: public
static void addStaticVars (string $class, array $properties, [bool $replace = false])
  • string $class
  • array $properties: in a [property name] => [value] format
  • bool $replace: replace existing static vars
static method add_extension (line 343)

Add an extension to a specific class

  • access: public
static void add_extension (string $class, string $extension)
  • string $class
  • string $extension: the extension to add to the class
static method add_static_var (line 305)

Add a static variable without replacing it completely if possible, but merging in with both existing PHP statics and existing psuedo-statics

  • access: public
static void add_static_var (string $class, string $name, mixed $value, [bool $replace = false])
  • string $class
  • string $name: the static name
  • mixed $value
  • bool $replace: completely replace existing static values
static method combined_static (line 264)

Traverse down a class ancestry and attempt to merge all the uninherited static values for a particular static into a single variable

  • access: public
static mixed combined_static (string $class, string $name, [string $ceiling = false])
  • string $class
  • string $name: the static name
  • string $ceiling: an optional parent class name to begin merging statics down from, rather than traversing the entire hierarchy
static method create (line 75)

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()

  • access: public
static Object create (string $class, mixed $arguments,...)
  • string $class: the class name
  • mixed $arguments,...: arguments to pass to the constructor

Redefined in descendants as:
static method getCustomClass (line 138)

If a class has been overloaded, get the class name it has been overloaded with - otherwise return the class name

  • return: the class that would be created if you called Object::create() with the class
  • access: public
static string getCustomClass (string $class)
  • string $class: the class to check
static method get_static (line 163)

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

  • access: public
static mixed get_static (string $class, string $name, [bool $uncached = false])
  • string $class
  • string $name: the property name
  • bool $uncached: if set to TRUE, force a regeneration of the static cache
static method has_extension (line 326)

Return TRUE if a class has a specified extension

  • access: public
static void has_extension (string $class, string $requiredExtension)
  • string $class
  • string $requiredExtension: the class name of the extension to check for
static method remove_extension (line 354)

Remove an extension from a class

  • access: public
static void remove_extension (string $class, string $extension)
  • string $class
  • string $extension
static method set_static (line 227)

Set a static variable

  • access: public
static void set_static (string $class, string $name, mixed $value)
  • string $class
  • string $name: the property name to set
  • mixed $value
static method strong_create (line 98)

Similar to Object::create(), except that classes are only overloaded if you set the $strong parameter to TRUE when using Object::useCustomClass()

  • access: public
static Object strong_create (string $class, mixed $arguments,...)
  • string $class: the class name
  • mixed $arguments,...: arguments to pass to the constructor
static method uninherited_static (line 239)

Get an uninherited static variable - a variable that is explicity set in this class, and not in the parent class

  • access: public
static mixed uninherited_static (string $class, string $name)
  • string $class
  • string $name
static method useCustomClass (line 124)

This class allows you to overload classes with other classes when they are constructed using the factory method Object::create()

  • access: public
static void useCustomClass (string $oldClass, string $newClass, [bool $strong = false])
  • string $oldClass: the class to replace
  • string $newClass: the class to replace it with
  • bool $strong: allows you to enforce a certain class replacement under all circumstances. This is used in singletons and DB interaction classes
Constructor __construct (line 366)
  • access: public
Object __construct ()

Redefined in descendants as:
addMethodsFrom (line 496)

Add all the methods from an object property (which is an Extension) to this object

  • access: protected
void addMethodsFrom (string $property, [string|int $index = null])
  • string $property: the property name
  • string|int $index: an index to use if the property is an array
addWrapperMethod (line 522)

Add a wrapper method - a method which points to another method with a different name. For example, Thumbnail(x) can be wrapped to generateThumbnail(x)

  • access: protected
void addWrapperMethod (string $method, string $wrap)
  • string $method: the method name to wrap
  • string $wrap: the method name to wrap to
allMethodNames (line 456)

Return the names of all the methods available on this object

  • access: public
array allMethodNames ([bool $custom = false])
  • bool $custom: include methods added dynamically at runtime
buildMethodList (line 466)
  • access: protected
void buildMethodList ()
cacheToFile (line 688)

Cache the results of an instance method in this object to a file, or if it is already cache return the cached results

  • return: the cached data
  • access: public
mixed cacheToFile (string $method, [int $lifetime = 3600], [string $ID = false], [array $arguments = array()])
  • string $method: the method name to cache
  • int $lifetime: the cache lifetime in seconds
  • string $ID: custom cache ID to use
  • array $arguments: an optional array of arguments
cacheToFileWithArgs (line 726)
  • deprecated:
  • access: public
void cacheToFileWithArgs ( $callback, [ $arguments = array()], [ $lifetime = 3600], [ $ID = false])
  • $callback
  • $arguments
  • $lifetime
  • $ID
clearCache (line 713)

Clears the cache for the given cacheToFile call

  • access: public
void clearCache ( $method, [ $ID = false], [ $arguments = array()])
  • $method
  • $ID
  • $arguments
createMethod (line 536)

Add an extra method using raw PHP code passed as a string

  • access: protected
void createMethod (string $method, string $code)
  • string $method: the method name
  • 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

Redefined in descendants as:
defineMethods (line 474)
  • access: protected
void defineMethods ()

Redefined in descendants as:
exists (line 584)

Return true if this object "exists" i.e. has a sensible value

This method should be overriden in subclasses to provide more context about the classes state. For example, a DataObject class could return false when it is deleted from the database

  • access: public
bool exists ()

Redefined in descendants as:
extend (line 643)

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 decorator. 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

  • access: public
array extend (string $method, [ &$a1 = null], [ &$a2 = null], [ &$a3 = null], [ &$a4 = null], [ &$a5 = null], [ &$a6 = null], [ &$a7 = null], mixed $a1,...)
  • string $method: the name of the method to call on each extension
  • mixed $a1,...: up to 7 arguments to be passed to the method
  • &$a1
  • &$a2
  • &$a3
  • &$a4
  • &$a5
  • &$a6
  • &$a7
extInstance (line 662)

Get an extension instance attached to this object by name

  • access: public
Extension extInstance (string $extension)
  • string $extension
hasExtension (line 672)

Returns TRUE if this object has a specific extension applied

  • access: public
bool hasExtension (string $extension)
  • string $extension
hasMethod (line 446)

Return TRUE if a method exists on this object

This should be used rather than PHP's inbuild method_exists() as it takes into account methods added via extensions

  • access: public
bool hasMethod (string $method)
  • string $method

Redefined in descendants as:
invokeWithExtensions (line 623)

Calls a method if available on both this object and all applied Extensions, and then attempts to merge all results into an array

  • todo: integrate inheritance rules
  • access: public
mixed invokeWithExtensions (string $method, [mixed $argument = null])
  • string $method: the method name to call
  • mixed $argument: a single argument to pass
is_a (line 601)

Check if this class is an instance of a specific class, or has that class as one of its parents

  • access: public
bool is_a (string $class)
  • string $class
loadCache (line 742)

Loads a cache from the filesystem if a valid on is present and within the specified lifetime

  • access: protected
mixed loadCache (string $cache, [int $lifetime = 3600])
  • string $cache: the cache name
  • int $lifetime: the lifetime (in seconds) of the cache before it is invalid
parentClass (line 591)
  • return: this classes parent class
  • access: public
string parentClass ()
sanitiseCachename (line 768)

Strip a file name of special characters so it is suitable for use as a cache file name

  • return: the name with all special cahracters replaced with underscores
  • access: protected
string sanitiseCachename (string $name)
  • string $name
saveCache (line 758)

Save a piece of cached data to the file system

  • access: protected
void saveCache (string $cache, mixed $data)
  • string $cache: the cache name
  • mixed $data: data to save (must be serializable)
set_stat (line 554)
void set_stat ( $name,  $value)
  • $name
  • $value
set_uninherited (line 568)
  • deprecated:
  • access: public
void set_uninherited ()
stat (line 547)
void stat ( $name, [ $uncached = false])
  • $name
  • $uncached
uninherited (line 561)
void uninherited ( $name)
  • $name
__call (line 393)

Attemps to locate and call a method dynamically added to a class at runtime if a default cannot be located

You can add extra methods to a class using Extensions, Object::createMethod() or Object::addWrapperMethod()

  • access: public
mixed __call (string $method, array $arguments)
  • string $method
  • array $arguments

Redefined in descendants as:
__toString (line 608)
  • return: the class name
  • access: public
string __toString ()

Redefined in descendants as:
blog comments powered by Disqus

Documentation generated on Mon, 23 Mar 2009 06:53:32 +1300 by phpDocumentor 1.3.2