mirror of
https://github.com/symbiote/silverstripe-gridfieldextensions.git
synced 2024-10-22 17:05:39 +02:00
Merge pull request #125 from SilbinaryWolf/support-hide-ancestor
Added support for 'hide_ancestor' config on GridFieldAddNewMultiClass
This commit is contained in:
commit
7d1a48c5d7
@ -92,24 +92,35 @@ class GridFieldAddNewMultiClass implements GridField_HTMLProvider, GridField_URL
|
||||
$classes = $this->classes;
|
||||
}
|
||||
|
||||
$kill_ancestors = array();
|
||||
foreach($classes as $class => $title) {
|
||||
if(!is_string($class)) {
|
||||
$class = $title;
|
||||
if (($reflection = new ReflectionClass($class)) && $reflection->isAbstract()) {
|
||||
continue;
|
||||
$is_abstract = (($reflection = new ReflectionClass($class)) && $reflection->isAbstract());
|
||||
if (!$is_abstract) {
|
||||
$title = singleton($class)->i18n_singular_name();
|
||||
}
|
||||
$title = singleton($class)->i18n_singular_name();
|
||||
} else if (($reflection = new ReflectionClass($class)) && $reflection->isAbstract()) {
|
||||
continue;
|
||||
} else {
|
||||
$is_abstract = (($reflection = new ReflectionClass($class)) && $reflection->isAbstract());
|
||||
}
|
||||
|
||||
if(!singleton($class)->canCreate()) {
|
||||
if ($ancestor_to_hide = Config::inst()->get($class, 'hide_ancestor', Config::FIRST_SET)) {
|
||||
$kill_ancestors[$ancestor_to_hide] = true;
|
||||
}
|
||||
|
||||
if($is_abstract || !singleton($class)->canCreate()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$result[$class] = $title;
|
||||
}
|
||||
|
||||
if($kill_ancestors) {
|
||||
foreach($kill_ancestors as $class => $bool) {
|
||||
unset($result[$class]);
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user