Update BlogHolder.php

Used 3x way to find if object exists. Unsure if you're happy with the split of the Blog Entry as it would mean automatically creating a BlogEntry even if it had previously been deleted? Thoughts/
This commit is contained in:
Phill Price 2014-10-23 21:33:56 +01:00
parent 638b309b69
commit d1ccbc583a

View File

@ -124,9 +124,7 @@ class BlogHolder extends BlogTree implements PermissionProvider {
// Skip creation of default records // Skip creation of default records
if(!self::config()->create_default_pages) return; if(!self::config()->create_default_pages) return;
$blogHolder = DataObject::get_one('BlogHolder'); if(!BlogHolder::get()->exists()) {
//TODO: This does not check for whether this blogholder is an orphan or not
if(!$blogHolder) {
$blogholder = new BlogHolder(); $blogholder = new BlogHolder();
$blogholder->Title = "Blog"; $blogholder->Title = "Blog";
$blogholder->URLSegment = "blog"; $blogholder->URLSegment = "blog";
@ -164,7 +162,8 @@ class BlogHolder extends BlogTree implements PermissionProvider {
} }
} }
} }
}
if(!BlogEntry::get()->exists()) {
$blog = new BlogEntry(); $blog = new BlogEntry();
$blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed"); $blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed");
$blog->URLSegment = 'sample-blog-entry'; $blog->URLSegment = 'sample-blog-entry';