class Image_Cached extends Image

A resized / processed {@link Image} object.

When Image object are processed or resized, a suitable Image_Cached object is returned, pointing to the cached copy of the processed image.

Constants

CHANGE_NONE

Represents a field that hasn't changed (before === after, thus before == after)

CHANGE_STRICT

Represents a field that has changed type, although not the loosely defined value.

(before !== after && before == after) E.g. change 1 to true or "true" to true, but not true to 0. Value changes are by nature also considered strict changes.

CHANGE_VALUE

Represents a field that has changed the loosely defined value (before != after, thus, before !== after)) E.g. change false to true, but not false to 0

ORIENTATION_SQUARE

ORIENTATION_PORTRAIT

ORIENTATION_LANDSCAPE

Properties

string $class from SS_Object
boolean $destroyed True if this DataObject has been destroyed. from DataObject
static $cache_has_own_table Static caches used by relevant functions. from DataObject
static $allowed_actions Provides a list of allowed methods that can be called via RESTful api. from DataObject

Methods

static Config_ForClass|null
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .

from SS_Object
static SS_Object
create()

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

from SS_Object
static SS_Object
singleton()

Creates a class instance by the "singleton" design pattern.

from SS_Object
static 
create_from_string($classSpec, $firstArg = null)

Create an object from a string representation. It treats it as a PHP constructor without the 'new' keyword. It also manages to construct the object without the use of eval().

from SS_Object
static 
parse_class_spec($classSpec)

Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().

from SS_Object
static SS_Object
strong_create()

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

from SS_Object
static 
useCustomClass(string $oldClass, string $newClass, bool $strong = false)

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

from SS_Object
static string
getCustomClass(string $class)

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

from SS_Object
static any
static_lookup($class, $name, null $default = null)

Get the value of a static property of a class, even in that property is declared protected (but not private), without any inheritance, merging or parent lookup if it doesn't exist on the given class.

from SS_Object
static 
get_static($class, $name, $uncached = false) deprecated

No description

from SS_Object
static 
set_static($class, $name, $value) deprecated

No description

from SS_Object
static 
uninherited_static($class, $name, $uncached = false) deprecated

No description

from SS_Object
static 
combined_static($class, $name, $ceiling = false) deprecated

No description

from SS_Object
static 
addStaticVars($class, $properties, $replace = false) deprecated

No description

from SS_Object
static 
add_static_var($class, $name, $value, $replace = false) deprecated

No description

from SS_Object
static 
has_extension(string $classOrExtension, string $requiredExtension = null, boolean $strict = false)

Return TRUE if a class has a specified extension.

from SS_Object
static 
add_extension(string $classOrExtension, string $extension = null)

Add an extension to a specific class.

from SS_Object
static 
remove_extension(string $extension)

Remove an extension from a class.

from SS_Object
static array
get_extensions(string $class, bool $includeArgumentString = false)

No description

from SS_Object
static 
get_extra_config_sources($class = null)

No description

from SS_Object
__construct($filename = null, $isSingleton = false, Image $sourceImage = null)

Create a new cached image.

mixed
__call(string $method, array $arguments)

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

from SS_Object
bool
hasMethod(string $method)

Return TRUE if a method exists on this object

from SS_Object
array
allMethodNames(bool $custom = false)

Return the names of all the methods available on this object

from SS_Object
stat($name, $uncached = false)

No description

from SS_Object
set_stat($name, $value)

No description

from SS_Object
uninherited($name)

No description

from SS_Object
bool
exists()

Override the parent's exists method becuase the ID is explicitly set to -1 on a cached image we can't use the default check

string
parentClass()

No description

from SS_Object
bool
is_a(string $class)

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

from SS_Object
string
__toString()

No description

from SS_Object
mixed
invokeWithExtensions(string $method, mixed $argument = null)

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

from SS_Object
array
extend(string $method, mixed $a1 = null, mixed $a2 = null, mixed $a3 = null, mixed $a4 = null, mixed $a5 = null, mixed $a6 = null, mixed $a7 = null)

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

from SS_Object
getExtensionInstance(string $extension)

Get an extension instance attached to this object by name.

from SS_Object
bool
hasExtension(string $extension)

Returns TRUE if this object instance has a specific extension applied in {@link $extension_instances}. Extension instances are initialized at constructor time, meaning if you use {@link add_extension()} afterwards, the added extension will just be added to new instances of the extended class. Use the static method {@link has_extension()} to check if a class (not an instance) has a specific extension.

from SS_Object
array
getExtensionInstances()

Get all extension instances for this specific object instance.

from SS_Object
mixed
cacheToFile(string $method, int $lifetime = 3600, string $ID = false, array $arguments = array())

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

from SS_Object
clearCache($method, $ID = false, $arguments = array())

Clears the cache for the given cacheToFile call

from SS_Object
static string
castingObjectCreator(string $fieldSchema)

Converts a field spec into an object creator. For example: "Int" becomes "new Int($fieldName);" and "Varchar(50)" becomes "new Varchar($fieldName, 50);".

static array
castingObjectCreatorPair(string $fieldSchema)

Convert a field schema (e.g. "Varchar(50)") into a casting object creator array that contains both a className and castingHelper constructor code. See {@link castingObjectCreator} for more information about the constructor.

bool
__isset(string $property)

Check if a field exists on this object or its failover.

mixed
__get(string $property)

Get the value of a property/field on this object. This will check if a method called get{$property} exists, then check if a field is available using {@link ViewableData::getField()}, then fall back on a failover object.

__set(string $property, mixed $value)

Set a property/field on this object. This will check for the existence of a method called set{$property}, then use the {@link ViewableData::setField()} method.

setFailover(ViewableData $failover)

Set a failover object to attempt to get data from if it is not present on this object.

getFailover()

Get the current failover object if set

bool
hasField(string $field)

Returns true if the given field exists in a database column on any of the objects tables and optionally look up a dynamic getter with get().

mixed
getField(string $field)

Gets the value of a field.

setField(string $fieldName, mixed $val)

Set the value of the field Called by {@link __set()} and any setFieldName() methods you might create.

defineMethods()

Set up template methods to access the transformations generated by 'generate' methods.

from Image
unknown
deprecatedCachedCall($method, $args = null, $identifier = null)

Method to facilitate deprecation of underscore-prefixed methods automatically being cached.

customise(array|ViewableData $data)

Merge some arbitrary data in with this object. This method returns a {@link ViewableData_Customised} instance with references to both this and the new custom data.

getCustomisedObj()

No description

setCustomisedObj(ViewableData $object)

No description

array
castingHelperPair(string $field)

Get the class a field on this object would be casted to, as well as the casting helper for casting a field to an object (see {@link ViewableData::castingHelper()} for information on casting helpers).

string
castingHelper(string $field)

Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field on this object.

string
castingClass(string $field)

Get the class name a field on this object will be casted to

string
escapeTypeForField(string $field)

Return the string-format type for the given field.

buildCastingCache(reference $cache)

Save the casting cache for this object (including data from any failovers) into a variable

renderWith(string|array|SSViewer $template, array $customFields = null)

Render this object into the template, and get the result as a string. You can pass one of the following as the $template parameter: - a template name (e.g. Page) - an array of possible template names - the first valid one will be used - an SSViewer instance

obj(string $fieldName, array $arguments = null, bool $forceReturnedObject = true, bool $cache = false, string $cacheName = null)

Get the value of a field on this object, automatically inserting the value into any available casting objects that have been specified.

cachedCall(string $field, array $arguments = null, string $identifier = null)

A simple wrapper around {@link ViewableData::obj()} that automatically caches the result so it can be used again without re-running the method.

bool
hasValue(string $field, array $arguments = null, bool $cache = true)

Returns true if the given method/parameter has a value (Uses the DBField::hasValue if the parameter is a database field)

XML_val($field, $arguments = null, $cache = false)

Get the string value of a field on this object that has been suitable escaped to be inserted directly into a template.

RAW_val($field, $arguments = null, $cache = true)

Return the value of the field without any escaping being applied.

SQL_val($field, $arguments = null, $cache = true)

Return the value of a field in an SQL-safe format.

JS_val($field, $arguments = null, $cache = true)

Return the value of a field in a JavaScript-save format.

ATT_val($field, $arguments = null, $cache = true)

Return the value of a field escaped suitable to be inserted into an XML node attribute.

array
getXMLValues($fields)

Get an array of XML-escaped values by field name

getIterator()

Return a single-item iterator so you can iterate over the fields of a single record.

Me()

When rendering some objects it is necessary to iterate over the object being rendered, to do this, you need access to itself.

string
ThemeDir(string $subtheme = false)

Return the directory if the current active theme (relative to the site root).

string
CSSClasses(string $stopAtClass = 'ViewableData')

Get part of the current classes ancestry to be used as a CSS class.

Debug()

Return debug information about this object that can be rendered into a template

static bool
get_validation_enabled() deprecated

Returns when validation on DataObjects is enabled.

static 
set_validation_enabled($enable) deprecated

Set whether DataObjects should be validated before they are written.

static 
clear_classname_spec_cache()

Clear all cached classname specs. It's necessary to clear all cached subclassed names for any classes if a new class manifest is generated.

static string
get_classname_spec(string $class, boolean $queryDB = true)

Determines the specification for the ClassName field for the given class

static array
database_fields(string $class, boolean $queryDB = true)

Return the complete map of fields on this object, including "Created", "LastEdited" and "ClassName".

static array
custom_database_fields(string $class)

Get all database columns explicitly defined on a class in {@link DataObject::$db} and {@link DataObject::$has_one}. Resolves instances of {@link CompositeDBField} into the actual database fields, rather than the name of the field which might not equate a database column.

static string
is_composite_field(string $class, string $name, boolean $aggregated = true)

Returns the field class if the given db field on the class is a composite field.

static 
composite_fields($class, $aggregated = true)

Returns a list of all the composite if the given db field on the class is a composite field.

setDataModel(DataModel $model)

Set the DataModel

destroy()

Destroy all of this objects dependant objects and local caches.

duplicate($doWrite = true)

Create a duplicate of this node.

getObsoleteClassName()

No description

getClassName()

No description

setClassName(string $className)

Set the ClassName attribute. {@link $class} is also updated.

newClassInstance(string $newClassName)

Create a new instance of a different class from this object's record.

boolean
isEmpty()

Returns TRUE if all values (other than "ID") are considered empty (by weak boolean comparison).

string
singular_name()

Get the user friendly singular name of this DataObject.

string
i18n_singular_name()

Get the translated user friendly singular name of this DataObject same as singular_name() but runs it through the translating function

string
plural_name()

Get the user friendly plural name of this DataObject If the name is not defined (by renaming $plural_name in the subclass), this returns a pluralised version of the class name.

string
i18n_plural_name()

Get the translated user friendly plural name of this DataObject Same as plural_name but runs it through the translation function Translation string is in the form: $this->class.PLURALNAME Example: Page.PLURALNAME

string
getTitle()

Standard implementation of a title/label for a specific record. Tries to find properties 'Title' or 'Name', and falls back to the 'ID'. Useful to provide user-friendly identification of a record, e.g. in errormessages or UI-selections.

data()

Returns the associated database record - in this case, the object itself.

array
toMap()

Convert this object to a map.

array
getQueriedDatabaseFields()

Return all currently fetched database fields.

update(array $data)

Update a number of fields on this object, given a map of the desired changes.

castedUpdate(array $data)

Pass changes as a map, and try to get automatic casting for these fields.

Boolean
merge($rightObj, $priority = 'right', $includeRelations = true, $overwriteWithEmpty = false)

Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty.

$this
forceChange()

Forces the record to think that all its data has changed.

