mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Added Extension::get_classname_without_arguments()
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@73884 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
23fc9380f2
commit
9eb57d064e
@ -1,7 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* Add extension that can be added to an object with Object::add_extension().
|
||||
* For DataObject extensions, use DataObjectDecorator
|
||||
* Add extension that can be added to an object with {@link Object::add_extension()}.
|
||||
* For {@link DataObject} extensions, use {@link DataObjectDecorator}.
|
||||
* Each extension instance has an "owner" instance, accessible through
|
||||
* {@link getOwner()}.
|
||||
* Every object instance gets its own set of extension instances,
|
||||
* meaning you can set parameters specific to the "owner instance"
|
||||
* in new Extension instances.
|
||||
*
|
||||
* @package sapphire
|
||||
* @subpackage core
|
||||
@ -35,6 +40,19 @@ abstract class Extension extends Object {
|
||||
public function getOwner() {
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper method to strip eval'ed arguments from a string
|
||||
* thats passed to {@link DataObject::$extensions} or
|
||||
* {@link Object::add_extension()}.
|
||||
*
|
||||
* @param string $extensionStr E.g. "Versioned('Stage','Live')"
|
||||
* @return string Extension classname, e.g. "Versioned"
|
||||
*/
|
||||
public static function get_classname_without_arguments($extensionStr) {
|
||||
return (($p = strpos($extensionStr, '(')) !== false) ? substr($extensionStr, 0, $p) : $extensionStr;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
Loading…
Reference in New Issue
Block a user