mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #78 from silverstripe-scienceninjas/release/new-orm-cleanup
Release/new orm cleanup
This commit is contained in:
commit
e592aecdd6
@ -77,5 +77,7 @@ if (!is_dir($aggregatecachedir)) mkdir($aggregatecachedir);
|
||||
SS_Cache::add_backend('aggregatestore', 'File', array('cache_dir' => $aggregatecachedir));
|
||||
SS_Cache::pick_backend('aggregatestore', 'aggregate', 1000);
|
||||
|
||||
Deprecation::notification_version('3.0.0-dev');
|
||||
|
||||
// TODO Remove once new ManifestBuilder with submodule support is in place
|
||||
require_once('admin/_config.php');
|
@ -32,7 +32,7 @@ abstract class CMSBatchAction extends Object {
|
||||
* Helper method for processing batch actions.
|
||||
* Returns a set of status-updating JavaScript to return to the CMS.
|
||||
*
|
||||
* @param $objs The DataObjectSet of objects to perform this batch action
|
||||
* @param $objs The SS_List of objects to perform this batch action
|
||||
* on.
|
||||
* @param $helperMethod The method to call on each of those objects.
|
||||
* @return JSON encoded map in the following format:
|
||||
@ -135,7 +135,7 @@ abstract class CMSBatchAction extends Object {
|
||||
}
|
||||
|
||||
|
||||
// if your batchaction has parameters, return a fieldset here
|
||||
// if your batchaction has parameters, return a FieldList here
|
||||
function getParameterFields() {
|
||||
return false;
|
||||
}
|
||||
|
@ -166,7 +166,7 @@ class CMSBatchActionHandler extends RequestHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a DataObjectSet of ArrayData objects containing the following pieces of info
|
||||
* Return a SS_List of ArrayData objects containing the following pieces of info
|
||||
* about each batch action:
|
||||
* - Link
|
||||
* - Title
|
||||
|
@ -393,7 +393,7 @@ class LeftAndMain extends Controller {
|
||||
* Returns the main menu of the CMS. This is also used by init()
|
||||
* to work out which sections the user has access to.
|
||||
*
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function MainMenu() {
|
||||
// Don't accidentally return a menu if you're not logged in - it's used to determine access.
|
||||
@ -786,7 +786,7 @@ class LeftAndMain extends Controller {
|
||||
$fields = ($fields) ? $fields : $record->getCMSFields();
|
||||
if ($fields == null) {
|
||||
user_error(
|
||||
"getCMSFields() returned null - it should return a FieldSet object.
|
||||
"getCMSFields() returned null - it should return a FieldList object.
|
||||
Perhaps you forgot to put a return statement at the end of your method?",
|
||||
E_USER_ERROR
|
||||
);
|
||||
|
@ -54,7 +54,7 @@ class MemberTableField extends ComplexTableField {
|
||||
* @param Controller $controller Controller class which created this field
|
||||
* @param string $name Name of the field (e.g. "Members")
|
||||
* @param mixed $group Can be the ID of a Group instance, or a Group instance itself
|
||||
* @param DataObjectSet $members Optional set of Members to set as the source items for this field
|
||||
* @param SS_List $members Optional set of Members to set as the source items for this field
|
||||
* @param boolean $hidePassword Hide the password field or not in the summary?
|
||||
*/
|
||||
function __construct($controller, $name, $group = null, $members = null, $hidePassword = true) {
|
||||
|
@ -244,7 +244,7 @@ abstract class ModelAdmin extends LeftAndMain {
|
||||
* Returns managed models' create, search, and import forms
|
||||
* @uses SearchContext
|
||||
* @uses SearchFilter
|
||||
* @return DataObjectSet of forms
|
||||
* @return SS_List of forms
|
||||
*/
|
||||
protected function getModelForms() {
|
||||
$models = $this->getManagedModels();
|
||||
|
@ -100,7 +100,7 @@ class SecurityAdmin extends LeftAndMain implements PermissionProvider {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
function RootForm() {
|
||||
$memberList = new MemberTableField(
|
||||
|
@ -116,9 +116,9 @@ class JSONDataFormatter extends DataFormatter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a JSON representation of the given {@link DataObjectSet}.
|
||||
* Generate a JSON representation of the given {@link SS_List}.
|
||||
*
|
||||
* @param DataObjectSet $set
|
||||
* @param SS_List $set
|
||||
* @return String XML
|
||||
*/
|
||||
public function convertDataObjectSet(SS_List $set, $fields = null) {
|
||||
|
@ -20,7 +20,7 @@ class RSSFeed extends ViewableData {
|
||||
/**
|
||||
* Holds the feed entries
|
||||
*
|
||||
* @var DataObjectSet
|
||||
* @var SS_List
|
||||
*/
|
||||
protected $entries;
|
||||
|
||||
@ -83,7 +83,7 @@ class RSSFeed extends ViewableData {
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DataObjectSet $entries RSS feed entries
|
||||
* @param SS_List $entries RSS feed entries
|
||||
* @param string $link Link to the feed
|
||||
* @param string $title Title of the feed
|
||||
* @param string $description Description of the field
|
||||
@ -134,7 +134,7 @@ class RSSFeed extends ViewableData {
|
||||
/**
|
||||
* Get the RSS feed entries
|
||||
*
|
||||
* @return DataObjectSet Returns the {@link RSSFeed_Entry} objects.
|
||||
* @return SS_List Returns the {@link RSSFeed_Entry} objects.
|
||||
*/
|
||||
function Entries() {
|
||||
$output = new ArrayList();
|
||||
|
@ -217,7 +217,7 @@ class RestfulServer extends Controller {
|
||||
$responseFormatter = $this->getResponseDataFormatter();
|
||||
if(!$responseFormatter) return $this->unsupportedMediaType();
|
||||
|
||||
// $obj can be either a DataObject or a DataObjectSet,
|
||||
// $obj can be either a DataObject or a SS_List,
|
||||
// depending on the request
|
||||
if($id) {
|
||||
// Format: /api/v1/<MyClass>/<ID>
|
||||
@ -262,7 +262,7 @@ class RestfulServer extends Controller {
|
||||
*
|
||||
* @param string $className
|
||||
* @param array $params
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
protected function getSearchQuery($className, $params = null, $sort = null, $limit = null, $existingQuery = null) {
|
||||
if(singleton($className)->hasMethod('getRestfulSearchContext')) {
|
||||
@ -592,7 +592,7 @@ class RestfulServer extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* Restful server handler for a DataObjectSet
|
||||
* Restful server handler for a SS_List
|
||||
*
|
||||
* @package sapphire
|
||||
* @subpackage api
|
||||
@ -630,7 +630,7 @@ class RestfulServer_Item {
|
||||
$funcName = $request('Relation');
|
||||
$relation = $this->item->$funcName();
|
||||
|
||||
if($relation instanceof DataObjectSet) return new RestfulServer_List($relation);
|
||||
if($relation instanceof SS_List) return new RestfulServer_List($relation);
|
||||
else return new RestfulServer_Item($relation);
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class SapphireSoapServer extends Controller {
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataObjectSet Collection of ArrayData elements describing
|
||||
* @return SS_List Collection of ArrayData elements describing
|
||||
* the method (keys: 'Name', 'Arguments', 'ReturnType')
|
||||
*/
|
||||
function Methods() {
|
||||
|
@ -127,9 +127,9 @@ class XMLDataFormatter extends DataFormatter {
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate an XML representation of the given {@link DataObjectSet}.
|
||||
* Generate an XML representation of the given {@link SS_List}.
|
||||
*
|
||||
* @param DataObjectSet $set
|
||||
* @param SS_List $set
|
||||
* @return String XML
|
||||
*/
|
||||
public function convertDataObjectSet(SS_List $set, $fields = null) {
|
||||
|
@ -162,7 +162,7 @@ class PaginatedList extends SS_ListDecorator {
|
||||
* around the current page.
|
||||
*
|
||||
* @param int $max
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function Pages($max = null) {
|
||||
$result = new ArrayList();
|
||||
@ -229,7 +229,7 @@ class PaginatedList extends SS_ListDecorator {
|
||||
* @param int $context The number of pages to display around the current
|
||||
* page. The number should be event, as half the number of each pages
|
||||
* are displayed on either side of the current one.
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function PaginationSummary($context = 4) {
|
||||
$result = new ArrayList();
|
||||
|
@ -182,7 +182,7 @@ abstract class BulkLoader extends ViewableData {
|
||||
abstract protected function processRecord($record, $columnMap, &$result, $preview = false);
|
||||
|
||||
/**
|
||||
* Return a FieldSet containing all the options for this form; this
|
||||
* Return a FieldList containing all the options for this form; this
|
||||
* doesn't include the actual upload field itself
|
||||
*/
|
||||
public function getOptionFields() {}
|
||||
@ -326,24 +326,24 @@ class BulkLoader_Result extends Object {
|
||||
* Returns all created objects. Each object might
|
||||
* contain specific importer feedback in the "_BulkLoaderMessage" property.
|
||||
*
|
||||
* @return DataObjectSet
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function Created() {
|
||||
return $this->mapToDataObjectSet($this->created);
|
||||
return $this->mapToArrayList($this->created);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataObjectSet
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function Updated() {
|
||||
return $this->mapToDataObjectSet($this->updated);
|
||||
return $this->mapToArrayList($this->updated);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataObjectSet
|
||||
* @return ArrayList
|
||||
*/
|
||||
public function Deleted() {
|
||||
return $this->mapToDataObjectSet($this->deleted);
|
||||
return $this->mapToArrayList($this->deleted);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -396,9 +396,9 @@ class BulkLoader_Result extends Object {
|
||||
|
||||
/**
|
||||
* @param $arr Array containing ID and ClassName maps
|
||||
* @return DataObjectSet
|
||||
* @return ArrayList
|
||||
*/
|
||||
protected function mapToDataObjectSet($arr) {
|
||||
protected function mapToArrayList($arr) {
|
||||
$set = new ArrayList();
|
||||
foreach($arr as $arrItem) {
|
||||
$obj = DataObject::get_by_id($arrItem['ClassName'], $arrItem['ID']);
|
||||
|
161
dev/Deprecation.php
Normal file
161
dev/Deprecation.php
Normal file
@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Handles raising an notice when accessing a deprecated method
|
||||
*
|
||||
* A pattern used in SilverStripe when deprecating a method is to add something like
|
||||
* user_error('This method is deprecated', E_USER_NOTICE);
|
||||
* to the method
|
||||
*
|
||||
* However sometimes we want to mark that a method will be deprecated in some future version and shouldn't be used in
|
||||
* new code, but not forbid in the current version - for instance when that method is still heavily used in framework
|
||||
* or cms.
|
||||
*
|
||||
* This class abstracts the above pattern and adds a way to do that.
|
||||
*
|
||||
* Each call to notice passes a version that the notice will be valid from. Additionally this class has a notion of the
|
||||
* version it should use when deciding whether to raise the notice. If that version is equal to or greater than the
|
||||
* notices version (and SilverStripe is in dev mode) a deprecation message will be raised.
|
||||
*
|
||||
* Normally the checking version will be the release version of SilverStripe, but a developer can choose to set it to a
|
||||
* future version, to see how their code will behave in future versions.
|
||||
*
|
||||
* Modules can also set the version for calls they make - either setting it to a future version in order to ensure
|
||||
* forwards compatibility or setting it backwards if a module has not yet removed references to deprecated methods.
|
||||
*
|
||||
* When set per-module, only direct calls to deprecated methods from those modules are considered - if the module
|
||||
* calls a non-module method which then calls a deprecated method, that call will use the global check version, not
|
||||
* the module specific check version.
|
||||
*/
|
||||
class Deprecation {
|
||||
|
||||
protected static $version;
|
||||
|
||||
protected static $module_version_overrides = array();
|
||||
|
||||
/**
|
||||
* @var int - the notice level to raise on a deprecation notice. Defaults to E_USER_DEPRECATED if that exists,
|
||||
* E_USER_NOTICE if not
|
||||
*/
|
||||
public static $notice_level = null;
|
||||
|
||||
/**
|
||||
* Set the version that is used to check against the version passed to notice. If the ::notice version is
|
||||
* greater than or equal to this version, a message will be raised
|
||||
*
|
||||
* @static
|
||||
* @param $ver string -
|
||||
* A php standard version string, see http://php.net/manual/en/function.version-compare.php for details.
|
||||
* @param null $forModule string -
|
||||
* The name of a module. The passed version will be used as the check value for
|
||||
* calls directly from this module rather than the global value
|
||||
* @return void
|
||||
*/
|
||||
public static function notification_version($ver, $forModule = null) {
|
||||
if ($forModule) {
|
||||
self::$module_version_overrides[$forModule] = $ver;
|
||||
}
|
||||
else {
|
||||
self::$version = $ver;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a backtrace, get the module name from the caller two removed (the caller of the method that called #notice)
|
||||
*
|
||||
* @static
|
||||
* @param $backtrace array - a backtrace as returned from debug_backtrace
|
||||
* @return string - the name of the module the call came from, or null if we can't determine
|
||||
*/
|
||||
protected static function get_calling_module_from_trace($backtrace) {
|
||||
if (!isset($backtrace[1]['file'])) return;
|
||||
|
||||
$callingfile = $backtrace[1]['file'];
|
||||
|
||||
global $manifest;
|
||||
foreach ($manifest->getModules() as $name => $path) {
|
||||
if (strpos($callingfile, $path) === 0) {
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a backtrace, get the method name from the immediate parent caller (the caller of #notice)
|
||||
*
|
||||
* @static
|
||||
* @param $backtrace array - a backtrace as returned from debug_backtrace
|
||||
* @return string - the name of the method
|
||||
*/
|
||||
protected static function get_called_method_from_trace($backtrace) {
|
||||
$called = $backtrace[1];
|
||||
|
||||
if (isset($called['class'])) {
|
||||
return $called['class'] . $called['type'] . $called['function'];
|
||||
}
|
||||
else {
|
||||
return $called['function'];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Raise a notice indicating the method is deprecated if the version passed as the second argument is greater
|
||||
* than or equal to the check version set via ::notification_version
|
||||
*
|
||||
* @static
|
||||
* @param $string - The notice to raise
|
||||
* @param $atVersion - The version at which this notice should start being raised
|
||||
* @return void
|
||||
*/
|
||||
public static function notice($atVersion, $string = '') {
|
||||
if(!Director::isDev()) return;
|
||||
|
||||
$checkVersion = self::$version;
|
||||
// Getting a backtrace is slow, so we only do it if we need it
|
||||
$backtrace = null;
|
||||
|
||||
if(self::$module_version_overrides) {
|
||||
$module = self::get_calling_module_from_trace($backtrace = debug_backtrace(0));
|
||||
if(isset(self::$module_version_overrides[$module])) $checkVersion = self::$module_version_overrides[$module];
|
||||
}
|
||||
|
||||
// Check the version against the notice version
|
||||
if ($checkVersion && version_compare($checkVersion, $atVersion, '>=')) {
|
||||
// Get the calling method
|
||||
if (!$backtrace) $backtrace = debug_backtrace(0);
|
||||
$caller = self::get_called_method_from_trace($backtrace);
|
||||
|
||||
// Get the level to raise the notice as
|
||||
$level = self::$notice_level;
|
||||
if (!$level) $level = defined(E_USER_DEPRECATED) ? E_USER_DEPRECATED : E_USER_NOTICE;
|
||||
|
||||
// Then raise the notice
|
||||
user_error($caller.' is deprecated.'.($string ? ' '.$string : ''), $level);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for when testing. Dump all the current version settings to a variable for later passing to restore
|
||||
* @return array - opaque array that should only be used to pass to ::restore_version_settings
|
||||
*/
|
||||
public static function dump_settings() {
|
||||
return array(
|
||||
'level' => self::$notice_level,
|
||||
'version' => self::$version,
|
||||
'moduleVersions' => self::$module_version_overrides
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method for when testing. Restore all the current version settings from a variable
|
||||
* @static
|
||||
* @param $settings array - An array as returned by ::dump_version_settings
|
||||
* @return void
|
||||
*/
|
||||
public static function restore_settings($settings) {
|
||||
self::$notice_level = $settings['level'];
|
||||
self::$version = $settings['version'];
|
||||
self::$module_version_overrides = $settings['moduleVersions'];
|
||||
}
|
||||
|
||||
}
|
@ -513,12 +513,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
|
||||
/**
|
||||
* Assert that the given {@link DataObjectSet} includes DataObjects matching the given key-value
|
||||
* Assert that the given {@link SS_List} includes DataObjects matching the given key-value
|
||||
* pairs. Each match must correspond to 1 distinct record.
|
||||
*
|
||||
* @param $matches The patterns to match. Each pattern is a map of key-value pairs. You can
|
||||
* either pass a single pattern or an array of patterns.
|
||||
* @param $dataObjectSet The {@link DataObjectSet} to test.
|
||||
* @param $dataObjectSet The {@link SS_List} to test.
|
||||
*
|
||||
* Examples
|
||||
* --------
|
||||
@ -550,8 +550,8 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
// We couldn't find a match - assertion failed
|
||||
if(!$matched) {
|
||||
throw new PHPUnit_Framework_AssertionFailedError(
|
||||
"Failed asserting that the DataObjectSet contains an item matching "
|
||||
. var_export($match, true) . "\n\nIn the following DataObjectSet:\n"
|
||||
"Failed asserting that the SS_List contains an item matching "
|
||||
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
||||
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
||||
);
|
||||
}
|
||||
@ -560,12 +560,12 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the given {@link DataObjectSet} includes only DataObjects matching the given
|
||||
* Assert that the given {@link SS_List} includes only DataObjects matching the given
|
||||
* key-value pairs. Each match must correspond to 1 distinct record.
|
||||
*
|
||||
* @param $matches The patterns to match. Each pattern is a map of key-value pairs. You can
|
||||
* either pass a single pattern or an array of patterns.
|
||||
* @param $dataObjectSet The {@link DataObjectSet} to test.
|
||||
* @param $dataObjectSet The {@link SS_List} to test.
|
||||
*
|
||||
* Example
|
||||
* --------
|
||||
@ -596,8 +596,8 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
// We couldn't find a match - assertion failed
|
||||
if(!$matched) {
|
||||
throw new PHPUnit_Framework_AssertionFailedError(
|
||||
"Failed asserting that the DataObjectSet contains an item matching "
|
||||
. var_export($match, true) . "\n\nIn the following DataObjectSet:\n"
|
||||
"Failed asserting that the SS_List contains an item matching "
|
||||
. var_export($match, true) . "\n\nIn the following SS_List:\n"
|
||||
. $this->DOSSummaryForMatch($dataObjectSet, $match)
|
||||
);
|
||||
}
|
||||
@ -607,18 +607,18 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
||||
if($extracted) {
|
||||
// If we didn't break by this point then we couldn't find a match
|
||||
throw new PHPUnit_Framework_AssertionFailedError(
|
||||
"Failed asserting that the DataObjectSet contained only the given items, the "
|
||||
"Failed asserting that the SS_List contained only the given items, the "
|
||||
. "following items were left over:\n" . var_export($extracted, true)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Assert that the every record in the given {@link DataObjectSet} matches the given key-value
|
||||
* Assert that the every record in the given {@link SS_List} matches the given key-value
|
||||
* pairs.
|
||||
*
|
||||
* @param $match The pattern to match. The pattern is a map of key-value pairs.
|
||||
* @param $dataObjectSet The {@link DataObjectSet} to test.
|
||||
* @param $dataObjectSet The {@link SS_List} to test.
|
||||
*
|
||||
* Example
|
||||
* --------
|
||||
|
@ -78,10 +78,10 @@ You can have more customized logic and interface feedback through a custom contr
|
||||
$form = new Form(
|
||||
$this,
|
||||
'Form',
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new FileField('CsvFile', false)
|
||||
),
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new FormAction('doUpload', 'Upload')
|
||||
),
|
||||
new RequiredFields()
|
||||
|
@ -43,7 +43,7 @@ You can override this behaviour in various ways:
|
||||
'MyName',
|
||||
'Product',
|
||||
array('Price','Code'),
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new TextField('Price')
|
||||
)
|
||||
)
|
||||
@ -75,11 +75,11 @@ popup as there is more real-estate for you to play with.
|
||||
|
||||
`[api:ComplexTableField]` gives you several options to do this. You can either
|
||||
|
||||
* Pass a FieldSet in the constructor.
|
||||
* Pass a FieldList in the constructor.
|
||||
* Pass a String in the constructor.
|
||||
|
||||
The first will simply add the fieldset to the form, and populate it with the source class.
|
||||
The second will call the String as a method on the source class (Which should return a FieldSet) of fields for the
|
||||
The first will simply add the fieldlist to the form, and populate it with the source class.
|
||||
The second will call the String as a method on the source class (Which should return a FieldList) of fields for the
|
||||
Popup.
|
||||
|
||||
You can also customise Javascript which is loaded for the Lightbox. As Requirements::clear() is called when the popup is
|
||||
@ -108,7 +108,7 @@ You'll have to do something like this in your form:
|
||||
|
||||
$tableField->setParentClass(false);
|
||||
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new HiddenField('ID', ''),
|
||||
$tableField
|
||||
);
|
||||
|
@ -88,7 +88,7 @@ extension:
|
||||
The $fields parameter is passed by reference, as it is an object.
|
||||
|
||||
:::php
|
||||
public function updateCMSFields(FieldSet $fields) {
|
||||
public function updateCMSFields(FieldList $fields) {
|
||||
$fields->push(new TextField('Position', 'Position Title'));
|
||||
$fields->push(new ImageField('Image', 'Profile Image'));
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ A single database record & abstract class for the data-access-model.
|
||||
## Basics
|
||||
|
||||
The call to `DataObject->getCMSFields()` is the centerpiece of every data administration interface in SilverStripe,
|
||||
which returns a `[api:FieldSet]`''.
|
||||
which returns a `[api:FieldList]`''.
|
||||
|
||||
:::php
|
||||
class MyPage extends Page {
|
||||
@ -27,7 +27,7 @@ which returns a `[api:FieldSet]`''.
|
||||
|
||||
## Scaffolding Formfields
|
||||
|
||||
These calls retrieve a `[api:FieldSet]` for the area where you intend to work with the scaffolded form.
|
||||
These calls retrieve a `[api:FieldList]` for the area where you intend to work with the scaffolded form.
|
||||
|
||||
### For the CMS
|
||||
|
||||
|
@ -30,7 +30,7 @@ given set of fields in a given set of tables
|
||||
* `[CompositeField](api:CompositeField)`: Base class for all fields that contain other fields. Uses `<div>` in template, but
|
||||
doesn't necessarily have any visible styling.
|
||||
* `[FieldGroup](api:FieldGroup)`: Same as CompositeField, but has default styling (indentation) attached in CMS-context.
|
||||
* `[api:FieldSet]`: Basic container for sequential fields, or nested fields through CompositeField. Does NOT render a
|
||||
* `[api:FieldList]`: Basic container for sequential fields, or nested fields through CompositeField. Does NOT render a
|
||||
`<fieldgroup>`.
|
||||
* `[TabSet](api:TabSet)`
|
||||
* `[Tab](api:Tab)`
|
||||
|
@ -51,10 +51,10 @@ The PHP file defining your new subclass is the first step in the process. This
|
||||
*/
|
||||
public function getEditForm($id = null) {
|
||||
return new Form($this, "EditForm",
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new ReadonlyField('id #',$id)
|
||||
),
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new FormAction('go')
|
||||
)
|
||||
);
|
||||
|
@ -64,8 +64,8 @@ Note that if you want to look this class-name up, you can call Object::getCustom
|
||||
## Overloading getCMSFields()
|
||||
|
||||
If you overload the built-in function getCMSFields(), then you can change the form that is used to view & edit member
|
||||
details in the newsletter system. This function returns a `[api:FieldSet]` object. You should generally start by calling
|
||||
parent::getCMSFields() and manipulate the `[api:FieldSet]` from there.
|
||||
details in the newsletter system. This function returns a `[api:FieldList]` object. You should generally start by calling
|
||||
parent::getCMSFields() and manipulate the `[api:FieldList]` from there.
|
||||
|
||||
:::php
|
||||
function getCMSFields() {
|
||||
@ -106,10 +106,10 @@ things, you should add appropriate `[api:Permission::checkMember()]` calls to th
|
||||
|
||||
* Modify the field set to be displayed in the CMS detail pop-up
|
||||
*/
|
||||
function updateCMSFields(FieldSet $currentFields) {
|
||||
function updateCMSFields(FieldList $currentFields) {
|
||||
// Only show the additional fields on an appropriate kind of use
|
||||
if(Permission::checkMember($this->owner->ID, "VIEW_FORUM")) {
|
||||
// Edit the fieldset passed, adding or removing fields as necessary
|
||||
// Edit the FieldList passed, adding or removing fields as necessary
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,7 @@ it just receives a set of search parameters and an object class it acts on.
|
||||
The default output of a `[api:SearchContext]` is either a `[api:SQLQuery]` object for further refinement, or a
|
||||
`[api:DataObject]` instance.
|
||||
|
||||
In case you need multiple contexts, consider namespacing your request parameters by using `FieldSet->namespace()` on
|
||||
In case you need multiple contexts, consider namespacing your request parameters by using `FieldList->namespace()` on
|
||||
the $fields constructor parameter.
|
||||
|
||||
`[api:SearchContext]` is mainly used by `[api:ModelAdmin]`, our generic data administration interface. Another
|
||||
@ -71,7 +71,7 @@ method, we're building our own `getCustomSearchContext()` variant.
|
||||
$fields = $context->getSearchFields();
|
||||
$form = new Form($this, "SearchForm",
|
||||
$fields,
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new FormAction('doSearch')
|
||||
)
|
||||
);
|
||||
|
@ -47,7 +47,7 @@ Create a mysite/code/CustomSiteConfig.php file.
|
||||
);
|
||||
}
|
||||
|
||||
public function updateCMSFields(FieldSet $fields) {
|
||||
public function updateCMSFields(FieldList $fields) {
|
||||
$fields->addFieldToTab("Root.Main", new HTMLEditorField("FooterContent", "Footer Content"));
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ class.
|
||||
:::php
|
||||
function Form() {
|
||||
$form = new Form($this, 'Form',
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new TextField('MyRequiredField'),
|
||||
new TextField('MyOptionalField')
|
||||
),
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new FormAction('submit', 'Submit')
|
||||
),
|
||||
new RequiredFields(array('MyRequiredField'))
|
||||
|
@ -14,19 +14,19 @@ constructor takes the following arguments:
|
||||
* `$name`: This must be the name of the method on that controller that is called to return the form. The first two
|
||||
fields allow the form object to be re-created after submission. **It's vital that they are properly set - if you ever
|
||||
have problems with form action handler not working, check that these values are correct.**
|
||||
* `$fields`: A `[api:FieldSet]` containing `[api:FormField]` instances make up fields in the form.
|
||||
* `$actions`: A `[api:FieldSet]` containing the `[api:FormAction]` objects - the buttons at the bottom.
|
||||
* `$fields`: A `[api:FieldList]` containing `[api:FormField]` instances make up fields in the form.
|
||||
* `$actions`: A `[api:FieldList]` containing the `[api:FormAction]` objects - the buttons at the bottom.
|
||||
* `$validator`: An optional `[api:Validator]` for more information.
|
||||
|
||||
Example:
|
||||
|
||||
:::php
|
||||
function MyCustomForm() {
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new EmailField("Email"),
|
||||
new EncryptField("Password")
|
||||
);
|
||||
$actions = new FieldSet(new FormAction("login", "Log in"));
|
||||
$actions = new FieldList(new FormAction("login", "Log in"));
|
||||
return new Form($this, "MyCustomForm", $fields, $actions);
|
||||
}
|
||||
|
||||
@ -44,11 +44,11 @@ $name must be passed - their values depend on where the form is instantiated.
|
||||
:::php
|
||||
class MyForm extends Form {
|
||||
function __construct($controller, $name) {
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new EmailField("Email"),
|
||||
new EncryptedField("Password")
|
||||
);
|
||||
$actions = new FieldSet(new FormAction("login", "Log in"));
|
||||
$actions = new FieldList(new FormAction("login", "Log in"));
|
||||
|
||||
parent::__construct($controller, $name, $fields, $actions);
|
||||
}
|
||||
@ -77,13 +77,13 @@ Full overview at [form-field-types](/reference/form-field-types)
|
||||
### Using Form Fields
|
||||
|
||||
To get these fields automatically rendered into a form element, all you need to do is create a new instance of the
|
||||
class, and add it to the fieldset of the form.
|
||||
class, and add it to the fieldlist of the form.
|
||||
|
||||
:::php
|
||||
$form = new Form(
|
||||
$controller = $this,
|
||||
$name = "SignupForm",
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new TextField(
|
||||
$name = "FirstName",
|
||||
$title = "First name"
|
||||
@ -91,7 +91,7 @@ class, and add it to the fieldset of the form.
|
||||
new TextField("Surname"),
|
||||
new EmailField("Email", "Email address"),
|
||||
),
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldList(
|
||||
// List the action buttons here
|
||||
new FormAction("signup", "Sign up")
|
||||
),
|
||||
@ -109,7 +109,7 @@ Implementing the more complex fields requires extra arguments.
|
||||
$form = new Form(
|
||||
$controller = $this,
|
||||
$name = "SignupForm",
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
// List the your fields here
|
||||
new TextField(
|
||||
$name = "FirstName",
|
||||
@ -123,7 +123,7 @@ Implementing the more complex fields requires extra arguments.
|
||||
$source = Geoip::getCountryDropDown(),
|
||||
$value = Geoip::visitor_country()
|
||||
)
|
||||
), new FieldSet(
|
||||
), new FieldList(
|
||||
// List the action buttons here
|
||||
new FormAction("signup", "Sign up")
|
||||
|
||||
@ -141,7 +141,7 @@ Readonly on a Form
|
||||
$myForm->makeReadonly();
|
||||
|
||||
|
||||
Readonly on a FieldSet
|
||||
Readonly on a FieldList
|
||||
|
||||
:::php
|
||||
$myFieldSet->makeReadonly();
|
||||
@ -170,12 +170,12 @@ First of all, you need to create your form on it's own class, that way you can d
|
||||
class MyForm extends Form {
|
||||
|
||||
function __construct($controller, $name) {
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new TextField('FirstName', 'First name'),
|
||||
new EmailField('Email', 'Email address')
|
||||
);
|
||||
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldList(
|
||||
new FormAction('submit', 'Submit')
|
||||
);
|
||||
|
||||
@ -280,5 +280,5 @@ Adds a new text field called FavouriteColour next to the Content field in the CM
|
||||
|
||||
* `[api:Form]`
|
||||
* `[api:FormField]`
|
||||
* `[api:FieldSet]`
|
||||
* `[api:FieldList]`
|
||||
* `[api:FormAction]`
|
@ -78,7 +78,7 @@ See [form](/topics/forms) and [tutorial:2-extending-a-basic-site](/tutorials/2-e
|
||||
|
||||
### removeFieldFromTab()
|
||||
|
||||
Overloading `getCMSFields()` you can call `removeFieldFromTab()` on a `[api:FieldSet]` object. For example, if you don't
|
||||
Overloading `getCMSFields()` you can call `removeFieldFromTab()` on a `[api:FieldList]` object. For example, if you don't
|
||||
want the MenuTitle field to show on your page, which is inherited from `[api:SiteTree]`.
|
||||
|
||||
:::php
|
||||
@ -105,7 +105,7 @@ required on a certain page-type.
|
||||
class MyForm extends Form {
|
||||
|
||||
function __construct($controller, $name) {
|
||||
// add a default FieldSet of form fields
|
||||
// add a default FieldList of form fields
|
||||
$member = singleton('Member');
|
||||
|
||||
$fields = $member->formFields();
|
||||
@ -113,7 +113,7 @@ required on a certain page-type.
|
||||
// We don't want the Country field from our default set of fields, so we remove it.
|
||||
$fields->removeByName('Country');
|
||||
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldList(
|
||||
new FormAction('submit', 'Submit')
|
||||
);
|
||||
|
||||
|
@ -85,7 +85,7 @@ Photos), and $description, a short description that will appear in the cms edito
|
||||
Flickr). The class may also specify functions to be used in the template like a page type can.
|
||||
|
||||
If a Widget has configurable options, then it can specify a number of database fields to store these options in via the
|
||||
static $db array, and also specify a getCMSFields function that returns a !FieldSet, much the same way as a page type
|
||||
static $db array, and also specify a getCMSFields function that returns a !FieldList, much the same way as a page type
|
||||
does.
|
||||
|
||||
An example widget is below:
|
||||
@ -139,7 +139,7 @@ An example widget is below:
|
||||
}
|
||||
|
||||
function getCMSFields() {
|
||||
return new FieldSet(
|
||||
return new FieldList(
|
||||
new TextField("User", "User"),
|
||||
new TextField("PhotoSet", "Photo Set"),
|
||||
new TextField("Tags", "Tags"),
|
||||
@ -246,10 +246,10 @@ sure that your controller follows the usual naming conventions, and it will be a
|
||||
return new Form(
|
||||
$this,
|
||||
'MyFormName',
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new TextField('TestValue')
|
||||
),
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new FormAction('doAction')
|
||||
)
|
||||
);
|
||||
|
@ -192,7 +192,7 @@ Let's walk through this method.
|
||||
|
||||
|
||||
Firstly, we get the fields from the parent class; we want to add fields, not replace them. The *$fields* variable
|
||||
returned is a `[api:FieldSet]` object.
|
||||
returned is a `[api:FieldList]` object.
|
||||
|
||||
:::php
|
||||
$fields->addFieldToTab('Root.Content', new DateField('Date'), 'Content');
|
||||
|
@ -33,7 +33,7 @@ the form in a method on *HomePage_Controller*.
|
||||
|
||||
function BrowserPollForm() {
|
||||
// Create fields
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new TextField('Name'),
|
||||
new OptionsetField('Browser', 'Your Favourite Browser', array(
|
||||
'Firefox' => 'Firefox',
|
||||
@ -46,7 +46,7 @@ the form in a method on *HomePage_Controller*.
|
||||
);
|
||||
|
||||
// Create actions
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldList(
|
||||
new FormAction('doBrowserPoll', 'Submit')
|
||||
);
|
||||
|
||||
@ -63,7 +63,7 @@ Let's step through this code.
|
||||
|
||||
:::php
|
||||
// Create fields
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new TextField('Name'),
|
||||
new OptionsetField('Browser', 'Your Favourite Browser', array(
|
||||
'Firefox' => 'Firefox',
|
||||
@ -78,7 +78,7 @@ Let's step through this code.
|
||||
|
||||
First we create our form fields.
|
||||
|
||||
We do this by creating a `[api:FieldSet]` and passing our fields as arguments. The first field is a new
|
||||
We do this by creating a `[api:FieldList]` and passing our fields as arguments. The first field is a new
|
||||
`[api:TextField]` with the name 'Name'.
|
||||
|
||||
There is a second argument when creating a field which specifies the text on the label of the field. If no second
|
||||
@ -88,7 +88,7 @@ The second field we create is an `[api:OptionsetField]`. This is a dropdown, and
|
||||
array mapping the values to the options listed in the dropdown.
|
||||
|
||||
:::php
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldList(
|
||||
new FormAction('doBrowserPoll', 'Submit');
|
||||
);
|
||||
|
||||
@ -100,7 +100,7 @@ button.
|
||||
|
||||
Here we create a 'Submit' button which calls the 'doBrowserPoll' method, which we will create later.
|
||||
|
||||
All the form actions (in this case only one) are collected into a `[api:FieldSet]` object the same way we did with
|
||||
All the form actions (in this case only one) are collected into a `[api:FieldList]` object the same way we did with
|
||||
the fields.
|
||||
|
||||
:::php
|
||||
@ -111,7 +111,7 @@ Finally we create the `[api:Form]` object and return it.
|
||||
|
||||
The first argument is the controller that contains the form, in most cases '$this'. The second is the name of the method
|
||||
that returns the form, which is 'BrowserPollForm' in our case. The third and fourth arguments are the
|
||||
FieldSets containing the fields and form actions respectively.
|
||||
FieldLists containing the fields and form actions respectively.
|
||||
|
||||
After creating the form function, we need to add the form to our home page template.
|
||||
|
||||
@ -139,7 +139,7 @@ Add the following code to the form style sheet:
|
||||
margin: 20px 10px 0 0;
|
||||
width: 20%;
|
||||
}
|
||||
form fieldset {
|
||||
form FieldList {
|
||||
border:0;
|
||||
}
|
||||
#BrowserPoll .message {
|
||||
|
@ -54,11 +54,11 @@ search on your site is to create a form for the user to type their query. Create
|
||||
function SearchForm() {
|
||||
$searchText = isset($this->Query) ? $this->Query : 'Search';
|
||||
|
||||
$fields = new FieldSet(
|
||||
$fields = new FieldList(
|
||||
new TextField("Search", "", $searchText)
|
||||
);
|
||||
|
||||
$actions = new FieldSet(
|
||||
$actions = new FieldList(
|
||||
new FormAction('results', 'Go')
|
||||
);
|
||||
|
||||
|
@ -83,7 +83,7 @@ The first step is to create the student and project objects.
|
||||
);
|
||||
|
||||
function getCMSFields_forPopup() {
|
||||
$fields = new FieldSet();
|
||||
$fields = new FieldList();
|
||||
|
||||
$fields->push( new TextField( 'FirstName', 'First Name' ) );
|
||||
$fields->push( new TextField( 'Lastname' ) );
|
||||
@ -153,7 +153,7 @@ Let’s walk through the parameters of the *HasOneComplexTableField* constructor
|
||||
You can also directly replace the last parameter by this code :
|
||||
|
||||
:::php
|
||||
new FieldSet(
|
||||
new FieldList(
|
||||
new TextField( 'FirstName', 'First Name' ),
|
||||
new TextField( 'Lastname' ),
|
||||
new TextField( 'Nationality' )
|
||||
@ -381,7 +381,7 @@ The first step is to create the module object and set the relation with the *Pro
|
||||
);
|
||||
|
||||
function getCMSFields_forPopup() {
|
||||
$fields = new FieldSet();
|
||||
$fields = new FieldList();
|
||||
$fields->push( new TextField( 'Name' ) );
|
||||
return $fields;
|
||||
}
|
||||
|
@ -775,7 +775,7 @@ class File extends DataObject {
|
||||
*
|
||||
* Needs to be enabled through {@link AssetAdmin::$metadata_upload_enabled}
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
function uploadMetadataFields() {
|
||||
$fields = new FieldList();
|
||||
|
@ -379,8 +379,8 @@ class Folder extends File {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the FieldSet used to edit this folder in the CMS.
|
||||
* You can modify this fieldset by subclassing folder, or by creating a {@link DataExtension}
|
||||
* Return the FieldList used to edit this folder 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.
|
||||
*/
|
||||
function getCMSFields() {
|
||||
|
@ -25,7 +25,7 @@
|
||||
* * If the field name matches a database field, a comma-separated list of values will be saved to that field. The keys can be text or numbers.
|
||||
*
|
||||
* @todo Document the different source data that can be used
|
||||
* with this form field - e.g ComponentSet, DataObjectSet,
|
||||
* with this form field - e.g ComponentSet, ArrayList,
|
||||
* array. Is it also appropriate to accept so many different
|
||||
* types of data when just using an array would be appropriate?
|
||||
*
|
||||
@ -46,7 +46,7 @@ class CheckboxSetField extends OptionsetField {
|
||||
|
||||
/**
|
||||
* @todo Explain different source data that can be used with this field,
|
||||
* e.g. SQLMap, DataObjectSet or an array.
|
||||
* e.g. SQLMap, ArrayList or an array.
|
||||
*
|
||||
* @todo Should use CheckboxField FieldHolder rather than constructing own markup.
|
||||
*/
|
||||
@ -76,7 +76,7 @@ class CheckboxSetField extends OptionsetField {
|
||||
$items = $values;
|
||||
} else {
|
||||
// Source and values are DataObject sets.
|
||||
if($values && is_a($values, 'DataObjectSet')) {
|
||||
if($values && is_a($values, 'SS_List')) {
|
||||
foreach($values as $object) {
|
||||
if(is_a($object, 'DataObject')) {
|
||||
$items[] = $object->ID;
|
||||
@ -88,8 +88,8 @@ class CheckboxSetField extends OptionsetField {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Sometimes we pass a singluar default value thats ! an array && !DataObjectSet
|
||||
if(is_a($values, 'DataObjectSet') || is_array($values)) {
|
||||
// Sometimes we pass a singluar default value thats ! an array && !SS_List
|
||||
if(is_a($values, 'SS_List') || is_array($values)) {
|
||||
$items = $values;
|
||||
} else {
|
||||
$items = explode(',', $values);
|
||||
@ -247,7 +247,7 @@ class CheckboxSetField extends OptionsetField {
|
||||
|
||||
if($items) {
|
||||
// Items is a DO Set
|
||||
if(is_a($items, 'DataObjectSet')) {
|
||||
if(is_a($items, 'SS_List')) {
|
||||
foreach($items as $item) {
|
||||
$data[] = $item->Title;
|
||||
}
|
||||
@ -264,7 +264,7 @@ class CheckboxSetField extends OptionsetField {
|
||||
$data[] = $item['Title'];
|
||||
} elseif(is_array($this->source) && !empty($this->source[$item])) {
|
||||
$data[] = $this->source[$item];
|
||||
} elseif(is_a($this->source, 'DataObjectSet')) {
|
||||
} elseif(is_a($this->source, 'SS_List')) {
|
||||
$data[] = $sourceTitles[$item];
|
||||
} else {
|
||||
$data[] = $item;
|
||||
|
@ -32,7 +32,7 @@ class ComplexTableField extends TableListField {
|
||||
|
||||
/**
|
||||
* Determines the fields of the detail pop-up form. It can take many forms:
|
||||
* - A FieldSet object: Use that field set directly.
|
||||
* - A FieldList object: Use that field set directly.
|
||||
* - A method name, eg, 'getCMSFields': Call that method on the child object to get the fields.
|
||||
*/
|
||||
protected $addTitle;
|
||||
@ -245,7 +245,7 @@ JS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
function Items() {
|
||||
$sourceItems = $this->sourceItems();
|
||||
@ -330,7 +330,7 @@ JS;
|
||||
/**
|
||||
* @return FieldList
|
||||
*/
|
||||
function createFieldSet() {
|
||||
function createFieldList() {
|
||||
$fieldset = new FieldList();
|
||||
foreach($this->fieldTypes as $key => $fieldType){
|
||||
$fieldset->push(new $fieldType($key));
|
||||
@ -352,7 +352,7 @@ JS;
|
||||
* Return the object-specific fields for the given record, to be shown in the detail pop-up
|
||||
*
|
||||
* This won't include all the CTF-specific 'plumbing; this method is called by self::getFieldsFor()
|
||||
* and the result is then processed further to get the actual FieldSet for the form.
|
||||
* and the result is then processed further to get the actual FieldList for the form.
|
||||
*
|
||||
* The default implementation of this processes the value of $this->detailFormFields; consequently, if you want to
|
||||
* set the value of the fields to something that $this->detailFormFields doesn't allow, you can do so by overloading
|
||||
@ -709,7 +709,7 @@ class ComplexTableField_ItemRequest extends TableListField_ItemRequest {
|
||||
/**
|
||||
* Method handles pagination in asset popup.
|
||||
*
|
||||
* @return Object DataObjectSet
|
||||
* @return Object SS_List
|
||||
*/
|
||||
|
||||
function Pagination() {
|
||||
|
@ -52,7 +52,7 @@ class FieldGroup extends CompositeField {
|
||||
if(is_array($arg1) || is_a($arg1, 'FieldSet')) {
|
||||
$fields = $arg1;
|
||||
|
||||
} else if(is_array($arg2) || is_a($arg2, 'FieldSet')) {
|
||||
} else if(is_array($arg2) || is_a($arg2, 'FieldList')) {
|
||||
$this->title = $arg1;
|
||||
$fields = $arg2;
|
||||
|
||||
|
40
forms/FieldList.php
Executable file → Normal file
40
forms/FieldList.php
Executable file → Normal file
@ -80,7 +80,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an extra field to a tab within this fieldset.
|
||||
* Add an extra field to a tab within this FieldList.
|
||||
* This is most commonly used when overloading getCMSFields()
|
||||
*
|
||||
* @param string $tabName The name of the tab or tabset. Subtabs can be referred to as TabSet.Tab or TabSet.Tab.Subtab.
|
||||
@ -101,7 +101,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a number of extra fields to a tab within this fieldset.
|
||||
* Add a number of extra fields to a tab within this FieldList.
|
||||
* This is most commonly used when overloading getCMSFields()
|
||||
*
|
||||
* @param string $tabName The name of the tab or tabset. Subtabs can be referred to as TabSet.Tab or TabSet.Tab.Subtab.
|
||||
@ -143,7 +143,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a number of fields from a Tab/TabSet within this FieldSet.
|
||||
* Removes a number of fields from a Tab/TabSet within this FieldList.
|
||||
*
|
||||
* @param string $tabName The name of the Tab or TabSet field
|
||||
* @param array $fields A list of fields, e.g. array('Name', 'Email')
|
||||
@ -159,7 +159,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a field from this FieldSet by Name.
|
||||
* Remove a field from this FieldList by Name.
|
||||
* The field could also be inside a CompositeField.
|
||||
*
|
||||
* @param string $fieldName The name of the field or tab
|
||||
@ -169,7 +169,7 @@ class FieldList extends ArrayList {
|
||||
*/
|
||||
public function removeByName($fieldName, $dataFieldOnly = false) {
|
||||
if(!$fieldName) {
|
||||
user_error('FieldSet::removeByName() was called with a blank field name.', E_USER_WARNING);
|
||||
user_error('FieldList::removeByName() was called with a blank field name.', E_USER_WARNING);
|
||||
}
|
||||
$this->flushFieldsCache();
|
||||
|
||||
@ -257,7 +257,7 @@ class FieldList extends ArrayList {
|
||||
public function findOrMakeTab($tabName, $title = null) {
|
||||
$parts = explode('.',$tabName);
|
||||
|
||||
// We could have made this recursive, but I've chosen to keep all the logic code within FieldSet rather than add it to TabSet and Tab too.
|
||||
// We could have made this recursive, but I've chosen to keep all the logic code within FieldList rather than add it to TabSet and Tab too.
|
||||
$currentPointer = $this;
|
||||
foreach($parts as $k => $part) {
|
||||
$parentPointer = $currentPointer;
|
||||
@ -274,7 +274,7 @@ class FieldList extends ArrayList {
|
||||
$parentPointer->push($currentPointer);
|
||||
} else {
|
||||
$withName = ($parentPointer->hasMethod('Name')) ? " named '{$parentPointer->Name()}'" : null;
|
||||
user_error("FieldSet::addFieldToTab() Tried to add a tab to object '{$parentPointer->class}'{$withName} - '$part' didn't exist.", E_USER_ERROR);
|
||||
user_error("FieldList::addFieldToTab() Tried to add a tab to object '{$parentPointer->class}'{$withName} - '$part' didn't exist.", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -324,7 +324,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a field before a particular field in a FieldSet.
|
||||
* Inserts a field before a particular field in a FieldList.
|
||||
*
|
||||
* @param FormField $item The form field to insert
|
||||
* @param string $name Name of the field to insert before
|
||||
@ -349,7 +349,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a field after a particular field in a FieldSet.
|
||||
* Inserts a field after a particular field in a FieldList.
|
||||
*
|
||||
* @param FormField $item The form field to insert
|
||||
* @param string $name Name of the field to insert after
|
||||
@ -374,7 +374,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a single field into this FieldSet instance.
|
||||
* Push a single field into this FieldList instance.
|
||||
*
|
||||
* @param FormField $item The FormField to add
|
||||
* @param string $key An option array key (field name)
|
||||
@ -386,7 +386,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handler method called before the FieldSet is going to be manipulated.
|
||||
* Handler method called before the FieldList is going to be manipulated.
|
||||
*/
|
||||
protected function onBeforeInsert($item) {
|
||||
$this->flushFieldsCache();
|
||||
@ -395,9 +395,9 @@ class FieldList extends ArrayList {
|
||||
|
||||
|
||||
/**
|
||||
* Set the Form instance for this FieldSet.
|
||||
* Set the Form instance for this FieldList.
|
||||
*
|
||||
* @param Form $form The form to set this FieldSet to
|
||||
* @param Form $form The form to set this FieldList to
|
||||
*/
|
||||
public function setForm($form) {
|
||||
foreach($this as $field) $field->setForm($form);
|
||||
@ -406,7 +406,7 @@ class FieldList extends ArrayList {
|
||||
/**
|
||||
* Load the given data into this form.
|
||||
*
|
||||
* @param data An map of data to load into the FieldSet
|
||||
* @param data An map of data to load into the FieldList
|
||||
*/
|
||||
public function setValues($data) {
|
||||
foreach($this->dataFields() as $field) {
|
||||
@ -420,7 +420,7 @@ class FieldList extends ArrayList {
|
||||
* in a form - including fields nested in {@link CompositeFields}.
|
||||
* Useful when doing custom field layouts.
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
function HiddenFields() {
|
||||
$hiddenFields = new HiddenFieldSet();
|
||||
@ -434,10 +434,10 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Transform this FieldSet with a given tranform method,
|
||||
* Transform this FieldList with a given tranform method,
|
||||
* e.g. $this->transform(new ReadonlyTransformation())
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
function transform($trans) {
|
||||
$this->flushFieldsCache();
|
||||
@ -461,9 +461,9 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Transforms this FieldSet instance to readonly.
|
||||
* Transforms this FieldList instance to readonly.
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
function makeReadonly() {
|
||||
return $this->transform(new ReadonlyTransformation());
|
||||
@ -481,7 +481,7 @@ class FieldList extends ArrayList {
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the order of fields in this FieldSet by specifying an ordered list of field names.
|
||||
* Change the order of fields in this FieldList by specifying an ordered list of field names.
|
||||
* This works well in conjunction with SilverStripe's scaffolding functions: take the scaffold, and
|
||||
* shuffle the fields around to the order that you want.
|
||||
*
|
||||
|
@ -7,11 +7,11 @@
|
||||
*/
|
||||
class FieldSet extends FieldList {
|
||||
|
||||
/**
|
||||
* @deprecated 3.0.0 Use FieldList instead
|
||||
*/
|
||||
public function __construct($items = array()) {
|
||||
// user_error(
|
||||
// 'FieldSet is deprecated, please use FieldList instead.', E_USER_NOTICE
|
||||
// );
|
||||
|
||||
Deprecation::notice('3.0.0', 'Use FieldList instead');
|
||||
parent::__construct(!is_array($items) || func_num_args() > 1 ? func_get_args(): $items);
|
||||
}
|
||||
}
|
||||
|
@ -142,8 +142,8 @@ class Form extends RequestHandler {
|
||||
*
|
||||
* @param Controller $controller The parent controller, necessary to create the appropriate form action tag.
|
||||
* @param String $name The method on the controller that will return this form object.
|
||||
* @param FieldList $fields All of the fields in the form - a {@link FieldSet} of {@link FormField} objects.
|
||||
* @param FieldList $actions All of the action buttons in the form - a {@link FieldSet} of {@link FormAction} objects
|
||||
* @param FieldList $fields All of the fields in the form - a {@link FieldList} of {@link FormField} objects.
|
||||
* @param FieldList $actions All of the action buttons in the form - a {@link FieldLis} of {@link FormAction} objects
|
||||
* @param Validator $validator Override the default validator instance (Default: {@link RequiredFields})
|
||||
*/
|
||||
function __construct($controller, $name, FieldList $fields, FieldList $actions, $validator = null) {
|
||||
@ -338,7 +338,7 @@ class Form extends RequestHandler {
|
||||
/**
|
||||
* Handle a field request.
|
||||
* Uses {@link Form->dataFieldByName()} to find a matching field,
|
||||
* and falls back to {@link FieldSet->fieldByName()} to look
|
||||
* and falls back to {@link FieldList->fieldByName()} to look
|
||||
* for tabs instead. This means that if you have a tab and a
|
||||
* formfield with the same name, this method gives priority
|
||||
* to the formfield.
|
||||
@ -460,7 +460,7 @@ class Form extends RequestHandler {
|
||||
/**
|
||||
* Generate extra special fields - namely the security token field (if required).
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
public function getExtraFields() {
|
||||
$extraFields = new FieldList();
|
||||
@ -483,7 +483,7 @@ class Form extends RequestHandler {
|
||||
/**
|
||||
* Return the form's fields - used by the templates
|
||||
*
|
||||
* @return FieldSet The form fields
|
||||
* @return FieldList The form fields
|
||||
*/
|
||||
function Fields() {
|
||||
foreach($this->getExtraFields() as $field) {
|
||||
@ -498,7 +498,7 @@ class Form extends RequestHandler {
|
||||
* in a form - including fields nested in {@link CompositeFields}.
|
||||
* Useful when doing custom field layouts.
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
function HiddenFields() {
|
||||
return $this->fields->HiddenFields();
|
||||
@ -531,7 +531,7 @@ class Form extends RequestHandler {
|
||||
/**
|
||||
* Return the form's action buttons - used by the templates
|
||||
*
|
||||
* @return FieldSet The action list
|
||||
* @return FieldList The action list
|
||||
*/
|
||||
function Actions() {
|
||||
return $this->actions;
|
||||
@ -916,7 +916,7 @@ class Form extends RequestHandler {
|
||||
* It will call $object->MyField to get the value of MyField.
|
||||
* If you passed an array, it will call $object[MyField].
|
||||
* Doesn't save into dataless FormFields ({@link DatalessField}),
|
||||
* as determined by {@link FieldSet->dataFields()}.
|
||||
* as determined by {@link FieldList->dataFields()}.
|
||||
*
|
||||
* By default, if a field isn't set (as determined by isset()),
|
||||
* its value will not be saved to the field, retaining
|
||||
@ -925,7 +925,7 @@ class Form extends RequestHandler {
|
||||
* Passed data should not be escaped, and is saved to the FormField instances unescaped.
|
||||
* Escaping happens automatically on saving the data through {@link saveInto()}.
|
||||
*
|
||||
* @uses FieldSet->dataFields()
|
||||
* @uses FieldList->dataFields()
|
||||
* @uses FormField->setValue()
|
||||
*
|
||||
* @param array|DataObject $data
|
||||
@ -1022,7 +1022,7 @@ class Form extends RequestHandler {
|
||||
|
||||
/**
|
||||
* Get the submitted data from this form through
|
||||
* {@link FieldSet->dataFields()}, which filters out
|
||||
* {@link FieldList->dataFields()}, which filters out
|
||||
* any form-specific data like form-actions.
|
||||
* Calls {@link FormField->dataValue()} on each field,
|
||||
* which returns a value suitable for insertion into a DataObject
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Represents a field in a form.
|
||||
*
|
||||
* A FieldSet contains a number of FormField objects which make up the whole of a form.
|
||||
* A FieldList contains a number of FormField objects which make up the whole of a form.
|
||||
* In addition to single fields, FormField objects can be "composite", for example, the {@link TabSet}
|
||||
* field. Composite fields let us define complex forms without having to resort to custom HTML.
|
||||
*
|
||||
@ -53,8 +53,8 @@ class FormField extends RequestHandler {
|
||||
protected $tabIndex;
|
||||
|
||||
/**
|
||||
* Stores a reference to the FieldSet that contains this object.
|
||||
* @var FieldSet
|
||||
* Stores a reference to the FieldList that contains this object.
|
||||
* @var FieldList
|
||||
*/
|
||||
protected $containerFieldSet;
|
||||
|
||||
@ -480,7 +480,7 @@ HTML;
|
||||
* make sense for data-focused methods to look at them. By overloading hasData() to return false,
|
||||
* you can prevent any data-focused methods from looking at it.
|
||||
*
|
||||
* @see FieldSet::collateDataFields()
|
||||
* @see FieldList::collateDataFields()
|
||||
*/
|
||||
function hasData() { return true; }
|
||||
|
||||
@ -654,7 +654,7 @@ HTML;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the fieldset that contains this field.
|
||||
* Set the FieldList that contains this field.
|
||||
*
|
||||
* @param FieldList $containerFieldSet
|
||||
*/
|
||||
|
@ -62,7 +62,7 @@ class FormScaffolder extends Object {
|
||||
* Depending on those parameters, the fields can be used in ajax-context,
|
||||
* contain {@link TabSet}s etc.
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
public function getFieldSet() {
|
||||
$fields = new FieldList();
|
||||
|
@ -34,7 +34,7 @@
|
||||
* $map = $myDoSet->toDropDownMap();
|
||||
*
|
||||
* // Instantiate the OptionsetField
|
||||
* $fieldset = new FieldList(
|
||||
* $FieldList = new FieldList(
|
||||
* new OptionsetField(
|
||||
* $name = "Foobar",
|
||||
* $title = "FooBar's optionset",
|
||||
|
@ -133,7 +133,7 @@ class TabSet extends CompositeField {
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts a field before a particular field in a FieldSet.
|
||||
* Inserts a field before a particular field in a FieldList.
|
||||
*
|
||||
* @param FormField $item The form field to insert
|
||||
* @param string $name Name of the field to insert before
|
||||
|
@ -20,7 +20,7 @@
|
||||
* @param $sourceSort string
|
||||
* @param $sourceJoin string
|
||||
*
|
||||
* @todo We should refactor this to support a single FieldSet instead of evaluated Strings for building FormFields
|
||||
* @todo We should refactor this to support a single FieldList instead of evaluated Strings for building FormFields
|
||||
*
|
||||
* @package forms
|
||||
* @subpackage fields-relational
|
||||
@ -43,7 +43,7 @@ class TableField extends TableListField {
|
||||
protected $filterValue = null;
|
||||
|
||||
/**
|
||||
* @var $fieldTypes FieldSet
|
||||
* @var $fieldTypes FieldList
|
||||
* Caution: Use {@setExtraData()} instead of manually adding HiddenFields if you want to
|
||||
* preset relations or other default data.
|
||||
*/
|
||||
@ -116,7 +116,7 @@ class TableField extends TableListField {
|
||||
/**
|
||||
* Displays the headings on the template
|
||||
*
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
function Headings() {
|
||||
$i=0;
|
||||
@ -147,7 +147,7 @@ class TableField extends TableListField {
|
||||
* it generates the rows from array data instead.
|
||||
* Used in the formfield template to iterate over each row.
|
||||
*
|
||||
* @return DataObjectSet Collection of {@link TableField_Item}
|
||||
* @return SS_List Collection of {@link TableField_Item}
|
||||
*/
|
||||
function Items() {
|
||||
// holds TableField_Item instances
|
||||
@ -206,7 +206,7 @@ class TableField extends TableListField {
|
||||
|
||||
/**
|
||||
* Generates a new {@link TableField} instance
|
||||
* by loading a fieldset for this row into a temporary form.
|
||||
* by loading a FieldList for this row into a temporary form.
|
||||
*
|
||||
* @param DataObject $dataObj
|
||||
* @return TableField_Item
|
||||
@ -341,7 +341,7 @@ class TableField extends TableListField {
|
||||
* Called on save, it creates the appropriate objects and writes them
|
||||
* to the database.
|
||||
*
|
||||
* @param DataObjectSet $dataObjects
|
||||
* @param SS_List $dataObjects
|
||||
* @param boolean $existingValues If set to TRUE, it tries to find existing objects
|
||||
* based on the database IDs passed as array keys in $dataObjects parameter.
|
||||
* If set to FALSE, it will always create new object (default: TRUE)
|
||||
|
@ -266,7 +266,7 @@ class TableListField extends FormField {
|
||||
function sourceClass() {
|
||||
$list = $this->getDataList();
|
||||
if(method_exists($list, 'dataClass')) return $list->dataClass();
|
||||
// Failover for DataObjectSet
|
||||
// Failover for SS_List
|
||||
else return get_class($list->First());
|
||||
}
|
||||
|
||||
@ -364,7 +364,7 @@ JS
|
||||
* Dummy function to get number of actions originally generated in
|
||||
* TableListField_Item.
|
||||
*
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
function Actions() {
|
||||
$allowedActions = new ArrayList();
|
||||
@ -396,10 +396,10 @@ JS
|
||||
user_error('TableList::setCustomSourceItems() deprecated, just pass the items into the constructor', E_USER_WARNING);
|
||||
|
||||
// The type-hinting above doesn't seem to work consistently
|
||||
if($items instanceof DataObjectSet) {
|
||||
if($items instanceof SS_List) {
|
||||
$this->dataList = $items;
|
||||
} else {
|
||||
user_error('TableList::setCustomSourceItems() should be passed a DataObjectSet', E_USER_WARNING);
|
||||
user_error('TableList::setCustomSourceItems() should be passed a SS_List', E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
@ -407,10 +407,10 @@ JS
|
||||
* Get items, with sort & limit applied
|
||||
*/
|
||||
function sourceItems() {
|
||||
// get items (this may actually be a DataObjectSet)
|
||||
// get items (this may actually be a SS_List)
|
||||
$items = clone $this->getDataList();
|
||||
|
||||
// TODO: Sorting could be implemented on regular DataObjectSets.
|
||||
// TODO: Sorting could be implemented on regular SS_Lists.
|
||||
if(method_exists($items,'canSortBy') && isset($_REQUEST['ctf'][$this->Name()]['sort'])) {
|
||||
$sort = $_REQUEST['ctf'][$this->Name()]['sort'];
|
||||
// TODO: sort direction
|
||||
@ -434,7 +434,7 @@ JS
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a DataObjectSet of TableListField_Item objects, suitable for display in the template.
|
||||
* Return a SS_List of TableListField_Item objects, suitable for display in the template.
|
||||
*/
|
||||
function Items() {
|
||||
$fieldItems = new ArrayList();
|
||||
@ -586,7 +586,7 @@ JS
|
||||
}
|
||||
|
||||
/**
|
||||
* @param DataObjectSet $items Only used to pass grouped sourceItems for creating
|
||||
* @param SS_List $items Only used to pass grouped sourceItems for creating
|
||||
* partial summaries.
|
||||
*/
|
||||
function SummaryFields($items = null) {
|
||||
@ -1275,7 +1275,7 @@ JS
|
||||
* Requires {@link Markable()} to return TRUE.
|
||||
* This is only functional with JavaScript enabled.
|
||||
*
|
||||
* @return DataObjectSet of ArrayData objects
|
||||
* @return SS_List of ArrayData objects
|
||||
*/
|
||||
function SelectOptions(){
|
||||
if(!$this->selectOptions) return;
|
||||
@ -1427,7 +1427,7 @@ class TableListField_Item extends ViewableData {
|
||||
* See TableListField->Action for a similiar dummy-function to work
|
||||
* around template-inheritance issues.
|
||||
*
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
function Actions() {
|
||||
$allowedActions = new ArrayList();
|
||||
|
@ -131,7 +131,7 @@ class DataDifferencer extends ViewableData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a DataObjectSet of the changed fields.
|
||||
* Get a SS_List of the changed fields.
|
||||
* Each element is an array data containing
|
||||
* - Name: The field name
|
||||
* - Title: The human-readable field title
|
||||
|
@ -172,7 +172,7 @@ abstract class DataExtension extends Extension {
|
||||
*
|
||||
* Caution: Use {@link FieldList->addFieldToTab()} to add fields.
|
||||
*
|
||||
* @param FieldList $fields FieldSet with a contained TabSet
|
||||
* @param FieldList $fields FieldList with a contained TabSet
|
||||
*/
|
||||
function updateCMSFields(FieldList $fields) {
|
||||
}
|
||||
@ -181,9 +181,9 @@ abstract class DataExtension extends Extension {
|
||||
* This function is used to provide modifications to the form used
|
||||
* for front end forms. {@link DataObject->getFrontEndFields()}
|
||||
*
|
||||
* Caution: Use {@link FieldSet->push()} to add fields.
|
||||
* Caution: Use {@link FieldList->push()} to add fields.
|
||||
*
|
||||
* @param FieldList $fields FieldSet without TabSet nesting
|
||||
* @param FieldList $fields FieldList without TabSet nesting
|
||||
*/
|
||||
function updateFrontEndFields(FieldList $fields) {
|
||||
}
|
||||
@ -192,7 +192,7 @@ abstract class DataExtension extends Extension {
|
||||
* This is used to provide modifications to the form actions
|
||||
* used in the CMS. {@link DataObject->getCMSActions()}.
|
||||
*
|
||||
* @param FieldList $actions FieldSet
|
||||
* @param FieldList $actions FieldList
|
||||
*/
|
||||
function updateCMSActions(FieldList $actions) {
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class DataList extends ViewableData implements SS_List {
|
||||
protected $dataClass;
|
||||
|
||||
/**
|
||||
* The {@link DataQuery} object responsible for getting this DataObjectSet's records
|
||||
* The {@link DataQuery} object responsible for getting this DataList's records
|
||||
*/
|
||||
protected $dataQuery;
|
||||
|
||||
@ -178,9 +178,9 @@ class DataList extends ViewableData implements SS_List {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an Iterator for this DataObjectSet.
|
||||
* This function allows you to use DataObjectSets in foreach loops
|
||||
* @return DataObjectSet_Iterator
|
||||
* Returns an Iterator for this DataList.
|
||||
* This function allows you to use DataLists in foreach loops
|
||||
* @return ArrayIterator
|
||||
*/
|
||||
public function getIterator() {
|
||||
return new ArrayIterator($this->toArray());
|
||||
|
@ -1764,7 +1764,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @param array $_params
|
||||
* 'fieldClasses': Associative array of field names as keys and FormField classes as values
|
||||
* 'restrictFields': Numeric array of a field name whitelist
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
public function scaffoldSearchFields($_params = null) {
|
||||
$params = array_merge(
|
||||
@ -1821,7 +1821,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @uses FormScaffolder
|
||||
*
|
||||
* @param array $_params Associative array passing through properties to {@link FormScaffolder}.
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
public function scaffoldFormFields($_params = null) {
|
||||
$params = array_merge(
|
||||
@ -1867,7 +1867,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @see Good example of complex FormField building: SiteTree::getCMSFields()
|
||||
*
|
||||
* @param array $params See {@link scaffoldFormFields()}
|
||||
* @return FieldSet Returns a TabSet for usage within the CMS - don't use for frontend forms.
|
||||
* @return FieldList Returns a TabSet for usage within the CMS - don't use for frontend forms.
|
||||
*/
|
||||
public function getCMSFields($params = null) {
|
||||
$tabbedFields = $this->scaffoldFormFields(array_merge(
|
||||
@ -1888,7 +1888,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* 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 an Empty FieldSet(); need to be overload by solid subclass
|
||||
* @return an Empty FieldList(); need to be overload by solid subclass
|
||||
*/
|
||||
public function getCMSActions() {
|
||||
$actions = new FieldList();
|
||||
@ -1906,7 +1906,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @todo Decide on naming for "website|frontend|site|page" and stick with it in the API
|
||||
*
|
||||
* @param array $params See {@link scaffoldFormFields()}
|
||||
* @return FieldSet Always returns a simple field collection without TabSet.
|
||||
* @return FieldList Always returns a simple field collection without TabSet.
|
||||
*/
|
||||
public function getFrontEndFields($params = null) {
|
||||
$untabbedFields = $this->scaffoldFormFields($params);
|
||||
@ -2457,10 +2457,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.5 Use DataObject::get() instead, with the new data mapper there's no reason not to.
|
||||
* @deprecated 3.0.0 Use DataObject::get and DataList to do your querying
|
||||
*/
|
||||
public function buildSQL($filter = "", $sort = "", $limit = "", $join = "", $restrictClasses = true, $having = "") {
|
||||
user_error("DataObject::buildSQL() deprecated; just use DataObject::get() with the new data mapper", E_USER_NOTICE);
|
||||
Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying');
|
||||
return $this->extendedSQL($filter, $sort, $limit, $join, $having);
|
||||
|
||||
}
|
||||
@ -2471,7 +2471,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
private static $cache_buildSQL_query;
|
||||
|
||||
/**
|
||||
* @deprecated 2.5 Use DataObject::get() instead, with the new data mapper there's no reason not to.
|
||||
* @deprecated 3.0.0 Use DataObject::get and DataList to do your querying
|
||||
*/
|
||||
public function extendedSQL($filter = "", $sort = "", $limit = "", $join = ""){
|
||||
$dataList = DataObject::get($this->class, $filter, $sort, $join, $limit);
|
||||
@ -2492,7 +2492,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return mixed The objects matching the filter, in the class specified by $containerClass
|
||||
*/
|
||||
public static function get($callerClass, $filter = "", $sort = "", $join = "", $limit = "", $containerClass = "DataList") {
|
||||
// Deprecated 2.5?
|
||||
// Todo: Determine if we can deprecate for 3.0.0 and use DI or something instead
|
||||
// Todo: Make the $containerClass method redundant
|
||||
if($containerClass != "DataList") user_error("The DataObject::get() \$containerClass argument has been deprecated", E_USER_NOTICE);
|
||||
$result = DataList::create($callerClass)->where($filter)->sort($sort)->join($join)->limit($limit);
|
||||
@ -2501,9 +2501,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated 3.0.0 Use DataObject::get and DataList to do your querying
|
||||
*/
|
||||
public function Aggregate($class = null) {
|
||||
Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying');
|
||||
|
||||
if($class) {
|
||||
$list = new DataList($class);
|
||||
$list->setModel(DataModel::inst());
|
||||
@ -2516,9 +2518,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @deprecated 3.0.0 Use DataObject::get and DataList to do your querying
|
||||
*/
|
||||
public function RelationshipAggregate($relationship) {
|
||||
Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying');
|
||||
|
||||
return $this->$relationship();
|
||||
}
|
||||
|
||||
@ -2526,7 +2530,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* The internal function that actually performs the querying for get().
|
||||
* DataObject::get("Table","filter") is the same as singleton("Table")->instance_get("filter")
|
||||
*
|
||||
* @deprecated 2.5 Use DataObject::get()
|
||||
* @deprecated 3.0.0 Use DataObject::get and DataList to do your querying
|
||||
*
|
||||
* @param string $filter A filter to be inserted into the WHERE clause.
|
||||
* @param string $sort A sort expression to be inserted into the ORDER BY clause. If omitted, self::$default_sort will be used.
|
||||
@ -2537,15 +2541,14 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return mixed The objects matching the filter, in the class specified by $containerClass
|
||||
*/
|
||||
public function instance_get($filter = "", $sort = "", $join = "", $limit="", $containerClass = "DataObjectSet") {
|
||||
user_error("instance_get deprecated", E_USER_NOTICE);
|
||||
Deprecation::notice('3.0.0', 'Use DataObject::get and DataList to do your querying');
|
||||
return self::get($this->class, $filter, $sort, $join, $limit, $containerClass);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Take a database {@link SS_Query} and instanciate an object for each record.
|
||||
*
|
||||
* @deprecated 2.5 Use DataObject::get(), you don't need to side-step it any more
|
||||
* @deprecated 3.0.0 Replaced by DataList
|
||||
*
|
||||
* @param SS_Query|array $records The database records, a {@link SS_Query} object or an array of maps.
|
||||
* @param string $containerClass The class to place all of the objects into.
|
||||
@ -2553,8 +2556,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return mixed The new objects in an object of type $containerClass
|
||||
*/
|
||||
function buildDataObjectSet($records, $containerClass = "DataObjectSet", $query = null, $baseClass = null) {
|
||||
user_error('buildDataObjectSet is deprecated; use DataList to do your querying', E_USER_NOTICE);
|
||||
|
||||
Deprecation::notice('3.0.0', 'Replaced by DataList');
|
||||
|
||||
foreach($records as $record) {
|
||||
if(empty($record['RecordClassName'])) {
|
||||
$record['RecordClassName'] = $record['ClassName'];
|
||||
@ -2670,7 +2673,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
/**
|
||||
* Does the hard work for get_one()
|
||||
*
|
||||
* @deprecated 2.5 Use DataObject::get_one() instead
|
||||
* @deprecated 3.0.0 Use DataObject::get_one() instead
|
||||
*
|
||||
* @uses DataExtension->augmentSQL()
|
||||
*
|
||||
@ -2679,7 +2682,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* @return DataObject The first item matching the query
|
||||
*/
|
||||
public function instance_get_one($filter, $orderby = null) {
|
||||
user_error("DataObjct::instance_get_one is deprecated", E_USER_NOTICE);
|
||||
Deprecation::notice('3.0.0', 'Use DataObject::get_one() instead');
|
||||
return DataObject::get_one($this->class, $filter, true, $orderby);
|
||||
}
|
||||
|
||||
@ -2822,22 +2825,20 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.5 use self::database_fields()
|
||||
* @deprecated 3.0.0 Use DataObject::database_fields() instead
|
||||
* @see DataObject::database_fields()
|
||||
*/
|
||||
public function databaseFields() {
|
||||
user_error("databaseFields() is deprecated; use self::database_fields() "
|
||||
. "instead", E_USER_NOTICE);
|
||||
Deprecation::notice('3.0.0', 'Use DataObject::database_fields() instead');
|
||||
return self::database_fields($this->class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated 2.5 use self::custom_database_fields()
|
||||
* @deprecated 3.0.0 Use DataObject::custom_database_fields() instead
|
||||
* @see DataObject::custom_database_fields()
|
||||
*/
|
||||
public function customDatabaseFields() {
|
||||
user_error("customDatabaseFields() is deprecated; use self::custom_database_fields() "
|
||||
. "instead", E_USER_NOTICE);
|
||||
Deprecation::notice('3.0.0', 'Use DataObject::custom_database_fields() instead');
|
||||
return self::custom_database_fields($this->class);
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,11 @@
|
||||
*/
|
||||
class DataObjectSet extends ArrayList {
|
||||
|
||||
/**
|
||||
* @deprecated 3.0.0
|
||||
*/
|
||||
public function __construct($items = array()) {
|
||||
// user_error(
|
||||
// 'DataObjectSet is deprecated, please use DataList or ArrayList instead.',
|
||||
// E_USER_NOTICE
|
||||
// );
|
||||
Deprecation::notice('3.0.0', 'Use DataList or ArrayList instead');
|
||||
|
||||
if ($items) {
|
||||
if (!is_array($items) || func_num_args() > 1) {
|
||||
|
@ -394,7 +394,7 @@ class Hierarchy extends DataExtension {
|
||||
|
||||
/**
|
||||
* Get the children for this DataObject.
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function Children() {
|
||||
if(!(isset($this->_cache_children) && $this->_cache_children)) {
|
||||
@ -413,7 +413,7 @@ class Hierarchy extends DataExtension {
|
||||
|
||||
/**
|
||||
* Return all children, including those 'not in menus'.
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function AllChildren() {
|
||||
return $this->owner->stageChildren(true);
|
||||
@ -425,7 +425,7 @@ class Hierarchy extends DataExtension {
|
||||
* Added children will be marked as "AddedToStage"
|
||||
* Modified children will be marked as "ModifiedOnStage"
|
||||
* Everything else has "SameOnStage" set, as an indicator that this information has been looked up.
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function AllChildrenIncludingDeleted($context = null) {
|
||||
return $this->doAllChildrenIncludingDeleted($context);
|
||||
@ -435,7 +435,7 @@ class Hierarchy extends DataExtension {
|
||||
* @see AllChildrenIncludingDeleted
|
||||
*
|
||||
* @param unknown_type $context
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function doAllChildrenIncludingDeleted($context = null) {
|
||||
if(!$this->owner) user_error('Hierarchy::doAllChildrenIncludingDeleted() called without $this->owner');
|
||||
@ -515,7 +515,7 @@ class Hierarchy extends DataExtension {
|
||||
*
|
||||
* @param showAll Inlcude all of the elements, even those not shown in the menus.
|
||||
* (only applicable when extension is applied to {@link SiteTree}).
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function stageChildren($showAll = false) {
|
||||
if($this->owner->db('ShowInMenus')) {
|
||||
@ -540,7 +540,7 @@ class Hierarchy extends DataExtension {
|
||||
* @param boolean $showAll Include all of the elements, even those not shown in the menus.
|
||||
* (only applicable when extension is applied to {@link SiteTree}).
|
||||
* @param boolean $onlyDeletedFromStage Only return items that have been deleted from stage
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function liveChildren($showAll = false, $onlyDeletedFromStage = false) {
|
||||
if(!$this->owner->hasExtension('Versioned')) throw new Exception('Hierarchy->liveChildren() only works with Versioned extension applied');
|
||||
@ -587,7 +587,7 @@ class Hierarchy extends DataExtension {
|
||||
/**
|
||||
* Return all the parents of this class in a set ordered from the lowest to highest parent.
|
||||
*
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getAncestors() {
|
||||
$ancestors = new ArrayList();
|
||||
|
@ -57,7 +57,7 @@ class SQLMap extends Object implements IteratorAggregate {
|
||||
|
||||
/**
|
||||
* Get the items in this class.
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getItems() {
|
||||
$this->genItems();
|
||||
|
@ -908,8 +908,8 @@ class Versioned extends DataExtension {
|
||||
* @param string $sort A sort expression to be inserted into the ORDER BY clause.
|
||||
* @param string $join A join expression, such as LEFT JOIN or INNER JOIN
|
||||
* @param int $limit A limit on the number of records returned from the database.
|
||||
* @param string $containerClass The container class for the result set (default is DataObjectSet)
|
||||
* @return DataObjectSet
|
||||
* @param string $containerClass The container class for the result set (default is DataList)
|
||||
* @return SS_List
|
||||
*/
|
||||
static function get_by_stage($class, $stage, $filter = '', $sort = '', $join = '', $limit = '', $containerClass = 'DataList') {
|
||||
$result = DataObject::get($class, $filter, $sort, $join, $limit, $containerClass);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* You should run Covert::raw2xml or whatever is appropriate before using it.
|
||||
*
|
||||
* Optionally (but recommended), is creating a static usable_tags method,
|
||||
* which will return a DataObjectSet of all the usable tags that can be parsed.
|
||||
* which will return a SS_List of all the usable tags that can be parsed.
|
||||
* This will (mostly) be used to create helper blocks - telling users what things will be parsed.
|
||||
* Again, @see BBCodeParser for an example of the syntax
|
||||
*
|
||||
|
@ -6,11 +6,11 @@
|
||||
* it just receives a set of search parameters and an object class it acts on.
|
||||
*
|
||||
* The default output of a SearchContext is either a {@link SQLQuery} object
|
||||
* for further refinement, or a {@link DataObjectSet} that can be used to display
|
||||
* for further refinement, or a {@link SS_List} that can be used to display
|
||||
* search results, e.g. in a {@link TableListField} instance.
|
||||
*
|
||||
* In case you need multiple contexts, consider namespacing your request parameters
|
||||
* by using {@link FieldSet->namespace()} on the $fields constructor parameter.
|
||||
* by using {@link FieldList->namespace()} on the $fields constructor parameter.
|
||||
*
|
||||
* Each DataObject subclass can have multiple search contexts for different cases,
|
||||
* e.g. for a limited frontend search and a fully featured backend search.
|
||||
@ -37,7 +37,7 @@ class SearchContext extends Object {
|
||||
* FormFields mapping to {@link DataObject::$db} properties
|
||||
* which are supposed to be searchable.
|
||||
*
|
||||
* @var FieldSet
|
||||
* @var FieldList
|
||||
*/
|
||||
protected $fields;
|
||||
|
||||
@ -79,7 +79,7 @@ class SearchContext extends Object {
|
||||
/**
|
||||
* Returns scaffolded search fields for UI.
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
public function getSearchFields() {
|
||||
return ($this->fields) ? $this->fields : singleton($this->modelClass)->scaffoldSearchFields();
|
||||
@ -159,7 +159,7 @@ class SearchContext extends Object {
|
||||
* @param array $searchParams
|
||||
* @param string|array $sort
|
||||
* @param string|array $limit
|
||||
* @return DataObjectSet
|
||||
* @return SS_List
|
||||
*/
|
||||
public function getResults($searchParams, $sort = false, $limit = false) {
|
||||
$searchParams = array_filter($searchParams, array($this,'clearEmptySearchFields'));
|
||||
@ -232,7 +232,7 @@ class SearchContext extends Object {
|
||||
/**
|
||||
* Get the list of searchable fields in the current search context.
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
public function getFields() {
|
||||
return $this->fields;
|
||||
|
@ -13,11 +13,11 @@ class ChangePasswordForm extends Form {
|
||||
* create the appropriate form action tag.
|
||||
* @param string $name The method on the controller that will return this
|
||||
* form object.
|
||||
* @param FieldSet|FormField $fields All of the fields in the form - a
|
||||
* {@link FieldSet} of {@link FormField}
|
||||
* @param FieldList|FormField $fields All of the fields in the form - a
|
||||
* {@link FieldList} of {@link FormField}
|
||||
* objects.
|
||||
* @param FieldSet|FormAction $actions All of the action buttons in the
|
||||
* form - a {@link FieldSet} of
|
||||
* @param FieldList|FormAction $actions All of the action buttons in the
|
||||
* form - a {@link FieldList} of
|
||||
*/
|
||||
function __construct($controller, $name, $fields = null, $actions = null) {
|
||||
if(isset($_REQUEST['BackURL'])) {
|
||||
|
@ -57,7 +57,7 @@ class Group extends DataObject {
|
||||
/**
|
||||
* Caution: Only call on instances, not through a singleton.
|
||||
*
|
||||
* @return FieldSet
|
||||
* @return FieldList
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
Requirements::javascript(SAPPHIRE_DIR . '/javascript/PermissionCheckboxSetField.js');
|
||||
|
@ -504,7 +504,7 @@ class Member extends DataObject {
|
||||
* Returns the fields for the member form - used in the registration/profile module.
|
||||
* It should return fields that are editable by the admin and the logged-in user.
|
||||
*
|
||||
* @return FieldSet Returns a {@link FieldSet} containing the fields for
|
||||
* @return FieldList Returns a {@link FieldList} containing the fields for
|
||||
* the member form.
|
||||
*/
|
||||
public function getMemberFormFields() {
|
||||
@ -717,7 +717,7 @@ class Member extends DataObject {
|
||||
/**
|
||||
* Check if the member is in one of the given groups.
|
||||
*
|
||||
* @param array|DataObjectSet $groups Collection of {@link Group} DataObjects to check
|
||||
* @param array|SS_List $groups Collection of {@link Group} DataObjects to check
|
||||
* @param boolean $strict Only determine direct group membership if set to true (Default: false)
|
||||
* @return bool Returns TRUE if the member is in one of the given groups, otherwise FALSE.
|
||||
*/
|
||||
@ -1001,7 +1001,7 @@ class Member extends DataObject {
|
||||
|
||||
$groupIDList = array();
|
||||
|
||||
if(is_a($groups, 'DataObjectSet')) {
|
||||
if(is_a($groups, 'SS_List')) {
|
||||
foreach( $groups as $group )
|
||||
$groupIDList[] = $group->ID;
|
||||
} elseif(is_array($groups)) {
|
||||
@ -1047,7 +1047,7 @@ class Member extends DataObject {
|
||||
|
||||
$groupIDList = array();
|
||||
|
||||
if(is_a($groups, 'DataObjectSet')) {
|
||||
if(is_a($groups, 'SS_List')) {
|
||||
foreach($groups as $group) {
|
||||
$groupIDList[] = $group->ID;
|
||||
}
|
||||
@ -1091,10 +1091,10 @@ class Member extends DataObject {
|
||||
|
||||
|
||||
/**
|
||||
* Return a {@link FieldSet} of fields that would appropriate for editing
|
||||
* Return a {@link FieldList} of fields that would appropriate for editing
|
||||
* this member.
|
||||
*
|
||||
* @return FieldSet Return a FieldSet of fields that would appropriate for
|
||||
* @return FieldList Return a FieldList of fields that would appropriate for
|
||||
* editing this member.
|
||||
*/
|
||||
public function getCMSFields() {
|
||||
|
@ -21,11 +21,11 @@ class MemberLoginForm extends LoginForm {
|
||||
* create the appropriate form action tag.
|
||||
* @param string $name The method on the controller that will return this
|
||||
* form object.
|
||||
* @param FieldSet|FormField $fields All of the fields in the form - a
|
||||
* {@link FieldSet} of {@link FormField}
|
||||
* @param FieldList|FormField $fields All of the fields in the form - a
|
||||
* {@link FieldList} of {@link FormField}
|
||||
* objects.
|
||||
* @param FieldSet|FormAction $actions All of the action buttons in the
|
||||
* form - a {@link FieldSet} of
|
||||
* @param FieldList|FormAction $actions All of the action buttons in the
|
||||
* form - a {@link FieldList} of
|
||||
* {@link FormAction} objects
|
||||
* @param bool $checkCurrentUser If set to TRUE, it will be checked if a
|
||||
* the user is currently logged in, and if
|
||||
|
@ -374,7 +374,7 @@ class Permission extends DataObject {
|
||||
* Returns all members for a specific permission.
|
||||
*
|
||||
* @param $code String|array Either a single permission code, or a list of permission codes
|
||||
* @return DataObjectSet Returns a set of member that have the specified
|
||||
* @return SS_List Returns a set of member that have the specified
|
||||
* permission.
|
||||
*/
|
||||
public static function get_members_by_permission($code) {
|
||||
@ -405,7 +405,7 @@ class Permission extends DataObject {
|
||||
/**
|
||||
* Return all of the groups that have one of the given permission codes
|
||||
* @param $codes array|string Either a single permission code, or an array of permission codes
|
||||
* @return DataObjectSet The matching group objects
|
||||
* @return SS_List The matching group objects
|
||||
*/
|
||||
static function get_groups_by_permission($codes) {
|
||||
if(!is_array($codes)) $codes = array($codes);
|
||||
|
@ -19,7 +19,7 @@ class PermissionCheckboxSetField extends FormField {
|
||||
protected $hiddenPermissions = array();
|
||||
|
||||
/**
|
||||
* @var DataObjectSet
|
||||
* @var SS_List
|
||||
*/
|
||||
protected $records = null;
|
||||
|
||||
@ -33,7 +33,7 @@ class PermissionCheckboxSetField extends FormField {
|
||||
* @param String $title
|
||||
* @param String $managedClass
|
||||
* @param String $filterField
|
||||
* @param Group|DataObjectSet $records One or more {@link Group} or {@link PermissionRole} records
|
||||
* @param Group|SS_List $records One or more {@link Group} or {@link PermissionRole} records
|
||||
* used to determine permission checkboxes.
|
||||
* Caution: saveInto() can only be used with a single record, all inherited permissions will be marked readonly.
|
||||
* Setting multiple groups only makes sense in a readonly context. (Optional)
|
||||
@ -47,7 +47,7 @@ class PermissionCheckboxSetField extends FormField {
|
||||
} elseif($records instanceof Group) {
|
||||
$this->records = new ArrayList(array($records));
|
||||
} elseif($records) {
|
||||
throw new InvalidArgumentException('$record should be either a Group record, or a DataObjectSet of Group records');
|
||||
throw new InvalidArgumentException('$record should be either a Group record, or a SS_List of Group records');
|
||||
}
|
||||
|
||||
// Get all available codes in the system as a categorized nested array
|
||||
|
71
tests/dev/DeprecationTest.php
Normal file
71
tests/dev/DeprecationTest.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
class DeprecationTest_Deprecation extends Deprecation {
|
||||
public static function get_module() {
|
||||
return self::get_calling_module_from_trace(debug_backtrace(0));
|
||||
}
|
||||
|
||||
public static function get_method() {
|
||||
return self::get_called_method_from_trace(debug_backtrace(0));
|
||||
}
|
||||
}
|
||||
|
||||
class DeprecationTest extends SapphireTest {
|
||||
|
||||
static $originalVersionInfo;
|
||||
|
||||
function setUp() {
|
||||
self::$originalVersionInfo = Deprecation::dump_settings();
|
||||
Deprecation::$notice_level = E_USER_NOTICE;
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
Deprecation::restore_settings(self::$originalVersionInfo);
|
||||
}
|
||||
|
||||
function testLesserVersionTriggersNoNotice() {
|
||||
Deprecation::notification_version('1.0.0');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test failed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
*/
|
||||
function testEqualVersionTriggersNotice() {
|
||||
Deprecation::notification_version('2.0.0');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
*/
|
||||
function testGreaterVersionTriggersNotice() {
|
||||
Deprecation::notification_version('3.0.0');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
||||
}
|
||||
|
||||
function testNonMatchingModuleNotifcationVersionDoesntAffectNotice() {
|
||||
Deprecation::notification_version('1.0.0');
|
||||
Deprecation::notification_version('3.0.0', 'mysite');
|
||||
$this->callThatOriginatesFromSapphire();
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException PHPUnit_Framework_Error_Notice
|
||||
*/
|
||||
function testMatchingModuleNotifcationVersionAffectsNotice() {
|
||||
Deprecation::notification_version('1.0.0');
|
||||
Deprecation::notification_version('3.0.0', 'sapphire');
|
||||
$this->callThatOriginatesFromSapphire();
|
||||
}
|
||||
|
||||
protected function callThatOriginatesFromSapphire() {
|
||||
$this->assertEquals(DeprecationTest_Deprecation::get_module(), 'sapphire');
|
||||
Deprecation::notice('2.0.0', 'Deprecation test passed');
|
||||
}
|
||||
|
||||
function testMethodNameCalculation() {
|
||||
$this->assertEquals(DeprecationTest_Deprecation::get_method(), 'DeprecationTest->testMethodNameCalculation');
|
||||
}
|
||||
|
||||
}
|
@ -36,7 +36,7 @@ class ComplexTableFieldTest extends FunctionalTest {
|
||||
$parser = new CSSContentParser($field->FieldHolder());
|
||||
|
||||
$this->assertEquals(count($parser->getBySelector('tbody tr')), 2, 'There are 2 players (rows) in the table');
|
||||
$this->assertEquals($field->Items()->Count(), 2, 'There are 2 CTF items in the DataObjectSet');
|
||||
$this->assertEquals($field->Items()->Count(), 2, 'There are 2 CTF items in the SS_List');
|
||||
}
|
||||
|
||||
function testAddingManyManyNewPlayer() {
|
||||
|
@ -294,7 +294,7 @@ class TableListFieldTest extends SapphireTest {
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that a DataObjectSet can be passed to TableListField
|
||||
* Check that a SS_List can be passed to TableListField
|
||||
*/
|
||||
function testDataObjectSet() {
|
||||
$one = new TableListFieldTest_Obj;
|
||||
|
Loading…
Reference in New Issue
Block a user