doValidate()

Public accessor for {see DataObject::validate()}

populateDefaults()

Load the default values in from the self::$defaults array.

write(boolean $showDebug = false, boolean $forceInsert = false, boolean $forceWrite = false, boolean $writeComponents = false)

Prevent writing the cached image to the database

writeRelations()

Writes cached relation lists to the database, if possible

writeComponents($recursive = false)

Write the cached components to the database. Cached components could refer to two different instances of the same record.

delete()

Delete this data object.

static 
delete_by_id(string $className, int $id)

Delete the record with the given ID.

array
getClassAncestry()

Get the class ancestry, including the current class name.

getComponent(string $componentName)

Return a component object from a one to one relationship, as a DataObject.

getComponents(string $componentName, string|null $filter = null, string|null|array $sort = null, string $join = null, string|null|array $limit = null)

Returns a one-to-many relation as a HasManyList

getComponentsQuery($componentName, $filter = "", $sort = "", $join = "", $limit = "") deprecated

No description

string
getRelationClass($relationName)

Find the foreign class of a relation on this DataObject, regardless of the relation type.

string
getRemoteJoinField(string $component, string $type = 'has_many', boolean $polymorphic = false)

Tries to find the database key on another object that is used to store a relationship to this class. If no join field can be found it defaults to 'ParentID'.

getManyManyComponents($componentName, $filter = null, $sort = null, $join = null, $limit = null)

Returns a many-to-many component, as a ManyManyList.

array|null
has_one(string $component = null) deprecated

No description

string|array
hasOne(string $component = null)

Return the class of a one-to-one component. If $component is null, return all of the one-to-one components and their classes. If the selected has_one is a polymorphic field then 'DataObject' will be returned for the type.

string|null
hasOneComponent(string $component)

Return data for a specific has_one component.

array|null
belongs_to(string $component = null, bool $classOnly = true) deprecated

No description

string|array
belongsTo(string $component = null, bool $classOnly = true)

Returns the class of a remote belongs_to relationship. If no component is specified a map of all components and their class name will be returned.

string|false
belongsToComponent(string $component, bool $classOnly = true)

Return data for a specific belongs_to component.

array
db(string $fieldName = null)

Return all of the database fields defined in self::$db and all the parent classes.

array|null
has_many(string $component = null, bool $classOnly = true) deprecated

No description

string|array|false
hasMany(string $component = null, bool $classOnly = true)

Gets the class of a one-to-many relationship. If no $component is specified then an array of all the one-to-many relationships and their classes will be returned.

string|false
hasManyComponent(string $component, bool $classOnly = true)

Return data for a specific has_many component.

array
many_many_extraFields(string $component = null) deprecated

No description

array|null
manyManyExtraFields(string $component = null)

Return the many-to-many extra fields specification.

array|null
manyManyExtraFieldsForComponent(string $component)

Return the many-to-many extra fields specification for a specific component.

array|null
many_many(string $component = null) deprecated

No description

array|null
manyMany(string $component = null)

Return information about a many-to-many component.

array|null
manyManyComponent(string $component)

Return information about a specific many_many component. Returns a numeric array of: array( , The class that relation is defined in e.g. "Product" , The target class of the relation e.g. "Category" , The field name pointing to 's table e.g. "ProductID" , The field name pointing to 's table e.g. "CategoryID" The join table between the two classes e.g. "Product_Categories" )

array
database_extensions($class)

This returns an array (if it exists) describing the database extensions that are required, or false if none

getDefaultSearchContext()

Generates a SearchContext to be used for building and processing a generic search form for properties on this object.

scaffoldSearchFields(array $_params = null)

Determine which properties on the DataObject are searchable, and map them to their default {@link FormField} representations. Used for scaffolding a searchform for {@link ModelAdmin}.

scaffoldFormFields(array $_params = null)

Scaffold a simple edit form for all properties on this dataobject, based on default {@link FormField} mapping in {@link DBField::scaffoldFormField()}.

getCMSFields()

Returns the fields to power the edit screen of files in the CMS.

from Image
an
getCMSActions()

need to be overload by solid dataobject, so that the customised actions of that dataobject, including that dataobject's extensions customised actions could be added to the EditForm.

getFrontEndFields(array $params = null)

Used for simple frontend forms without relation editing or {@link TabSet} behaviour. Uses {@link scaffoldFormFields()} by default. To customize, either overload this method in your subclass, or extend it by {@link DataExtension->updateFrontEndFields()}.

array
getChangedFields(boolean $databaseFieldsOnly = false, int $changeLevel = self::CHANGE_STRICT)

Return the fields that have changed.

boolean
isChanged(string $fieldName = null, int $changeLevel = self::CHANGE_STRICT)

Uses {@link getChangedFields()} to determine if fields have been changed since loading them from the database.

setCastedField($fieldName, $val)

Set the value of the field, using a casting object.

boolean
hasDatabaseField(string $field)

Returns true if the given field exists as a database column

string
hasOwnTableDatabaseField(string $field)

Returns the field type of the given field, if it belongs to this class, and not a parent.

static string
has_own_table_database_field(string $class, string $field)

Returns the field type of the given field, if it belongs to this class, and not a parent.

static bool
has_own_table(string $dataClass)

Returns true if given class has its own table. Uses the rules for whether the table should exist rather than actually looking in the database.

boolean
can(string $perm, Member $member = null)

Returns true if the member is allowed to do the given action.

boolean|null
extendedCan(String $methodName, Member|int $member)

Process tri-state responses from permission-alterting extensions. The extensions are expected to return one of three values:

boolean
canView(Member $member = null)

No description

from File
boolean
canEdit(Member $member = null)

Returns true if the following conditions are met: - CMS_ACCESS_AssetAdmin

from File
boolean
canDelete(Member $member = null)

No description

from File
boolean
canCreate(Member $member = null)

No description

from File
string
debug()

Debugging used by Debug::show()

dbObject(string $fieldName)

Return the DBField object that represents the given field.

mixed
relObject(string $fieldPath)

Traverses to a DBField referenced by relationships between data objects.

string
relField($fieldName)

Traverses to a field referenced by relationships between data objects, returning the value The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName)

String
getReverseAssociation($className)

Temporary hack to return an association name, based on class, to get around the mangle of having to deal with reverse lookup of relationships to determine autogenerated foreign keys.

static DataList
get(string $callerClass = null, string|array $filter = "", string|array $sort = "", string $join = "", string|array $limit = null, string $containerClass = 'DataList')

Return all objects matching the filter sub-classes are automatically selected and included

Aggregate($class = null) deprecated

No description

RelationshipAggregate($relationship) deprecated

No description

static DataObject
get_one(string $callerClass, string|array $filter = "", boolean $cache = true, string $orderby = "")

Return the first item matching the given query.

flushCache($persistant = true)

Flush the cached results for all relations (has_one, has_many, many_many) Also clears any cached aggregate data.

from File
static 
flush_and_destroy_cache()

Flush the get_one global cache and destroy associated objects.

static 
reset()

Reset all global caches associated with DataObject.

static DataObject
get_by_id(string $callerClass, int $id, boolean $cache = true)

Return the given element, searching by ID

baseTable()

Get the name of the base table for this object

array
getSourceQueryParams()

No description

setSourceQueryParams(array $array)

No description

setSourceQueryParam($key, $value)

No description

Mixed
getSourceQueryParam($key)

No description

databaseIndexes()

Return the database indexes on this table.

requireTable()

Prevent creating new tables for the cached record

requireDefaultRecords()

Add default records to database. This function is called whenever the database is built, after the database tables have all been created. Overload this to add default records when the database is built, but make sure you call parent::requireDefaultRecords().

inheritedDatabaseFields()

Returns fields bu traversing the class heirachy in a bottom-up direction.

array
searchableFields()

Get the default searchable fields for this object, as defined in the $searchable_fields list. If searchable fields are not defined on the data object, uses a default selection of summary fields.

array|string
fieldLabels(boolean $includerelations = true)

No description

from File
string
fieldLabel(string $name)

Get a human-readable label for a single field, see {@link fieldLabels()} for more details.

array
summaryFields()

Get the default summary fields for this object.

array
defaultSearchFilters()

Defines a default list of filters for the search context.

boolean
isInDB()

No description

static 
disable_subclass_access()

Temporarily disable subclass access in data object qeur

static 
enable_subclass_access()

No description

array
provideI18nEntities()

Collect all static properties on the object which contain natural language, and need to be translated.

static string
link_shortcode_handler($arguments, $content = null, $parser = null)

Replace "[file_link id=n]" shortcode with an anchor tag or link to the file.

from File
static mixed
find(String $filename)

Find a File object by the given filename.

from File
string
Link()

Just an alias function to keep a consistent API with SiteTree

from File
string
RelativeLink()

Just an alias function to keep a consistent API with SiteTree

from File
string
AbsoluteLink()

Just an alias function to keep a consistent API with SiteTree

from File
string
getTreeTitle()

No description

from File
static String
get_app_category($ext)

Returns a category based on the file extension.

from File
String
appCategory()

Returns a category based on the file extension.

from File
StripThumbnail()

Resize this image for use as a thumbnail in a strip. Use in templates with $StripThumbnail.

from Image
CMSThumbnail()

Resize this image for the CMS. Use in templates with $CMSThumbnail

from Image
String
Icon()

Return the relative URL of an icon for the file type, based on the {@link appCategory()} value.

from File
onAfterUpload()

Should be called after the file was uploaded

from Image
deleteDatabaseOnly()

Delete the database record (recursively for folders) without touching the filesystem

from File
updateFilesystem()

Moving the file if appropriate according to updated database content.

from File
collateDescendants(condition $condition, collator $collator)

Collate selected descendants of this page.

from File
setName(string $name)

Setter function for Name. Automatically sets a default title, and removes characters that might be invalid on the filesystem.

from File
setParentID($parentID)

Does not change the filesystem itself, please use {@link write()} for this.

from File
string
getAbsoluteURL()

Gets the absolute URL accessible through the web.

from File
string
getURL()

Gets the relative URL accessible through the web.

from File
String
getFullPath()

Returns an absolute filesystem path to the file.

from File
String
getRelativePath()

Returns path relative to webroot.

DeleteLink()

No description

from File
getFilename()

No description

from File
setFilename($val)

Caution: this does not change the location of the file on the filesystem.

from File
String
getExtension()

Returns the file extension

from File
static string
get_file_extension(string $filename)

Gets the extension of a filepath or filename, by stripping away everything before the last "dot".

from File
string
getFileType()

Return the type of file for the given extension on the current file name.

from File
getSize()

Returns the size of the file type in an appropriate format.

from File
static string
format_size(int $size)

Formats a file size (eg: (int)42 becomes string '42 bytes')

from File
static int
ini2bytes(string $iniValue)

Convert a php.ini value (eg: 512M) to bytes

from File
int
getAbsoluteSize()

Return file size in bytes.

from File
static String
get_class_for_file_extension(String $ext)

Maps a {@link File} subclass to a specific extension.

from File
static 
set_class_for_file_extension(String|array $exts, String $class)

See {@link get_class_for_file_extension()}.

from File
Parent()

Returns parent File

from File
Owner()

Returns Member object of file owner.

from File
static 
flush()

Triggered early in the request when someone requests a flush.

from Image
static 
set_backend($backend)

No description

from Image
static 
get_backend()

No description

from Image
static string
strip_resampled_prefix(string $path)

Retrieve the original filename from the path of a transformed image.

from Image
string
getTag()

Return an XHTML img tag for this Image, or NULL if the image file doesn't exist on the filesystem.

from Image
string
forTemplate()

Return an XHTML img tag for this Image.

