Issue #1813832 by andypost: Fixed Allow use '0' as id for entity.
parent
d3edf50190
commit
f8673ac410
|
@ -51,7 +51,8 @@ abstract class ConfigEntityBase extends Entity implements ConfigEntityInterface
|
|||
* since each configuration entity is unique.
|
||||
*/
|
||||
final public function isNew() {
|
||||
return !$this->id();
|
||||
$id = $this->id();
|
||||
return !isset($id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -91,7 +91,8 @@ class Entity implements IteratorAggregate, EntityInterface {
|
|||
* Implements EntityInterface::isNew().
|
||||
*/
|
||||
public function isNew() {
|
||||
return !empty($this->enforceIsNew) || !$this->id();
|
||||
$id = $this->id();
|
||||
return !empty($this->enforceIsNew) || !isset($id);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -78,13 +78,16 @@ class ConfigEntityTest extends WebTestBase {
|
|||
// Rename the configuration entity's ID/machine name.
|
||||
$this->assertLinkByHref('admin/structure/config_test/manage/' . $id);
|
||||
$edit = array(
|
||||
'id' => strtolower($this->randomName()),
|
||||
'id' => '0',
|
||||
'label' => $label3,
|
||||
);
|
||||
$this->drupalPost('admin/structure/config_test/manage/' . $id, $edit, 'Save');
|
||||
$this->assertResponse(200);
|
||||
$this->assertNoText($label1);
|
||||
$this->assertText($label3);
|
||||
$this->drupalPost('admin/structure/config_test/manage/0/delete', array(), 'Delete');
|
||||
$this->assertResponse(200);
|
||||
$this->assertNoText($label3);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue