mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API CHANGE Renamed setContainerFieldSet() to setContainerFieldList() to match the FieldList API.
API CHANGE Renamed rootFieldSet() to rootFieldList() to match the FieldList API.
This commit is contained in:
parent
a53cca8932
commit
9da92e04cf
@ -248,8 +248,8 @@ class CompositeField extends FormField {
|
|||||||
return $this->children->replaceField($fieldName, $newField);
|
return $this->children->replaceField($fieldName, $newField);
|
||||||
}
|
}
|
||||||
|
|
||||||
function rootFieldSet() {
|
function rootFieldList() {
|
||||||
if(is_object($this->containerFieldSet)) return $this->containerFieldSet->rootFieldSet();
|
if(is_object($this->containerFieldList)) return $this->containerFieldList->rootFieldList();
|
||||||
else return $this->children;
|
else return $this->children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class FieldList extends ArrayList {
|
|||||||
parent::__construct($items);
|
parent::__construct($items);
|
||||||
|
|
||||||
foreach ($items as $item) {
|
foreach ($items as $item) {
|
||||||
if ($item instanceof FormField) $item->setContainerFieldSet($this);
|
if ($item instanceof FormField) $item->setContainerFieldList($this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +332,7 @@ class FieldList extends ArrayList {
|
|||||||
foreach($dataFields as $child) {
|
foreach($dataFields as $child) {
|
||||||
if(trim($name) == trim($child->getName()) || $name == $child->id) return $child;
|
if(trim($name) == trim($child->getName()) || $name == $child->id) return $child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -343,7 +343,7 @@ class FieldList extends ArrayList {
|
|||||||
*/
|
*/
|
||||||
public function insertBefore($item, $name) {
|
public function insertBefore($item, $name) {
|
||||||
$this->onBeforeInsert($item);
|
$this->onBeforeInsert($item);
|
||||||
$item->setContainerFieldSet($this);
|
$item->setContainerFieldList($this);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($this->items as $child) {
|
foreach($this->items as $child) {
|
||||||
@ -368,7 +368,7 @@ class FieldList extends ArrayList {
|
|||||||
*/
|
*/
|
||||||
public function insertAfter($item, $name) {
|
public function insertAfter($item, $name) {
|
||||||
$this->onBeforeInsert($item);
|
$this->onBeforeInsert($item);
|
||||||
$item->setContainerFieldSet($this);
|
$item->setContainerFieldList($this);
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach($this->items as $child) {
|
foreach($this->items as $child) {
|
||||||
@ -393,7 +393,7 @@ class FieldList extends ArrayList {
|
|||||||
*/
|
*/
|
||||||
public function push($item, $key = null) {
|
public function push($item, $key = null) {
|
||||||
$this->onBeforeInsert($item);
|
$this->onBeforeInsert($item);
|
||||||
$item->setContainerFieldSet($this);
|
$item->setContainerFieldList($this);
|
||||||
return parent::push($item, $key = null);
|
return parent::push($item, $key = null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ class FieldList extends ArrayList {
|
|||||||
*/
|
*/
|
||||||
protected function onBeforeInsert($item) {
|
protected function onBeforeInsert($item) {
|
||||||
$this->flushFieldsCache();
|
$this->flushFieldsCache();
|
||||||
if($item->getName()) $this->rootFieldSet()->removeByName($item->getName(), true);
|
if($item->getName()) $this->rootFieldList()->removeByName($item->getName(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -479,8 +479,8 @@ class FieldList extends ArrayList {
|
|||||||
/**
|
/**
|
||||||
* Returns the root field set that this belongs to
|
* Returns the root field set that this belongs to
|
||||||
*/
|
*/
|
||||||
public function rootFieldSet() {
|
public function rootFieldList() {
|
||||||
if($this->containerField) return $this->containerField->rootFieldSet();
|
if($this->containerField) return $this->containerField->rootFieldList();
|
||||||
else return $this;
|
else return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,8 @@ class FormField extends RequestHandler {
|
|||||||
/**
|
/**
|
||||||
* Stores a reference to the FieldList that contains this object.
|
* Stores a reference to the FieldList that contains this object.
|
||||||
* @var FieldList
|
* @var FieldList
|
||||||
*/
|
*/
|
||||||
protected $containerFieldSet;
|
protected $containerFieldList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var boolean
|
* @var boolean
|
||||||
@ -837,19 +837,30 @@ class FormField extends RequestHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setContainerFieldSet($list) {
|
||||||
|
Deprecation::notice('3.0', 'Use setContainerFieldList() instead.');
|
||||||
|
return $this->setContainerFieldList($list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the FieldList that contains this field.
|
* Set the FieldList that contains this field.
|
||||||
*
|
*
|
||||||
* @param FieldList $containerFieldSet
|
* @param FieldList $list
|
||||||
*/
|
* @return FieldList
|
||||||
function setContainerFieldSet($containerFieldSet) {
|
*/
|
||||||
$this->containerFieldSet = $containerFieldSet;
|
function setContainerFieldList($list) {
|
||||||
|
$this->containerFieldList = $list;
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rootFieldSet() {
|
function rootFieldSet() {
|
||||||
if(is_object($this->containerFieldSet)) return $this->containerFieldSet->rootFieldSet();
|
Deprecation::notice('3.0', 'Use rootFieldList() instead.');
|
||||||
else user_error("rootFieldSet() called on $this->class object without a containerFieldSet", E_USER_ERROR);
|
return $this->rootFieldList();
|
||||||
|
}
|
||||||
|
|
||||||
|
function rootFieldList() {
|
||||||
|
if(is_object($this->containerFieldList)) return $this->containerFieldList->rootFieldList();
|
||||||
|
else user_error("rootFieldList() called on $this->class object without a containerFieldList", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -386,7 +386,7 @@ class FieldListTest extends SapphireTest {
|
|||||||
$this->assertEquals('Title', $fields[1]->getName());
|
$this->assertEquals('Title', $fields[1]->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testrootFieldSet() {
|
function testrootFieldList() {
|
||||||
/* Given a nested set of FormField, CompositeField, and FieldList objects */
|
/* Given a nested set of FormField, CompositeField, and FieldList objects */
|
||||||
$FieldList = new FieldList(
|
$FieldList = new FieldList(
|
||||||
$root = new TabSet("Root",
|
$root = new TabSet("Root",
|
||||||
@ -397,22 +397,22 @@ class FieldListTest extends SapphireTest {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
/* rootFieldSet() should always evaluate to the same object: the topmost FieldList */
|
/* rootFieldList() should always evaluate to the same object: the topmost FieldList */
|
||||||
$this->assertSame($FieldList, $FieldList->rootFieldSet());
|
$this->assertSame($FieldList, $FieldList->rootFieldList());
|
||||||
$this->assertSame($FieldList, $root->rootFieldSet());
|
$this->assertSame($FieldList, $root->rootFieldList());
|
||||||
$this->assertSame($FieldList, $main->rootFieldSet());
|
$this->assertSame($FieldList, $main->rootFieldList());
|
||||||
$this->assertSame($FieldList, $a->rootFieldSet());
|
$this->assertSame($FieldList, $a->rootFieldList());
|
||||||
$this->assertSame($FieldList, $b->rootFieldSet());
|
$this->assertSame($FieldList, $b->rootFieldList());
|
||||||
|
|
||||||
/* If we push additional fields, they should also have the same rootFieldSet() */
|
/* If we push additional fields, they should also have the same rootFieldList() */
|
||||||
$root->push($other = new Tab("Other"));
|
$root->push($other = new Tab("Other"));
|
||||||
$other->push($c = new TextField("C"));
|
$other->push($c = new TextField("C"));
|
||||||
$root->push($third = new Tab("Third", $d = new TextField("D")));
|
$root->push($third = new Tab("Third", $d = new TextField("D")));
|
||||||
|
|
||||||
$this->assertSame($FieldList, $other->rootFieldSet());
|
$this->assertSame($FieldList, $other->rootFieldList());
|
||||||
$this->assertSame($FieldList, $third->rootFieldSet());
|
$this->assertSame($FieldList, $third->rootFieldList());
|
||||||
$this->assertSame($FieldList, $c->rootFieldSet());
|
$this->assertSame($FieldList, $c->rootFieldList());
|
||||||
$this->assertSame($FieldList, $d->rootFieldSet());
|
$this->assertSame($FieldList, $d->rootFieldList());
|
||||||
}
|
}
|
||||||
|
|
||||||
function testAddingDuplicateReplacesOldField() {
|
function testAddingDuplicateReplacesOldField() {
|
||||||
|
Loading…
Reference in New Issue
Block a user