from Image
loadUploadedImage($tmpFile) deprecated

File names are filtered through {@link FileNameFilter}, see class documentation on how to influence this behaviour.

from Image
Image|null
Fit(integer $width, integer $height)

Scale image proportionally to fit within the specified bounds

from Image
generateFit(Image_Backend $backend, integer $width, integer $height) deprecated

Scale image proportionally to fit within the specified bounds

from Image
FitMax(integer $width, integer $height)

Proportionally scale down this image if it is wider or taller than the specified dimensions.

from Image
Image|null
Fill(integer $width, integer $height)

Resize and crop image to fill specified dimensions.

from Image
generateFill(Image_Backend $backend, integer $width, integer $height) deprecated

Resize and crop image to fill specified dimensions.

from Image
FillMax(integer $width, integer $height)

Crop this image to the aspect ratio defined by the specified width and height, then scale down the image to those dimensions if it exceeds them.

from Image
Image|null
Pad(integer $width, integer $height, string $backgroundColor = 'FFFFFF', integer $transparencyPercent)

Fit image to specified dimensions and fill leftover space with a solid colour (default white). Use in templates with $Pad.

from Image
generatePad(Image_Backend $backend, integer $width, integer $height, string $backgroundColor = 'FFFFFF', integer $transparencyPercent) deprecated

Fit image to specified dimensions and fill leftover space with a solid colour (default white). Use in templates with $Pad.

from Image
Image|null
ScaleWidth(integer $width)

Scale image proportionally by width. Use in templates with $ScaleWidth.

from Image
generateScaleWidth(Image_Backend $backend, int $width) deprecated

Scale image proportionally by width. Use in templates with $ScaleWidth.

from Image
ScaleMaxWidth(integer $width)

Proportionally scale down this image if it is wider than the specified width.

from Image
Image|null
ScaleHeight(integer $height)

Scale image proportionally by height. Use in templates with $ScaleHeight.

from Image
generateScaleHeight(Image_Backend $backend, integer $height) deprecated

Scale image proportionally by height. Use in templates with $ScaleHeight.

from Image
ScaleMaxHeight(integer $height)

Proportionally scale down this image if it is taller than the specified height.

from Image
CropWidth(integer $width)

Crop image on X axis if it exceeds specified width. Retain height.

from Image
CropHeight(integer $height)

Crop image on Y axis if it exceeds specified height. Retain width.

from Image
SetRatioSize(integer $width, integer $height) deprecated

Resize the image by preserving aspect ratio, keeping the image inside the $width and $height

from Image
generateSetRatioSize(Image_Backend $backend, integer $width, integer $height) deprecated

Resize the image by preserving aspect ratio, keeping the image inside the $width and $height

from Image
SetWidth(integer $width) deprecated

Resize this Image by width, keeping aspect ratio. Use in templates with $SetWidth.

from Image
generateSetWidth(Image_Backend $backend, int $width) deprecated

Resize this Image by width, keeping aspect ratio. Use in templates with $SetWidth.

from Image
SetHeight(integer $height) deprecated

Resize this Image by height, keeping aspect ratio. Use in templates with $SetHeight.

from Image
generateSetHeight(Image_Backend $backend, integer $height) deprecated

Resize this Image by height, keeping aspect ratio. Use in templates with $SetHeight.

from Image
SetSize(integer $width, integer $height) deprecated

Resize this Image by both width and height, using padded resize. Use in templates with $SetSize.

from Image
generateSetSize(Image_Backend $backend, integer $width, integer $height) deprecated

Resize this Image by both width and height, using padded resize. Use in templates with $SetSize.

from Image
generateCMSThumbnail(Image_Backend $backend) deprecated

Resize this image for the CMS. Use in templates with $CMSThumbnail.

from Image
generateAssetLibraryPreview(Image_Backend $backend) deprecated

Resize this image for preview in the Asset section. Use in templates with $AssetLibraryPreview.

from Image
generateAssetLibraryThumbnail(Image_Backend $backend) deprecated

Resize this image for thumbnail in the Asset section. Use in templates with $AssetLibraryThumbnail.

from Image
generateStripThumbnail(Image_Backend $backend) deprecated

Resize this image for use as a thumbnail in a strip. Use in templates with $StripThumbnail.

from Image
PaddedImage($width, $height, $backgroundColor = 'FFFFFF', $transparencyPercent) deprecated

Resize this Image by both width and height, using padded resize. Use in templates with $PaddedImage.

from Image
generatePaddedImage(Image_Backend $backend, $width, $height, $backgroundColor = 'FFFFFF', $transparencyPercent) deprecated

Resize this Image by both width and height, using padded resize. Use in templates with $PaddedImage.

from Image
boolean
isSize(integer $width, integer $height)

Determine if this image is of the specified size

from Image
boolean
isWidth(integer $width)

Determine if this image is of the specified width

from Image
boolean
isHeight(integer $height)

Determine if this image is of the specified width

from Image
getFormattedImage(string $format)

Return an image object representing the image in the given format.

from Image
string
cacheFilename(string $format)

Return the filename for the cached image, given its format name and arguments.

from Image
generateFormattedImage(string $format)

Generate an image on the specified format. It will save the image at the location specified by cacheFilename(). The image will be generated using the specific 'generate' method for the specified format.

from Image
ResizedImage(integer $width, integer $height)

Generate a resized copy of this image with the given width & height.

from Image
generateResizedImage(Image_Backend $backend, integer $width, integer $height)

Generate a resized copy of this image with the given width & height.

from Image
CroppedImage(integer $width, integer $height) deprecated

Generate a resized copy of this image with the given width & height, cropping to maintain aspect ratio.

from Image
generateCroppedImage(Image_Backend $backend, integer $width, integer $height) deprecated

Generate a resized copy of this image with the given width & height, cropping to maintain aspect ratio.

from Image
int
regenerateFormattedImages()

Regenerate all of the formatted cached images for this image.

from Image
int
deleteFormattedImages()

Remove all of the formatted cached images for this image.

from Image
string|int|null
getDimensions(string $dim = "string")

Get the dimensions of this Image.

from Image
int
getWidth()

Get the width of this image.

from Image
int
getHeight()

Get the height of this image.

from Image
ORIENTATION_SQUARE
getOrientation()

Get the orientation of this image.

from Image

Details

in SS_Object at line 60
static Config_ForClass|null config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .

....).

Return Value

Config_ForClass|null

in SS_Object at line 132
static SS_Object create()

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 {@link 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();

Return Value

SS_Object

in SS_Object at line 155
static SS_Object singleton()

Creates a class instance by the "singleton" design pattern.

It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).

Return Value

SS_Object The singleton instance

in SS_Object at line 190
static create_from_string($classSpec, $firstArg = null)

Create an object from a string representation. It treats it as a PHP constructor without the 'new' keyword. It also manages to construct the object without the use of eval().

Construction itself is done with Object::create(), so that Object::useCustomClass() calls are respected.

