From 7b88435b7ef8e05ff1a10878b0030057f3d87e33 Mon Sep 17 00:00:00 2001 From: David Craig Date: Wed, 25 Mar 2015 12:06:02 +1300 Subject: [PATCH] Minor improvements to BlogMemberExtension --- code/extensions/BlogMemberExtension.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/code/extensions/BlogMemberExtension.php b/code/extensions/BlogMemberExtension.php index 3ade07e..815bbb3 100644 --- a/code/extensions/BlogMemberExtension.php +++ b/code/extensions/BlogMemberExtension.php @@ -10,7 +10,7 @@ class BlogMemberExtension extends DataExtension { private static $db = array( - 'URLSegment' => 'Varchar', + 'URLSegment' => 'Varchar(50)', 'BlogProfileSummary' => 'Text' ); @@ -47,8 +47,7 @@ class BlogMemberExtension extends DataExtension { */ public function generateURLSegment() { $filter = URLSegmentFilter::create(); - $name = $this->owner->FirstName . ' ' . $this->owner->Surname; - $urlSegment = $filter->filter($name); + $urlSegment = $filter->filter($this->owner->getName()); // Fallback to generic profile name if path is empty (= no valid, convertable characters) if(!$urlSegment || $urlSegment == '-' || $urlSegment == '-1') $urlSegment = "profile-$this->ID"; @@ -70,7 +69,7 @@ class BlogMemberExtension extends DataExtension { $conflict = $conflict->exclude('ID', $this->owner->ID); } - return $conflict->count() == 0; + return !$conflict->exists(); } }