From f811e7e69eefef4e5817f86bb0e7097886375147 Mon Sep 17 00:00:00 2001 From: Phill Price Date: Fri, 24 Oct 2014 13:33:14 +0100 Subject: [PATCH] Used 3x way to find if object exists. Split BlogHolder and BlogEntry record generation. --- code/BlogHolder.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/code/BlogHolder.php b/code/BlogHolder.php index 48edefc..98954e9 100644 --- a/code/BlogHolder.php +++ b/code/BlogHolder.php @@ -124,9 +124,7 @@ class BlogHolder extends BlogTree implements PermissionProvider { // Skip creation of default records if(!self::config()->create_default_pages) return; - $blogHolder = DataObject::get_one('BlogHolder'); - //TODO: This does not check for whether this blogholder is an orphan or not - if(!$blogHolder) { + if(!BlogHolder::get()->exists()) { $blogholder = new BlogHolder(); $blogholder->Title = "Blog"; $blogholder->URLSegment = "blog"; @@ -165,6 +163,9 @@ class BlogHolder extends BlogTree implements PermissionProvider { } } + DB::alteration_message("Blog holder created","created"); + } + if(!BlogEntry::get()->exists()) { $blog = new BlogEntry(); $blog->Title = _t('BlogHolder.SUCTITLE', "SilverStripe blog module successfully installed"); $blog->URLSegment = 'sample-blog-entry'; @@ -175,7 +176,7 @@ class BlogHolder extends BlogTree implements PermissionProvider { $blog->write(); $blog->publish("Stage", "Live"); - DB::alteration_message("Blog page created","created"); + DB::alteration_message("Blog entry created","created"); } }