Object::create_from_string("Versioned('Stage','Live')") will return the result of Versioned::create('Stage', 'Live);

It is designed for simple, clonable objects. The first time this method is called for a given string it is cached, and clones of that object are returned.

If you pass the $firstArg argument, this will be prepended to the constructor arguments. It's impossible to pass null as the firstArg argument.

Object::create_from_string("Varchar(50)", "MyField") will return the result of Vachar::create('MyField', '50');

Arguments are always strings, although this is a quirk of the current implementation rather than something that can be relied upon.

Parameters

$classSpec
$firstArg

in SS_Object at line 215
static parse_class_spec($classSpec)

Parses a class-spec, such as "Versioned('Stage','Live')", as passed to create_from_string().

Returns a 2-elemnent array, with classname and arguments

Parameters

$classSpec

in SS_Object at line 341
static SS_Object strong_create()

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

Return Value

SS_Object

in SS_Object at line 361
static useCustomClass(string $oldClass, string $newClass, bool $strong = false)

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

Parameters

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

in SS_Object at line 375
static string getCustomClass(string $class)

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

Parameters

string $class the class to check

Return Value

string the class that would be created if you called {@link Object::create()} with the class

in SS_Object at line 396
static any static_lookup($class, $name, null $default = null)

Get the value of a static property of a class, even in that property is declared protected (but not private), without any inheritance, merging or parent lookup if it doesn't exist on the given class.

Parameters

$class
  • The class to get the static from
$name
  • The property to get from the class
null $default
  • The value to return if property doesn't exist on class

Return Value

any
  • The value of the static property $name on class $class, or $default if that property is not defined

in SS_Object at line 436
static get_static($class, $name, $uncached = false) deprecated

deprecated

Parameters

$class
$name
$uncached

in SS_Object at line 444
static set_static($class, $name, $value) deprecated

deprecated

Parameters

$class
$name
$value

in SS_Object at line 452
static uninherited_static($class, $name, $uncached = false) deprecated

deprecated

Parameters

$class
$name
$uncached

in SS_Object at line 460
static combined_static($class, $name, $ceiling = false) deprecated

deprecated

Parameters

$class
$name
$ceiling

in SS_Object at line 470
static addStaticVars($class, $properties, $replace = false) deprecated

deprecated

Parameters

$class
$properties
$replace

in SS_Object at line 478
static add_static_var($class, $name, $value, $replace = false) deprecated

deprecated

Parameters

$class
$name
$value
$replace

in SS_Object at line 494
static has_extension(string $classOrExtension, string $requiredExtension = null, boolean $strict = false)

Return TRUE if a class has a specified extension.

This supports backwards-compatible format (static Object::has_extension($requiredExtension)) and new format ($object->has_extension($class, $requiredExtension))

Parameters

string $classOrExtension if 1 argument supplied, the class name of the extension to check for; if 2 supplied, the class name to test
string $requiredExtension used only if 2 arguments supplied
boolean $strict if the extension has to match the required extension and not be a subclass

in SS_Object at line 536
static add_extension(string $classOrExtension, string $extension = null)

Add an extension to a specific class.

The preferred method for adding extensions is through YAML config, since it avoids autoloading the class, and is easier to override in more specific configurations.

As an alternative, extensions can be added to a specific class directly in the {@link Object::$extensions} array. See {@link 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 {@link singleton()}).

Parameters

string $classOrExtension Class that should be extended - has to be a subclass of {@link Object}
string $extension Subclass of {@link Extension} with optional parameters as a string, e.g. "Versioned" or "Translatable('Param')"

See also

http://doc.silverstripe.org/framework/en/trunk/reference/dataextension

in SS_Object at line 594
static remove_extension(string $extension)

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 {@link Object} instances which are already created, but will have an effect on new extensions. Clears any previously created singletons through {@link singleton()} to avoid side-effects from stale extension information.

Parameters

string $extension Classname of an {@link Extension} subclass, without parameters

in SS_Object at line 633
static array get_extensions(string $class, bool $includeArgumentString = false)

Parameters

string $class
bool $includeArgumentString Include the argument string in the return array, FALSE would return array("Versioned"), TRUE returns array("Versioned('Stage','Live')").

Return Value

array Numeric array of either {@link DataExtension} classnames, or eval'ed classname strings with constructor arguments.

in SS_Object at line 655
static get_extra_config_sources($class = null)

Parameters

$class

at line 1084
__construct($filename = null, $isSingleton = false, Image $sourceImage = null)

Create a new cached image.

Parameters

$filename
$isSingleton
Image $sourceImage

in SS_Object at line 725
mixed __call(string $method, array $arguments)

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 {@link Extensions}, {@link Object::createMethod()} or {@link Object::addWrapperMethod()}

Parameters

string $method
array $arguments

Return Value

mixed

in SS_Object at line 792
bool hasMethod(string $method)

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

Parameters

string $method

Return Value

bool

in SS_Object at line 802
array allMethodNames(bool $custom = false)

Return the names of all the methods available on this object

Parameters

bool $custom include methods added dynamically at runtime

Return Value

array

in SS_Object at line 963
stat($name, $uncached = false)

Parameters

$name
$uncached

See also

SS_Object::get_static()

in SS_Object at line 970
set_stat($name, $value)

Parameters

$name
$value

See also

SS_Object::set_static()

in SS_Object at line 977
uninherited($name)

Parameters

$name

See also

SS_Object::uninherited_static()

at line 1102
bool exists()

Override the parent's exists method becuase the ID is explicitly set to -1 on a cached image we can't use the default check

Return Value

bool

in SS_Object at line 998
string parentClass()

Return Value

string this classes parent class

in SS_Object at line 1008
bool is_a(string $class)

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

Parameters

string $class

Return Value

bool

in SS_Object at line 1015
string __toString()

Return Value

string the class name

in SS_Object at line 1030
mixed invokeWithExtensions(string $method, mixed $argument = null)

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

Parameters

string $method the method name to call
mixed $argument a single argument to pass

Return Value

mixed

in SS_Object at line 1058
array extend(string $method, mixed $a1 = null, mixed $a2 = null, mixed $a3 = null, mixed $a4 = null, mixed $a5 = null, mixed $a6 = null, mixed $a7 = null)

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.

The extension methods are defined during {@link __construct()} in {@link defineMethods()}.

Parameters

string $method the name of the method to call on each extension
mixed $a1
mixed $a2
mixed $a3
mixed $a4
mixed $a5
mixed $a6
mixed $a7

Return Value

array

in SS_Object at line 1097
Extension getExtensionInstance(string $extension)

Get an extension instance attached to this object by name.

Parameters

string $extension

Return Value

Extension

in SS_Object at line 1115
bool hasExtension(string $extension)

Returns TRUE if this object instance has a specific extension applied in {@link $extension_instances}. Extension instances are initialized at constructor time, meaning if you use {@link add_extension()} afterwards, the added extension will just be added to new instances of the extended class. Use the static method {@link has_extension()} to check if a class (not an instance) has a specific extension.

Caution: Don't use singleton()->hasExtension() as it will give you inconsistent results based on when the singleton was first accessed.

Parameters

string $extension Classname of an {@link Extension} subclass without parameters

Return Value

bool

in SS_Object at line 1126
array getExtensionInstances()

Get all extension instances for this specific object instance.

See {@link get_extensions()} to get all applied extension classes for this class (not the instance).

Return Value

array Map of {@link DataExtension} instances, keyed by classname.

in SS_Object at line 1142
mixed cacheToFile(string $method, int $lifetime = 3600, string $ID = false, array $arguments = array())

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

Parameters

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

Return Value

mixed the cached data

in SS_Object at line 1171
clearCache($method, $ID = false, $arguments = array())

Clears the cache for the given cacheToFile call

Parameters

$method
$ID
$arguments

in ViewableData at line 72
static string castingObjectCreator(string $fieldSchema)

Converts a field spec into an object creator. For example: "Int" becomes "new Int($fieldName);" and "Varchar(50)" becomes "new Varchar($fieldName, 50);".

Parameters

string $fieldSchema The field spec

Return Value

string

in ViewableData at line 83
static array castingObjectCreatorPair(string $fieldSchema)

Convert a field schema (e.g. "Varchar(50)") into a casting object creator array that contains both a className and castingHelper constructor code. See {@link castingObjectCreator} for more information about the constructor.

Parameters

string $fieldSchema

Return Value

array

in ViewableData at line 95
bool __isset(string $property)

Check if a field exists on this object or its failover.

Parameters

string $property

Return Value

bool

in ViewableData at line 117
mixed __get(string $property)

Get the value of a property/field on this object. This will check if a method called get{$property} exists, then check if a field is available using {@link ViewableData::getField()}, then fall back on a failover object.

Parameters

string $property

Return Value

mixed

in ViewableData at line 138
__set(string $property, mixed $value)

Set a property/field on this object. This will check for the existence of a method called set{$property}, then use the {@link ViewableData::setField()} method.

Parameters

string $property
mixed $value

in ViewableData at line 151
setFailover(ViewableData $failover)

Set a failover object to attempt to get data from if it is not present on this object.

Parameters

ViewableData $failover

in ViewableData at line 166
ViewableData|null getFailover()

Get the current failover object if set

Return Value

ViewableData|null

in DataObject at line 2778
bool hasField(string $field)

Returns true if the given field exists in a database column on any of the objects tables and optionally look up a dynamic getter with get().

Parameters

string $field

Return Value

bool

in DataObject at line 2456
mixed getField(string $field)

Gets the value of a field.

Called by {@link __get()} and any getFieldName() methods you might create.

Parameters

string $field

Return Value

mixed

in DataObject at line 2663
setField(string $fieldName, mixed $val)

Set the value of the field Called by {@link __set()} and any setFieldName() methods you might create.

Parameters

string $fieldName Name of the field
mixed $val New field value

in Image at line 110
defineMethods()

Set up template methods to access the transformations generated by 'generate' methods.

in ViewableData at line 236
unknown deprecatedCachedCall($method, $args = null, $identifier = null)

Method to facilitate deprecation of underscore-prefixed methods automatically being cached.

Parameters

$method
$args
$identifier

Return Value

unknown

in ViewableData at line 255
ViewableData_Customised customise(array|ViewableData $data)

Merge some arbitrary data in with this object. This method returns a {@link ViewableData_Customised} instance with references to both this and the new custom data.

Note that any fields you specify will take precedence over the fields on this object.

Parameters

array|ViewableData $data

Return Value

ViewableData_Customised

in ViewableData at line 272
ViewableData getCustomisedObj()

Return Value

ViewableData

in ViewableData at line 279
setCustomisedObj(ViewableData $object)

Parameters

ViewableData $object

in ViewableData at line 296
array castingHelperPair(string $field)

Get the class a field on this object would be casted to, as well as the casting helper for casting a field to an object (see {@link ViewableData::castingHelper()} for information on casting helpers).

The returned array contains two keys: - className: the class the field would be casted to (e.g. "Varchar") - castingHelper: the casting helper for casting the field (e.g. "return new Varchar($fieldName)")

Parameters

string $field

Return Value

array

in DataObject at line 2751
string castingHelper(string $field)

Return the "casting helper" (a piece of PHP code that when evaluated creates a casted value object) for a field on this object.

Parameters

string $field

Return Value

string

in ViewableData at line 331
string castingClass(string $field)

Get the class name a field on this object will be casted to

Parameters

string $field

Return Value

string

in ViewableData at line 346
string escapeTypeForField(string $field)

Return the string-format type for the given field.

Parameters

string $field

Return Value

string 'xml'|'raw'

in ViewableData at line 357
buildCastingCache(reference $cache)

Save the casting cache for this object (including data from any failovers) into a variable

Parameters

reference $cache

in ViewableData at line 394
HTMLText renderWith(string|array|SSViewer $template, array $customFields = null)

Render this object into the template, and get the result as a string. You can pass one of the following as the $template parameter: - a template name (e.g. Page) - an array of possible template names - the first valid one will be used - an SSViewer instance

Parameters

string|array|SSViewer $template the template to render into
array $customFields fields to customise() the object with before rendering

Return Value

HTMLText

in ViewableData at line 456
obj(string $fieldName, array $arguments = null, bool $forceReturnedObject = true, bool $cache = false, string $cacheName = null)

Get the value of a field on this object, automatically inserting the value into any available casting objects that have been specified.

Parameters

string $fieldName
array $arguments
bool $forceReturnedObject if TRUE, the value will ALWAYS be casted to an object before being returned, even if there is no explicit casting information
bool $cache Cache this object
string $cacheName a custom cache name

in ViewableData at line 503
cachedCall(string $field, array $arguments = null, string $identifier = null)

A simple wrapper around {@link ViewableData::obj()} that automatically caches the result so it can be used again without re-running the method.

Parameters

string $field
array $arguments
string $identifier an optional custom cache identifier

in DataObject at line 4167
bool hasValue(string $field, array $arguments = null, bool $cache = true)

Returns true if the given method/parameter has a value (Uses the DBField::hasValue if the parameter is a database field)

Parameters

string $field
array $arguments
bool $cache

Return Value

bool

in ViewableData at line 538
XML_val($field, $arguments = null, $cache = false)

Get the string value of a field on this object that has been suitable escaped to be inserted directly into a template.

Parameters

$field
$arguments
$cache

in ViewableData at line 546
RAW_val($field, $arguments = null, $cache = true)

Return the value of the field without any escaping being applied.

Parameters

$field
$arguments
$cache

in ViewableData at line 553
SQL_val($field, $arguments = null, $cache = true)

Return the value of a field in an SQL-safe format.

Parameters

$field
$arguments
$cache

in ViewableData at line 560
JS_val($field, $arguments = null, $cache = true)

Return the value of a field in a JavaScript-save format.

Parameters

$field
$arguments
$cache

in ViewableData at line 567
ATT_val($field, $arguments = null, $cache = true)

Return the value of a field escaped suitable to be inserted into an XML node attribute.

Parameters

$field
$arguments
$cache

in ViewableData at line 579
array getXMLValues($fields)

Get an array of XML-escaped values by field name

Parameters

$fields

Return Value

array

in ViewableData at line 599
ArrayIterator getIterator()

Return a single-item iterator so you can iterate over the fields of a single record.

This is useful so you can use a single record inside a <% control %> block in a template - and then use to access individual fields on this object.

Return Value

ArrayIterator

in ViewableData at line 611
ViewableData Me()

When rendering some objects it is necessary to iterate over the object being rendered, to do this, you need access to itself.

Return Value

ViewableData

in ViewableData at line 627
string ThemeDir(string $subtheme = false)

Return the directory if the current active theme (relative to the site root).

This method is useful for things such as accessing theme images from your template without hardcoding the theme page - e.g. .

This method should only be used when a theme is currently active. However, it will fall over to the current project directory.

Parameters

string $subtheme the subtheme path to get

Return Value

string

in ViewableData at line 648
string CSSClasses(string $stopAtClass = 'ViewableData')

Get part of the current classes ancestry to be used as a CSS class.

This method returns an escaped string of CSS classes representing the current classes ancestry until it hits a stop point - e.g. "Page DataObject ViewableData".

Parameters

string $stopAtClass the class to stop at (default: ViewableData)

Return Value

string

in ViewableData at line 671
ViewableData_Debugger Debug()

Return debug information about this object that can be rendered into a template

Return Value

ViewableData_Debugger

in DataObject at line 211
static bool get_validation_enabled() deprecated

deprecated 3.2 Use the "DataObject.validation_enabled" config setting instead

Returns when validation on DataObjects is enabled.

Return Value

bool

in DataObject at line 227
static set_validation_enabled($enable) deprecated

deprecated 3.2 Use the "DataObject.validation_enabled" config setting instead

Set whether DataObjects should be validated before they are written.

Caution: Validation can contain safeguards against invalid/malicious data, and check permission levels (e.g. on {@link Group}). Therefore it is recommended to only disable validation for very specific use cases.

Parameters

$enable bool

See also

DataObject::validate()

in DataObject at line 241
static clear_classname_spec_cache()

Clear all cached classname specs. It's necessary to clear all cached subclassed names for any classes if a new class manifest is generated.

in DataObject at line 254
static string get_classname_spec(string $class, boolean $queryDB = true)

Determines the specification for the ClassName field for the given class

Parameters

string $class
boolean $queryDB Determine if the DB may be queried for additional information

Return Value

string Resulting ClassName spec. If $queryDB is true this will include all legacy types that no longer have concrete classes in PHP

in DataObject at line 281
static array database_fields(string $class, boolean $queryDB = true)

Return the complete map of fields on this object, including "Created", "LastEdited" and "ClassName".

See {@link custom_database_fields()} for a getter that excludes these "base fields".

Parameters

string $class
boolean $queryDB Determine if the DB may be queried for additional information

Return Value

array

in DataObject at line 310
static array custom_database_fields(string $class)

Get all database columns explicitly defined on a class in {@link DataObject::$db} and {@link DataObject::$has_one}. Resolves instances of {@link CompositeDBField} into the actual database fields, rather than the name of the field which might not equate a database column.

Does not include "base fields" like "ID", "ClassName", "Created", "LastEdited", see {@link database_fields()}.

Parameters

string $class

Return Value

array Map of fieldname to specification, similiar to {@link DataObject::$db}.

in DataObject at line 363
static string is_composite_field(string $class, string $name, boolean $aggregated = true)

Returns the field class if the given db field on the class is a composite field.

Will check all applicable ancestor classes and aggregate results.

Parameters

string $class Class to check
string $name Field to check
boolean $aggregated True if parent classes should be checked, or false to limit to this class

Return Value

string Class name of composite field if it exists

in DataObject at line 389
static composite_fields($class, $aggregated = true)

Returns a list of all the composite if the given db field on the class is a composite field.

Will check all applicable ancestor classes and aggregate results.

Parameters

$class
$aggregated

in DataObject at line 510
DataObject setDataModel(DataModel $model)

Set the DataModel

Parameters

DataModel $model

Return Value

DataObject $this

in DataObject at line 519
destroy()

Destroy all of this objects dependant objects and local caches.

You'll need to call this to get the memory of an object that has components or extensions freed.

in DataObject at line 533
DataObject duplicate($doWrite = true)

Create a duplicate of this node.

Note: now also duplicates relations.

Parameters

$doWrite Perform a write() operation before returning the object. If this is true, it will create the duplicate in the database.

Return Value

DataObject A duplicate of this node. The exact type will be the type of this node.

in DataObject at line 614
getObsoleteClassName()

in DataObject at line 619
getClassName()

in DataObject at line 635
DataObject setClassName(string $className)

Set the ClassName attribute. {@link $class} is also updated.

Warning: This will produce an inconsistent record, as the object instance will not automatically switch to the new subclass. Please use {@link newClassInstance()} for this purpose, or destroy and reinstanciate the record.

Parameters

string $className The new ClassName attribute (a subclass of {@link DataObject})

Return Value

DataObject $this

in DataObject at line 660
DataObject newClassInstance(string $newClassName)

Create a new instance of a different class from this object's record.

This is useful when dynamically changing the type of an instance. Specifically, it ensures that the instance of the class is a match for the className of the record. Don't set the {@link DataObject->class} or {@link DataObject->ClassName} property manually before calling this method, as it will confuse change detection.

If the new class is different to the original class, defaults are populated again because this will only occur automatically on instantiation of a DataObject if there is no record, or the record has no ID. In this case, we do have an ID but we still need to repopulate the defaults.

Parameters

string $newClassName The name of the new class

Return Value

DataObject The new instance of the new class, The exact type will be of the class name provided.

in DataObject at line 743
boolean isEmpty()

Returns TRUE if all values (other than "ID") are considered empty (by weak boolean comparison).

Only checks for fields listed in {@link custom_database_fields()}

Return Value

boolean

in DataObject at line 765
string singular_name()

Get the user friendly singular name of this DataObject.

If the name is not defined (by redefining $singular_name in the subclass), this returns the class name.

Return Value

string User friendly singular name of this DataObject

in DataObject at line 784
string i18n_singular_name()

Get the translated user friendly singular name of this DataObject same as singular_name() but runs it through the translating function

Translating string is in the form: $this->class.SINGULARNAME Example: Page.SINGULARNAME

Return Value

string User friendly translated singular name of this DataObject

in DataObject at line 795
string plural_name()

Get the user friendly plural name of this DataObject If the name is not defined (by renaming $plural_name in the subclass), this returns a pluralised version of the class name.

Return Value

string User friendly plural name of this DataObject

in DataObject at line 818
string i18n_plural_name()

Get the translated user friendly plural name of this DataObject Same as plural_name but runs it through the translation function Translation string is in the form: $this->class.PLURALNAME Example: Page.PLURALNAME

Return Value

string User friendly translated plural name of this DataObject

in DataObject at line 841
string getTitle()

Standard implementation of a title/label for a specific record. Tries to find properties 'Title' or 'Name', and falls back to the 'ID'. Useful to provide user-friendly identification of a record, e.g. in errormessages or UI-selections.

Overload this method to have a more specialized implementation, e.g. for an Address record this could be: function getTitle() { return "{$this->StreetNumber} {$this->StreetName} {$this->City}"; }

Return Value

string

in DataObject at line 854
DataObject data()

Returns the associated database record - in this case, the object itself.

This is included so that you can call $dataOrController->data() and get a DataObject all the time.

Return Value

DataObject Associated database record

in DataObject at line 863
array toMap()

Convert this object to a map.

Return Value

array The data as a map.

in DataObject at line 876
array getQueriedDatabaseFields()

Return all currently fetched database fields.

This function is similar to toMap() but doesn't trigger the lazy-loading of all unfetched fields. Obviously, this makes it a lot faster.

Return Value

array The data as a map.

in DataObject at line 892
DataObject update(array $data)

Update a number of fields on this object, given a map of the desired changes.

The field names can be simple names, or you can use a dot syntax to access $has_one relations. For example, array("Author.FirstName" => "Jim") will set $this->Author()->FirstName to "Jim".

update() doesn't write the main object, but if you use the dot syntax, it will write() the related objects that it alters.

Parameters

array $data A map of field name to data values to update.

Return Value

DataObject $this

in DataObject at line 949
DataObject castedUpdate(array $data)

Pass changes as a map, and try to get automatic casting for these fields.

Doesn't write to the database. To write the data, use the write() method.

Parameters

array $data A map of field name to data values to update.

Return Value

DataObject $this

in DataObject at line 977
Boolean merge($rightObj, $priority = 'right', $includeRelations = true, $overwriteWithEmpty = false)

Merges data and relations from another object of same class, without conflict resolution. Allows to specify which dataset takes priority in case its not empty.

has_one-relations are just transferred with priority 'right'. has_many and many_many-relations are added regardless of priority.

Caution: has_many/many_many relations are moved rather than duplicated, meaning they are not connected to the merged object any longer. Caution: Just saves updated has_many/many_many relations to the database, doesn't write the updated object itself (just writes the object-properties). Caution: Does not delete the merged object. Caution: Does now overwrite Created date on the original object.

Parameters

$rightObj
$priority
$includeRelations
$overwriteWithEmpty

Return Value

Boolean

in DataObject at line 1054
$this forceChange()

Forces the record to think that all its data has changed.

Doesn't write to the database. Only sets fields as changed if they are not already marked as changed.

Return Value

$this

in DataObject at line 1101
ValidationResult doValidate()

Public accessor for {see DataObject::validate()}

Return Value

ValidationResult

in DataObject at line 1161
DataObject populateDefaults()

Load the default values in from the self::$defaults array.

Will traverse the defaults of the current class and all its parent classes. Called by the constructor when creating new records.

Return Value

DataObject $this

at line 1124
write(boolean $showDebug = false, boolean $forceInsert = false, boolean $forceWrite = false, boolean $writeComponents = false)

Prevent writing the cached image to the database

Parameters

boolean $showDebug Show debugging information
boolean $forceInsert Run INSERT command rather than UPDATE, even if record already exists
boolean $forceWrite Write to database even if there are no changes
boolean $writeComponents Call write() on all associated component instances which were previously retrieved through {@link getComponent()}, {@link getComponents()} or {@link getManyManyComponents()} (Default: false)

Exceptions

Exception

in DataObject at line 1450
writeRelations()

Writes cached relation lists to the database, if possible

in DataObject at line 1469
DataObject writeComponents($recursive = false)

Write the cached components to the database. Cached components could refer to two different instances of the same record.

Parameters

$recursive Recursively write components

Return Value

DataObject $this

in DataObject at line 1484
delete()

Delete this data object.

$this->onBeforeDelete() gets called. Note that in Versioned objects, both Stage and Live will be deleted.

in DataObject at line 1519
static delete_by_id(string $className, int $id)

Delete the record with the given ID.

Parameters

string $className The class name of the record to be deleted
int $id ID of record to be deleted

in DataObject at line 1536
array getClassAncestry()

Get the class ancestry, including the current class name.

The ancestry will be returned as an array of class names, where the 0th element will be the class that inherits directly from DataObject, and the last element will be the current class.

Return Value

array Class ancestry

in DataObject at line 1555
DataObject getComponent(string $componentName)

Return a component object from a one to one relationship, as a DataObject.

If no component is available, an 'empty component' will be returned for non-polymorphic relations, or for polymorphic relations with a class set.

Parameters

string $componentName Name of the component

Return Value

DataObject The component object. It's exact type will be that of the component.

in DataObject at line 1624
HasManyList getComponents(string $componentName, string|null $filter = null, string|null|array $sort = null, string $join = null, string|null|array $limit = null)

Returns a one-to-many relation as a HasManyList

Parameters

string $componentName Name of the component
string|null $filter Deprecated. A filter to be inserted into the WHERE clause
string|null|array $sort Deprecated. A sort expression to be inserted into the ORDER BY clause. If omitted, the static field $default_sort on the component class will be used.
string $join Deprecated, use leftJoin($table, $joinClause) instead
string|null|array $limit Deprecated. A limit expression to be inserted into the LIMIT clause

Return Value

HasManyList The components of the one-to-many relationship.

in DataObject at line 1674
getComponentsQuery($componentName, $filter = "", $sort = "", $join = "", $limit = "") deprecated

deprecated

Parameters

$componentName
$filter
$sort
$join
$limit

in DataObject at line 1685
string getRelationClass($relationName)

Find the foreign class of a relation on this DataObject, regardless of the relation type.

Parameters

$relationName Relation name.

Return Value

string Class name, or null if not found.

in DataObject at line 1723
string getRemoteJoinField(string $component, string $type = 'has_many', boolean $polymorphic = false)

Tries to find the database key on another object that is used to store a relationship to this class. If no join field can be found it defaults to 'ParentID'.

If the remote field is polymorphic then $polymorphic is set to true, and the return value is in the form 'Relation' instead of 'RelationID', referencing the composite DBField.

Parameters

string $component Name of the relation on the current object pointing to the remote object.
string $type the join type - either 'has_many' or 'belongs_to'
boolean $polymorphic Flag set to true if the remote join field is polymorphic.

Return Value

string

in DataObject at line 1799
ManyManyList getManyManyComponents($componentName, $filter = null, $sort = null, $join = null, $limit = null)

Returns a many-to-many component, as a ManyManyList.

Parameters

$componentName
$filter
$sort
$join
$limit

Return Value

ManyManyList The set of components

in DataObject at line 1845
array|null has_one(string $component = null) deprecated

deprecated 4.0 Method has been replaced by hasOne() and hasOneComponent()

Parameters

string $component

Return Value

array|null

in DataObject at line 1863
string|array hasOne(string $component = null)

Return the class of a one-to-one component. If $component is null, return all of the one-to-one components and their classes. If the selected has_one is a polymorphic field then 'DataObject' will be returned for the type.

Parameters

string $component Deprecated - Name of component

Return Value

string|array The class of the one-to-one component, or an array of all one-to-one components and their classes.

in DataObject at line 1881
string|null hasOneComponent(string $component)

Return data for a specific has_one component.

Parameters

string $component

Return Value

string|null

in DataObject at line 1895
array|null belongs_to(string $component = null, bool $classOnly = true) deprecated

deprecated 4.0 Method has been replaced by belongsTo() and belongsToComponent()

Parameters

string $component
bool $classOnly

Return Value

array|null

in DataObject at line 1914
string|array belongsTo(string $component = null, bool $classOnly = true)

Returns the class of a remote belongs_to relationship. If no component is specified a map of all components and their class name will be returned.

Parameters

string $component
  • Name of component
bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have the field data stripped off. It defaults to TRUE.

Return Value

string|array

in DataObject at line 1939
string|false belongsToComponent(string $component, bool $classOnly = true)

Return data for a specific belongs_to component.

Parameters

string $component
bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have the field data stripped off. It defaults to TRUE.

Return Value

string|false

in DataObject at line 1958
array db(string $fieldName = null)

Return all of the database fields defined in self::$db and all the parent classes.

Doesn't include any fields specified by self::$has_one. Use $this->hasOne() to get these fields

Parameters

string $fieldName Limit the output to a specific field name

Return Value

array The database fields

in DataObject at line 1996
array|null has_many(string $component = null, bool $classOnly = true) deprecated

deprecated 4.0 Method has been replaced by hasMany() and hasManyComponent()

Parameters

string $component
bool $classOnly

Return Value

array|null

in DataObject at line 2015
string|array|false hasMany(string $component = null, bool $classOnly = true)

Gets the class of a one-to-many relationship. If no $component is specified then an array of all the one-to-many relationships and their classes will be returned.

Parameters

string $component Deprecated - Name of component
bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have the field data stripped off. It defaults to TRUE.

Return Value

string|array|false

in DataObject at line 2040
string|false hasManyComponent(string $component, bool $classOnly = true)

Return data for a specific has_many component.

Parameters

string $component
bool $classOnly If this is TRUE, than any has_many relationships in the form "ClassName.Field" will have the field data stripped off. It defaults to TRUE.

Return Value

string|false

in DataObject at line 2058
array many_many_extraFields(string $component = null) deprecated

deprecated 4.0 Method has been replaced by manyManyExtraFields() and manyManyExtraFieldsForComponent()

Parameters

string $component

Return Value

array

in DataObject at line 2077
array|null manyManyExtraFields(string $component = null)

Return the many-to-many extra fields specification.

If you don't specify a component name, it returns all extra fields for all components available.

Parameters

string $component Deprecated - Name of component

Return Value

array|null

in DataObject at line 2096
array|null manyManyExtraFieldsForComponent(string $component)

Return the many-to-many extra fields specification for a specific component.

Parameters

string $component

Return Value

array|null

in DataObject at line 2142
array|null many_many(string $component = null) deprecated

deprecated 4.0 Method has been renamed to manyMany()

Parameters

string $component

Return Value

array|null

in DataObject at line 2161
array|null manyMany(string $component = null)

Return information about a many-to-many component.

The return value is an array of (parentclass, childclass). If $component is null, then all many-many components are returned.

Parameters

string $component Deprecated - Name of component

Return Value

array|null An array of (parentclass, childclass), or an array of all many-many components

See also

DataObject::manyManyComponent()

in DataObject at line 2190
array|null manyManyComponent(string $component)

Return information about a specific many_many component. Returns a numeric array of: array( , The class that relation is defined in e.g. "Product" , The target class of the relation e.g. "Category" , The field name pointing to 's table e.g. "ProductID" , The field name pointing to 's table e.g. "CategoryID" The join table between the two classes e.g. "Product_Categories" )

Parameters

string $component The component name

Return Value

array|null

in DataObject at line 2253
array database_extensions($class)

This returns an array (if it exists) describing the database extensions that are required, or false if none

This is experimental, and is currently only a Postgres-specific enhancement.

Parameters

$class

Return Value

array or false

in DataObject at line 2268
SearchContext getDefaultSearchContext()

Generates a SearchContext to be used for building and processing a generic search form for properties on this object.

Return Value

SearchContext

in DataObject at line 2291
FieldList scaffoldSearchFields(array $_params = null)

Determine which properties on the DataObject are searchable, and map them to their default {@link FormField} representations. Used for scaffolding a searchform for {@link ModelAdmin}.

Some additional logic is included for switching field labels, based on how generic or specific the field type is.

Used by {@link SearchContext}.

Parameters

array $_params 'fieldClasses': Associative array of field names as keys and FormField classes as values 'restrictFields': Numeric array of a field name whitelist

Return Value

FieldList

in DataObject at line 2349
FieldList scaffoldFormFields(array $_params = null)

Scaffold a simple edit form for all properties on this dataobject, based on default {@link FormField} mapping in {@link DBField::scaffoldFormField()}.

Field labels/titles will be auto generated from {@link DataObject::fieldLabels()}.

Parameters

array $_params Associative array passing through properties to {@link FormScaffolder}.

Return Value

FieldList

in Image at line 121
FieldList getCMSFields()

Returns the fields to power the edit screen of files in the CMS.

You can modify this FieldList by subclassing folder, or by creating a {@link DataExtension} and implemeting updateCMSFields(FieldList $fields) on that extension.

Return Value

FieldList Returns a TabSet for usage within the CMS - don't use for frontend forms.

in DataObject at line 2423
an getCMSActions()

need to be overload by solid dataobject, so that the customised actions of that dataobject, including that dataobject's extensions customised actions could be added to the EditForm.

Return Value

an Empty FieldList(); need to be overload by solid subclass

in DataObject at line 2441
FieldList getFrontEndFields(array $params = null)

Used for simple frontend forms without relation editing or {@link TabSet} behaviour. Uses {@link scaffoldFormFields()} by default. To customize, either overload this method in your subclass, or extend it by {@link DataExtension->updateFrontEndFields()}.

Parameters

array $params See {@link scaffoldFormFields()}

Return Value

FieldList Always returns a simple field collection without TabSet.

in DataObject at line 2590
array getChangedFields(boolean $databaseFieldsOnly = false, int $changeLevel = self::CHANGE_STRICT)

Return the fields that have changed.

The change level affects what the functions defines as "changed": - Level CHANGE_STRICT (integer 1) will return strict changes, even !== ones. - Level CHANGE_VALUE (integer 2) is more lenient, it will only return real data changes, for example a change from 0 to null would not be included.

Example return: array( 'Title' = array('before' => 'Home', 'after' => 'Home-Changed', 'level' => DataObject::CHANGE_VALUE) )

Parameters

boolean $databaseFieldsOnly Get only database fields that have changed
int $changeLevel The strictness of what is defined as change. Defaults to strict

Return Value

array

in DataObject at line 2643
boolean isChanged(string $fieldName = null, int $changeLevel = self::CHANGE_STRICT)

Uses {@link getChangedFields()} to determine if fields have been changed since loading them from the database.

Parameters

string $fieldName Name of the database field to check, will check for any if not given
int $changeLevel See {@link getChangedFields()}

Return Value

boolean

in DataObject at line 2733
setCastedField($fieldName, $val)

Set the value of the field, using a casting object.

This is useful when you aren't sure that a date is in SQL format, for example. setCastedField() can also be used, by forms, to set related data. For example, uploaded images can be saved into the Image table.

Parameters

$fieldName
$val

in DataObject at line 2794
boolean hasDatabaseField(string $field)

Returns true if the given field exists as a database column

Parameters

string $field Name of the field

Return Value

boolean

in DataObject at line 2807
string hasOwnTableDatabaseField(string $field)

Returns the field type of the given field, if it belongs to this class, and not a parent.

Note that the field type will not include constructor arguments in round brackets, only the classname.

Parameters

string $field Name of the field

Return Value

string The field type of the given field

in DataObject at line 2819
static string has_own_table_database_field(string $class, string $field)

Returns the field type of the given field, if it belongs to this class, and not a parent.

Note that the field type will not include constructor arguments in round brackets, only the classname.

Parameters

string $class Class name to check
string $field Name of the field

Return Value

string The field type of the given field

in DataObject at line 2840
static bool has_own_table(string $dataClass)

Returns true if given class has its own table. Uses the rules for whether the table should exist rather than actually looking in the database.

Parameters

string $dataClass

Return Value

bool

in DataObject at line 2866
boolean can(string $perm, Member $member = null)

Returns true if the member is allowed to do the given action.

See {@link extendedCan()} for a more versatile tri-state permission control.

Parameters

string $perm The permission to be checked, such as 'View'.
Member $member The member whose permissions need checking. Defaults to the currently logged in user.

Return Value

boolean True if the the member is allowed to do the given action

in DataObject at line 2946
boolean|null extendedCan(String $methodName, Member|int $member)

Process tri-state responses from permission-alterting extensions. The extensions are expected to return one of three values:

  • false: Disallow this permission, regardless of what other extensions say
    • true: Allow this permission, as long as no other extensions return false
    • NULL: Don't affect the outcome

This method itself returns a tri-state value, and is designed to be used like this:

$extended = $this->extendedCan('canDoSomething', $member); if($extended !== null) return $extended; else return $normalValue;

Parameters

String $methodName Method on the same object, e.g. {@link canEdit()}
Member|int $member

Return Value

boolean|null

in File at line 315
boolean canView(Member $member = null)

Parameters

Member $member

Return Value

boolean

in File at line 332
boolean canEdit(Member $member = null)

Returns true if the following conditions are met: - CMS_ACCESS_AssetAdmin

Parameters

Member $member

Return Value

boolean

in File at line 356
boolean canDelete(Member $member = null)

Parameters

Member $member

Return Value

boolean

in File at line 344
boolean canCreate(Member $member = null)

Parameters

Member $member

Return Value

boolean

in DataObject at line 3013
string debug()

Debugging used by Debug::show()

Return Value

string HTML data representing this object

in DataObject at line 3032
DBField dbObject(string $fieldName)

Return the DBField object that represents the given field.

This works similarly to obj() with 2 key differences: - it still returns an object even when the field has no value. - it only matches fields and not methods - it matches foreign keys generated by has_one relationships, eg, "ParentID"

Parameters

string $fieldName Name of the field

Return Value

DBField The field as a DBField object

in DataObject at line 3078
mixed relObject(string $fieldPath)

Traverses to a DBField referenced by relationships between data objects.

The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName).

