5098 Posts in 1518 Topics by 1115 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 304 Views |
-
SS3 - canCreate/canDelete functions

24 September 2012 at 5:36pm Last edited: 24 September 2012 5:37pm
Hi guys,
I like to stop pages from being created if there is already an instance of it, and likewise stop it from being deleted.
Up until I started using Silverstripe 3 (last week), I've been using the following code:public function canCreate() {
return false
}
public function canDelete() {
return false
}
orpublic function canCreate() {
return !DataObject::get_one($this->ClassName);
}
public function canDelete() {
return !DataObject::get_one($this->ClassName);
}However now it doesn't work with SS3. I get the following error:
[Strict Notice] Declaration of HomePage::canCreate() should be compatible with that of SiteTree::canCreate()Does anyone know how I can get the same functionality in SS3?
Thanks in advance,
Ruth. -
Re: SS3 - canCreate/canDelete functions

24 September 2012 at 6:32pm
That functionality still works, you just need to have method decelerations be compatible with those you're overriding. Usually, this just means have the same prototype.
In this case, that's
.public function canCreate($member = null)
| 304 Views | ||
|
Page:
1
|
Go to Top |

