src/GridFieldAddNewMultiClass.php
public function getClasses(GridField $grid)
    {
        $result = array();

        if (is_null($this->classes)) {
            $classes = array_values(ClassInfo::subclassesFor($grid->getModelClass()));
            sort($classes);
        } else {
            $classes = $this->classes;
        }

        $kill_ancestors = array();
        foreach ($classes as $class => $title) {
            if (!is_string($class)) {
                $class = $title;
            }
            if (!class_exists($class)) {
                continue;
            }
            $is_abstract = (($reflection = new ReflectionClass($class)) && $reflection->isAbstract());
            if (!$is_abstract && $class === $title) {
                $title = singleton($class)->i18n_singular_name();
            }

            if ($ancestor_to_hide = Config::inst()->get($class, 'hide_ancestor')) {
                $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]);
            }
        }

        $sanitised = array();
        foreach ($result as $class => $title) {
            $sanitised[$this->sanitiseClassName($class)] = $title;
        }

        return $sanitised;
    }
public function getClasses(GridField $grid)
    {
        $result = array();

        if (is_null($this->classes)) {
            $classes = array_values(ClassInfo::subclassesFor($grid->getModelClass()));
            sort($classes);
        } else {
            $classes = $this->classes;
        }

        $kill_ancestors = array();
        foreach ($classes as $class => $title) {
            if (!is_string($class)) {
                $class = $title;
            }
            if (!class_exists($class)) {
                continue;
            }
            $is_abstract = (($reflection = new ReflectionClass($class)) && $reflection->isAbstract());
            if (!$is_abstract && $class === $title) {
                $title = singleton($class)->i18n_singular_name();
            }

            if ($ancestor_to_hide = Config::inst()->get($class, 'hide_ancestor')) {
                $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]);
            }
        }

        $sanitised = array();
        foreach ($result as $class => $title) {
            $sanitised[$this->sanitiseClassName($class)] = $title;
        }

        return $sanitised;
    }
public function getClasses ( GridField $ grid ) { $ result = array ( ) ; if ( is_null ( $ this -> classes ) ) { $ classes = array_values ( ClassInfo :: subclassesFor ( $ grid -> getModelClass ( ) ) ) ; sort ( $ classes ) ; } else { $ classes = $ this -> classes ; } $ kill_ancestors = array ( ) ; foreach ( $ classes as $ class => $ title ) { if ( ! is_string ( $ class ) ) { $ class = $ title ; } if ( ! class_exists ( $ class ) ) { continue ; } $ is_abstract = ( ( $ reflection = new ReflectionClass ( $ class ) ) && $ reflection -> isAbstract ( ) ) ; if ( ! $ is_abstract && $ class === $ title ) { $ title = singleton ( $ class ) -> i18n_singular_name ( ) ; } if ( $ ancestor_to_hide = Config :: inst ( ) -> get ( $ class , 'hide_ancestor' ) ) { $ 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 ] ) ; } } $ sanitised = array ( ) ; foreach ( $ result as $ class => $ title ) { $ sanitised [ $ this -> sanitiseClassName ( $ class ) ] = $ title ; } return $ sanitised ; }
Gets the classes that can be created using this button, defaulting to the model class and
its subclasses.

@param GridField $grid
@return array a map of class name to title
Gets the classes that can be created using this button defaulting to the model class and its subclasses .