Parameters

string $fieldPath

Return Value

mixed DBField of the field on the object or a DataList instance.

in DataObject at line 3116
string relField($fieldName)

Traverses to a field referenced by relationships between data objects, returning the value The path to the related field is specified with dot separated syntax (eg: Parent.Child.Child.FieldName)

Parameters

$fieldName

Return Value

string | null - will return null on a missing value

in DataObject at line 3161
String getReverseAssociation($className)

Temporary hack to return an association name, based on class, to get around the mangle of having to deal with reverse lookup of relationships to determine autogenerated foreign keys.

Parameters

$className

Return Value

String

in DataObject at line 3195
static DataList get(string $callerClass = null, string|array $filter = "", string|array $sort = "", string $join = "", string|array $limit = null, string $containerClass = 'DataList')

Return all objects matching the filter sub-classes are automatically selected and included

Parameters

string $callerClass The class of objects to be returned
string|array $filter A filter to be inserted into the WHERE clause. Supports parameterised queries. See SQLQuery::addWhere() for syntax examples.
string|array $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used.
string $join Deprecated 3.0 Join clause. Use leftJoin($table, $joinClause) instead.
string|array $limit A limit expression to be inserted into the LIMIT clause.
string $containerClass The container class to return the results in.

Return Value

DataList The objects matching the filter, in the class specified by $containerClass

