Skip to content

Commit

Permalink
Fixed exception if class associated with PageType no longer exists
Browse files Browse the repository at this point in the history
  • Loading branch information
colintucker committed May 24, 2017
1 parent 2eba06b commit 0c72dcd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/Model/PageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
namespace SilverWare\Model;

use SilverStripe\Core\ClassInfo;
use SilverStripe\Core\Injector\Injector;
use SilverStripe\Forms\DropdownField;
use SilverStripe\Forms\FieldList;
use SilverStripe\Forms\RequiredFields;
Expand Down Expand Up @@ -261,8 +262,8 @@ public function getTitle()
*/
public function getPageName()
{
if ($this->PageClass) {
return singleton($this->PageClass)->i18n_singular_name();
if ($this->PageClass && class_exists($this->PageClass)) {
return Injector::inst()->get($this->PageClass)->i18n_singular_name();
}
}

Expand Down Expand Up @@ -320,7 +321,7 @@ public function getPageClassOptions()
$type = self::findByClass($class);

if (!$type || $type->ID == $this->ID) {
$options[$class] = singleton($class)->i18n_singular_name();
$options[$class] = Injector::inst()->get($class)->i18n_singular_name();
}

}
Expand Down
2 changes: 1 addition & 1 deletion src/Tools/ClassTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function getVisibleSubClasses($name)

foreach ($classes as $class) {

$instance = singleton($class);
$instance = Injector::inst()->get($class);

if ($ancestor = $instance->stat('hide_ancestor')) {
$remove[$ancestor] = $ancestor;
Expand Down

0 comments on commit 0c72dcd

Please sign in to comment.