in DataObject at line 3237
Aggregate($class = null) deprecated

deprecated

Parameters

$class

in DataObject at line 3258
RelationshipAggregate($relationship) deprecated

deprecated

Parameters

$relationship

in DataObject at line 3276
static DataObject get_one(string $callerClass, string|array $filter = "", boolean $cache = true, string $orderby = "")

Return the first item matching the given query.

All calls to get_one() are cached.

Parameters

string $callerClass The class of objects to be returned
string|array $filter A filter to be inserted into the WHERE clause. Supports parameterised queries. See SQLQuery::addWhere() for syntax examples.
boolean $cache Use caching
string $orderby A sort expression to be inserted into the ORDER BY clause.

Return Value

DataObject The first item matching the query

in File at line 925
DataObject flushCache($persistant = true)

Flush the cached results for all relations (has_one, has_many, many_many) Also clears any cached aggregate data.

Parameters

$persistant

Return Value

DataObject $this

in DataObject at line 3333
static flush_and_destroy_cache()

Flush the get_one global cache and destroy associated objects.

in DataObject at line 3345
static reset()

Reset all global caches associated with DataObject.

in DataObject at line 3366
static DataObject get_by_id(string $callerClass, int $id, boolean $cache = true)

Return the given element, searching by ID

Parameters

string $callerClass The class of the object to be returned
int $id The id of the element
boolean $cache See {@link get_one()}

Return Value

DataObject The element

in DataObject at line 3387
baseTable()

Get the name of the base table for this object

in DataObject at line 3403
array getSourceQueryParams()

Return Value

array

See also

$sourceQueryParams

in DataObject at line 3411
setSourceQueryParams(array $array)

Parameters

array $array

See also

$sourceQueryParams

in DataObject at line 3419
setSourceQueryParam($key, $value)

Parameters

$key
$value

See also

$sourceQueryParams

in DataObject at line 3427
Mixed getSourceQueryParam($key)

Parameters

$key

Return Value

Mixed

See also

$sourceQueryParams

in DataObject at line 3439
databaseIndexes()

Return the database indexes on this table.

This array is indexed by the name of the field with the index, and the value is the type of index.

at line 1115
requireTable()

Prevent creating new tables for the cached record

in DataObject at line 3611
requireDefaultRecords()

Add default records to database. This function is called whenever the database is built, after the database tables have all been created. Overload this to add default records when the database is built, but make sure you call parent::requireDefaultRecords().

in DataObject at line 3640
inheritedDatabaseFields()

Returns fields bu traversing the class heirachy in a bottom-up direction.

Needed to avoid getCMSFields being empty when customDatabaseFields overlooks the inheritance chain of the $db array, where a child data object has no $db array, but still needs to know the properties of its parent. This should be merged into databaseFields or customDatabaseFields.

in DataObject at line 3659
array searchableFields()

Get the default searchable fields for this object, as defined in the $searchable_fields list. If searchable fields are not defined on the data object, uses a default selection of summary fields.

Return Value

array

in File at line 936
array|string fieldLabels(boolean $includerelations = true)

Parameters

boolean $includerelations a boolean value to indicate if the labels returned include relation fields

Return Value

array|string Array of all element labels if no argument given, otherwise the label of the field

in DataObject at line 3802
string fieldLabel(string $name)

Get a human-readable label for a single field, see {@link fieldLabels()} for more details.

Parameters

string $name Name of the field

Return Value

string Label of the field

in DataObject at line 3814
array summaryFields()

Get the default summary fields for this object.

Return Value

array

in DataObject at line 3864
array defaultSearchFilters()

Defines a default list of filters for the search context.

If a filter class mapping is defined on the data object, it is constructed here. Otherwise, the default filter specified in {@link DBField} is used.

Return Value

array

in DataObject at line 3889
boolean isInDB()

Return Value

boolean True if the object is in the database

in DataObject at line 3901
static disable_subclass_access()

Temporarily disable subclass access in data object qeur

in DataObject at line 3904
static enable_subclass_access()

in DataObject at line 4139
array provideI18nEntities()

Collect all static properties on the object which contain natural language, and need to be translated.

The full entity name is composed from the class name and a custom identifier.

Return Value

array All entites in an associative array, with entity name as the key, and a numerical array of pseudo-arguments for _t() as a value.

Replace "[file_link id=n]" shortcode with an anchor tag or link to the file.

Parameters

$arguments array Arguments to the shortcode
$content string Content of the returned link (optional)
$parser object Specify a parser to parse the content (see {@link ShortCodeParser})

Return Value

string anchor HTML tag if content argument given, otherwise file path link

in File at line 239
static mixed find(String $filename)

Find a File object by the given filename.

Parameters

String $filename Matched against the "Name" property.

Return Value

mixed null if not found, File object of found file

Just an alias function to keep a consistent API with SiteTree

Return Value

string The link to the file

Just an alias function to keep a consistent API with SiteTree

Return Value

string The relative link to the file

Just an alias function to keep a consistent API with SiteTree

Return Value

string The absolute link to the file

in File at line 290
string getTreeTitle()

Return Value

string

in File at line 454
static String get_app_category($ext)

Returns a category based on the file extension.

This can be useful when grouping files by type, showing icons on filelinks, etc. Possible group values are: "audio", "mov", "zip", "image".

Parameters

$ext

Return Value

String

in File at line 467
String appCategory()

Returns a category based on the file extension.

Return Value

String

in Image at line 644
HTMLVarchar StripThumbnail()

Resize this image for use as a thumbnail in a strip. Use in templates with $StripThumbnail.

Return Value

HTMLVarchar

in Image at line 602
CMSThumbnail()

Resize this image for the CMS. Use in templates with $CMSThumbnail

in File at line 491
String Icon()

Return the relative URL of an icon for the file type, based on the {@link appCategory()} value.

Images are searched for in "framework/images/app_icons/".

Return Value

String

in Image at line 1051
onAfterUpload()

Should be called after the file was uploaded

in File at line 514
deleteDatabaseOnly()

Delete the database record (recursively for folders) without touching the filesystem

in File at line 557
updateFilesystem()

Moving the file if appropriate according to updated database content.

Throws an Exception if the new file already exists.

Caution: This method should just be called during a {@link write()} invocation, as it relies on {@link DataObject->isChanged()}, which is reset after a {@link write()} call. Might be called as {@link File->updateFilesystem()} from within {@link Folder->updateFilesystem()}, so it has to handle both files and folders.

Assumes that the "Filename" property was previously updated, either directly or indirectly. (it might have been influenced by {@link setName()} or {@link setParentID()} before).

in File at line 618
collateDescendants(condition $condition, collator $collator)

Collate selected descendants of this page.

$condition will be evaluated on each descendant, and if it is succeeds, that item will be added to the $collator array.

Parameters

condition $condition The PHP condition to be evaluated. The page will be called $item
collator $collator An array, passed by reference, to collect all of the matching descendants.

in File at line 639
setName(string $name)

Setter function for Name. Automatically sets a default title, and removes characters that might be invalid on the filesystem.

Also adds a suffix to the name if the filename already exists on the filesystem, and is associated to a different {@link File} database record in the same folder. This means "myfile.jpg" might become "myfile-1.jpg".

Does not change the filesystem itself, please use {@link write()} for this.

Parameters

string $name

in File at line 699
setParentID($parentID)

Does not change the filesystem itself, please use {@link write()} for this.

Parameters

$parentID

in File at line 714
string getAbsoluteURL()

Gets the absolute URL accessible through the web.

Return Value

string

in File at line 724
string getURL()

Gets the relative URL accessible through the web.

Return Value

string

in File at line 736
String getFullPath()

Returns an absolute filesystem path to the file.

Use {@link getRelativePath()} to get the same path relative to the webroot.

Return Value

String

at line 1106
String getRelativePath()

Returns path relative to webroot.

Serves as a "fallback" method to create the "Filename" property if it isn't set. If no {@link Folder} is set ("ParentID" property), defaults to a filename relative to the ASSETS_DIR (usually "assets/").

Return Value

String

in File at line 778
getFilename()

in File at line 790
setFilename($val)

Caution: this does not change the location of the file on the filesystem.

Parameters

$val

in File at line 807
String getExtension()

Returns the file extension

Return Value

String

in File at line 825
static string get_file_extension(string $filename)

Gets the extension of a filepath or filename, by stripping away everything before the last "dot".

Caution: Only returns the last extension in "double-barrelled" extensions (e.g. "gz" for "tar.gz").

Examples: - "myfile" returns "" - "myfile.txt" returns "txt" - "myfile.tar.gz" returns "gz"

Parameters

string $filename

Return Value

string

in File at line 835
string getFileType()

Return the type of file for the given extension on the current file name.

Return Value

string

in File at line 868
getSize()

Returns the size of the file type in an appropriate format.

in File at line 879
static string format_size(int $size)

Formats a file size (eg: (int)42 becomes string '42 bytes')

Parameters

int $size

Return Value

string

in File at line 894
static int ini2bytes(string $iniValue)

Convert a php.ini value (eg: 512M) to bytes

Parameters

string $iniValue

Return Value

int

in File at line 916
int getAbsoluteSize()

Return file size in bytes.

Return Value

int

in File at line 1001
static String get_class_for_file_extension(String $ext)

Maps a {@link File} subclass to a specific extension.

By default, files with common image extensions will be created as {@link Image} instead of {@link File} when using {@link Folder::constructChild}, {@link Folder::addUploadToFolder}), and the {@link Upload} class (either directly or through {@link FileField}). For manually instanciated files please use this mapping getter.

Caution: Changes to mapping doesn't apply to existing file records in the database. Also doesn't hook into {@link Object::getCustomClass()}.

Parameters

String $ext File extension, without dot prefix. Use an asterisk ('*') to specify a generic fallback if no mapping is found for an extension.

Return Value

String Classname for a subclass of {@link File}

in File at line 1012
static set_class_for_file_extension(String|array $exts, String $class)

See {@link get_class_for_file_extension()}.

Parameters

String|array $exts
String $class

in File at line 77
File Parent()

Returns parent File

Return Value

File

in File at line 77
Member Owner()

Returns Member object of file owner.

Return Value

Member

in Image at line 84
static flush()

Triggered early in the request when someone requests a flush.

in Image at line 88
static set_backend($backend)

Parameters

$backend

in Image at line 92
static get_backend()

in Image at line 103
static string strip_resampled_prefix(string $path)

Retrieve the original filename from the path of a transformed image.

Any other filenames pass through unchanged.

Parameters

string $path

Return Value

string

in Image at line 145
string getTag()

Return an XHTML img tag for this Image, or NULL if the image file doesn't exist on the filesystem.

Return Value

string

in Image at line 165
string forTemplate()

Return an XHTML img tag for this Image.

Return Value

string

in Image at line 175
loadUploadedImage($tmpFile) deprecated

deprecated 4.0

File names are filtered through {@link FileNameFilter}, see class documentation on how to influence this behaviour.

Parameters

$tmpFile

in Image at line 227
Image|null Fit(integer $width, integer $height)

Scale image proportionally to fit within the specified bounds

Parameters

integer $width The width to size within
integer $height The height to size within

Return Value

Image|null

in Image at line 256
Image_Backend generateFit(Image_Backend $backend, integer $width, integer $height) deprecated

deprecated 4.0 Generate methods are no longer applicable

Scale image proportionally to fit within the specified bounds

Parameters

Image_Backend $backend
integer $width The width to size within
integer $height The height to size within

Return Value

Image_Backend

in Image at line 270
Image FitMax(integer $width, integer $height)

Proportionally scale down this image if it is wider or taller than the specified dimensions.

Similar to Fit but without up-sampling. Use in templates with $FitMax.

Parameters

integer $width The maximum width of the output image
integer $height The maximum height of the output image

Return Value

Image

in Image at line 287
Image|null Fill(integer $width, integer $height)

Resize and crop image to fill specified dimensions.

Use in templates with $Fill

Parameters

integer $width Width to crop to
integer $height Height to crop to

Return Value

Image|null

in Image at line 303
Image_Backend generateFill(Image_Backend $backend, integer $width, integer $height) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize and crop image to fill specified dimensions.

Use in templates with $Fill

Parameters

Image_Backend $backend
integer $width Width to crop to
integer $height Height to crop to

Return Value

Image_Backend

in Image at line 318
Image FillMax(integer $width, integer $height)

Crop this image to the aspect ratio defined by the specified width and height, then scale down the image to those dimensions if it exceeds them.

Similar to Fill but without up-sampling. Use in templates with $FillMax.

Parameters

integer $width The relative (used to determine aspect ratio) and maximum width of the output image
integer $height The relative (used to determine aspect ratio) and maximum height of the output image

Return Value

Image

in Image at line 348
Image|null Pad(integer $width, integer $height, string $backgroundColor = 'FFFFFF', integer $transparencyPercent)

Fit image to specified dimensions and fill leftover space with a solid colour (default white). Use in templates with $Pad.

Parameters

integer $width The width to size to
integer $height The height to size to
string $backgroundColor The background colour to use on padded sides (default white)
integer $transparencyPercent Level of transparency

Return Value

Image|null

in Image at line 365
Image_Backend generatePad(Image_Backend $backend, integer $width, integer $height, string $backgroundColor = 'FFFFFF', integer $transparencyPercent) deprecated

deprecated 4.0 Generate methods are no longer applicable

Fit image to specified dimensions and fill leftover space with a solid colour (default white). Use in templates with $Pad.

Parameters

Image_Backend $backend
integer $width The width to size to
integer $height The height to size to
string $backgroundColor The background colour to use on padded sides (default white)
integer $transparencyPercent Level of transparency

Return Value

Image_Backend

in Image at line 378
Image|null ScaleWidth(integer $width)

Scale image proportionally by width. Use in templates with $ScaleWidth.

Parameters

integer $width The width to set

Return Value

Image|null

in Image at line 392
Image_Backend generateScaleWidth(Image_Backend $backend, int $width) deprecated

deprecated 4.0 Generate methods are no longer applicable

Scale image proportionally by width. Use in templates with $ScaleWidth.

Parameters

Image_Backend $backend
int $width The width to set

Return Value

Image_Backend

in Image at line 405
Image ScaleMaxWidth(integer $width)

Proportionally scale down this image if it is wider than the specified width.

Similar to ScaleWidth but without up-sampling. Use in templates with $ScaleMaxWidth.

Parameters

integer $width The maximum width of the output image

Return Value

Image

in Image at line 420
Image|null ScaleHeight(integer $height)

Scale image proportionally by height. Use in templates with $ScaleHeight.

Parameters

integer $height The height to set

Return Value

Image|null

in Image at line 434
Image_Backend generateScaleHeight(Image_Backend $backend, integer $height) deprecated

deprecated 4.0 Generate methods are no longer applicable

Scale image proportionally by height. Use in templates with $ScaleHeight.

Parameters

Image_Backend $backend
integer $height The height to set

Return Value

Image_Backend

in Image at line 447
Image ScaleMaxHeight(integer $height)

Proportionally scale down this image if it is taller than the specified height.

Similar to ScaleHeight but without up-sampling. Use in templates with $ScaleMaxHeight.

Parameters

integer $height The maximum height of the output image

Return Value

Image

in Image at line 464
Image CropWidth(integer $width)

Crop image on X axis if it exceeds specified width. Retain height.

Use in templates with $CropWidth. Example: $Image.ScaleHeight(100).$CropWidth(100)

Parameters

integer $width The maximum width of the output image

Return Value

Image

in Image at line 481
Image CropHeight(integer $height)

Crop image on Y axis if it exceeds specified height. Retain width.

Use in templates with $CropHeight. Example: $Image.ScaleWidth(100).CropHeight(100)

Parameters

integer $height The maximum height of the output image

Return Value

Image

in Image at line 499
Image SetRatioSize(integer $width, integer $height) deprecated

deprecated 4.0 Use Fit instead

Resize the image by preserving aspect ratio, keeping the image inside the $width and $height

Parameters

integer $width The width to size within
integer $height The height to size within

Return Value

Image

in Image at line 514
Image_Backend generateSetRatioSize(Image_Backend $backend, integer $width, integer $height) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize the image by preserving aspect ratio, keeping the image inside the $width and $height

Parameters

Image_Backend $backend
integer $width The width to size within
integer $height The height to size within

Return Value

Image_Backend

in Image at line 526
Image SetWidth(integer $width) deprecated

deprecated 4.0 Use ScaleWidth instead

Resize this Image by width, keeping aspect ratio. Use in templates with $SetWidth.

Parameters

integer $width The width to set

Return Value

Image

in Image at line 539
Image_Backend generateSetWidth(Image_Backend $backend, int $width) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this Image by width, keeping aspect ratio. Use in templates with $SetWidth.

Parameters

Image_Backend $backend
int $width The width to set

Return Value

Image_Backend

in Image at line 551
Image SetHeight(integer $height) deprecated

deprecated 4.0 Use ScaleHeight instead

Resize this Image by height, keeping aspect ratio. Use in templates with $SetHeight.

Parameters

integer $height The height to set

Return Value

Image

in Image at line 564
Image_Backend generateSetHeight(Image_Backend $backend, integer $height) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this Image by height, keeping aspect ratio. Use in templates with $SetHeight.

Parameters

Image_Backend $backend
integer $height The height to set

Return Value

Image_Backend

in Image at line 578
Image SetSize(integer $width, integer $height) deprecated

deprecated 4.0 Use Pad instead

Resize this Image by both width and height, using padded resize. Use in templates with $SetSize.

Parameters

integer $width The width to size to
integer $height The height to size to

Return Value

Image

See also

Image::PaddedImage()

in Image at line 592
Image_Backend generateSetSize(Image_Backend $backend, integer $width, integer $height) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this Image by both width and height, using padded resize. Use in templates with $SetSize.

Parameters

Image_Backend $backend
integer $width The width to size to
integer $height The height to size to

Return Value

Image_Backend

in Image at line 612
Image_Backend generateCMSThumbnail(Image_Backend $backend) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this image for the CMS. Use in templates with $CMSThumbnail.

Parameters

Image_Backend $backend

Return Value

Image_Backend

in Image at line 623
Image_Backend generateAssetLibraryPreview(Image_Backend $backend) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this image for preview in the Asset section. Use in templates with $AssetLibraryPreview.

Parameters

Image_Backend $backend

Return Value

Image_Backend

in Image at line 634
Image_Backend generateAssetLibraryThumbnail(Image_Backend $backend) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this image for thumbnail in the Asset section. Use in templates with $AssetLibraryThumbnail.

Parameters

Image_Backend $backend

Return Value

Image_Backend

in Image at line 654
Image_Backend generateStripThumbnail(Image_Backend $backend) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this image for use as a thumbnail in a strip. Use in templates with $StripThumbnail.

Parameters

Image_Backend $backend

Return Value

Image_Backend

in Image at line 669
Image PaddedImage($width, $height, $backgroundColor = 'FFFFFF', $transparencyPercent) deprecated

deprecated 4.0 Use Pad instead

Resize this Image by both width and height, using padded resize. Use in templates with $PaddedImage.

Parameters

$width
$height
$backgroundColor
$transparencyPercent

Return Value

Image

See also

Image::SetSize()

in Image at line 684
Image_Backend generatePaddedImage(Image_Backend $backend, $width, $height, $backgroundColor = 'FFFFFF', $transparencyPercent) deprecated

deprecated 4.0 Generate methods are no longer applicable

Resize this Image by both width and height, using padded resize. Use in templates with $PaddedImage.

Parameters

Image_Backend $backend
$width
$height
$backgroundColor
$transparencyPercent

Return Value

Image_Backend

in Image at line 696
boolean isSize(integer $width, integer $height)

Determine if this image is of the specified size

Parameters

integer $width Width to check
integer $height Height to check

Return Value

boolean

in Image at line 706
boolean isWidth(integer $width)

Determine if this image is of the specified width

Parameters

integer $width Width to check

Return Value

boolean

in Image at line 716
boolean isHeight(integer $height)

Determine if this image is of the specified width

Parameters

integer $height Height to check

Return Value

boolean

in Image at line 730
Image_Cached|null getFormattedImage(string $format)

Return an image object representing the image in the given format.

This image will be generated using generateFormattedImage(). The generated image is cached, to flush the cache append ?flush=1 to your URL.

Just pass the correct number of parameters expected by the working function

Parameters

string $format The name of the format.

Return Value

Image_Cached|null

in Image at line 751
string cacheFilename(string $format)

Return the filename for the cached image, given its format name and arguments.

Parameters

string $format The format name.

Return Value

string

Exceptions

InvalidArgumentException

in Image at line 787
generateFormattedImage(string $format)

Generate an image on the specified format. It will save the image at the location specified by cacheFilename(). The image will be generated using the specific 'generate' method for the specified format.

Parameters

string $format Name of the format to generate.

in Image at line 825
Image ResizedImage(integer $width, integer $height)

Generate a resized copy of this image with the given width & height.

This can be used in templates with $ResizedImage but should be avoided, as it's the only image manipulation function which can skew an image.

Parameters

integer $width Width to resize to
integer $height Height to resize to

Return Value

Image

in Image at line 840
Image_Backend|null generateResizedImage(Image_Backend $backend, integer $width, integer $height)

Generate a resized copy of this image with the given width & height.

Use in templates with $ResizedImage.

Parameters

Image_Backend $backend
integer $width Width to resize to
integer $height Height to resize to

Return Value

Image_Backend|null

in Image at line 858
Image CroppedImage(integer $width, integer $height) deprecated

deprecated 4.0 Use Fill instead

Generate a resized copy of this image with the given width & height, cropping to maintain aspect ratio.

Use in templates with $CroppedImage

Parameters

integer $width Width to crop to
integer $height Height to crop to

Return Value

Image

in Image at line 873
Image_Backend generateCroppedImage(Image_Backend $backend, integer $width, integer $height) deprecated

deprecated 4.0 Generate methods are no longer applicable

Generate a resized copy of this image with the given width & height, cropping to maintain aspect ratio.

Use in templates with $CroppedImage

Parameters

Image_Backend $backend
integer $width Width to crop to
integer $height Height to crop to

Return Value

Image_Backend

in Image at line 951
int regenerateFormattedImages()

Regenerate all of the formatted cached images for this image.

Return Value

int The number of formatted images regenerated

in Image at line 981
int deleteFormattedImages()

Remove all of the formatted cached images for this image.

Return Value

int The number of formatted images deleted

in Image at line 1006
string|int|null getDimensions(string $dim = "string")

Get the dimensions of this Image.

Parameters

string $dim If this is equal to "string", return the dimensions in string form, if it is 0 return the height, if it is 1 return the width.

Return Value

string|int|null

in Image at line 1023
int getWidth()

Get the width of this image.

Return Value

int

in Image at line 1031
int getHeight()

Get the height of this image.

Return Value

int

in Image at line 1039
ORIENTATION_SQUARE getOrientation()

Get the orientation of this image.

Return Value

ORIENTATION_SQUARE | ORIENTATION_PORTRAIT | ORIENTATION_LANDSCAPE