public function setupEntities()
    {
        if ($this->registeredEntities->Count() > 0) {
            return;
        }

        if (Config::inst()->get('DocumentationManifest', 'automatic_registration')) {
            $this->populateEntitiesFromInstall();
        }

        $registered = Config::inst()->get('DocumentationManifest', 'register_entities');

        foreach ($registered as $details) {
            // validate the details provided through the YAML configuration
            $required = array('Path', 'Title');

            foreach ($required as $require) {
                if (!isset($details[$require])) {
                    throw new Exception("$require is a required key in DocumentationManifest.register_entities");
                }
            }

            // if path is not an absolute value then assume it is relative from
            // the BASE_PATH.
            $path = $this->getRealPath($details['Path']);

            $key = (isset($details['Key'])) ? $details['Key'] : $details['Title'];

            if (!$path || !is_dir($path)) {
                trigger_error($details['Path'] . ' is not a valid documentation directory', E_USER_WARNING);
                continue;
            }

            $version = (isset($details['Version'])) ? $details['Version'] : '';

            $versionTitle = isset($details['VersionTitle'])
                ? $details['VersionTitle']
                : $version;

            $archived = !empty($details['Archived']);

            $branch = (isset($details['Branch'])) ? $details['Branch'] : '';

            $langs = scandir($path);

            if ($langs) {
                $possible = i18n::get_common_languages(true);

                foreach ($langs as $k => $lang) {
                    if (isset($possible[$lang])) {
                        /**
                         * @var DocumentationEntity $entity
                         */
                        $entity = Injector::inst()->create(
                            'DocumentationEntity',
                            $key
                        );

                        $entity->setPath(DocumentationHelper::normalizePath(Controller::join_links($path, $lang, '/')));
                        $entity->setTitle($details['Title']);
                        $entity->setLanguage($lang);
                        $entity->setVersion($version);
                        $entity->setVersionTitle($versionTitle);
                        $entity->setBranch($branch);
                        $entity->setIsArchived($archived);

                        if (isset($details['Stable'])) {
                            $entity->setIsStable($details['Stable']);
                        }

                        if (isset($details['DefaultEntity'])) {
                            $entity->setIsDefaultEntity($details['DefaultEntity']);
                            if ($entity->getIsDefaultEntity()) {
                                $this->has_default_entity = true;
                            }
                        }

                        $this->registeredEntities->push($entity);
                    }
                }
            }
        }
    }
public function setupEntities()
    {
        if ($this->registeredEntities->Count() > 0) {
            return;
        }

        if (Config::inst()->get('DocumentationManifest', 'automatic_registration')) {
            $this->populateEntitiesFromInstall();
        }

        $registered = Config::inst()->get('DocumentationManifest', 'register_entities');

        foreach ($registered as $details) {
            // validate the details provided through the YAML configuration
            $required = array('Path', 'Title');

            foreach ($required as $require) {
                if (!isset($details[$require])) {
                    throw new Exception("$require is a required key in DocumentationManifest.register_entities");
                }
            }

            // if path is not an absolute value then assume it is relative from
            // the BASE_PATH.
            $path = $this->getRealPath($details['Path']);

            $key = (isset($details['Key'])) ? $details['Key'] : $details['Title'];

            if (!$path || !is_dir($path)) {
                trigger_error($details['Path'] . ' is not a valid documentation directory', E_USER_WARNING);
                continue;
            }

            $version = (isset($details['Version'])) ? $details['Version'] : '';

            $versionTitle = isset($details['VersionTitle'])
                ? $details['VersionTitle']
                : $version;

            $archived = !empty($details['Archived']);

            $branch = (isset($details['Branch'])) ? $details['Branch'] : '';

            $langs = scandir($path);

            if ($langs) {
                $possible = i18n::get_common_languages(true);

                foreach ($langs as $k => $lang) {
                    if (isset($possible[$lang])) {
                        /**
                         * @var DocumentationEntity $entity
                         */
                        $entity = Injector::inst()->create(
                            'DocumentationEntity',
                            $key
                        );

                        $entity->setPath(DocumentationHelper::normalizePath(Controller::join_links($path, $lang, '/')));
                        $entity->setTitle($details['Title']);
                        $entity->setLanguage($lang);
                        $entity->setVersion($version);
                        $entity->setVersionTitle($versionTitle);
                        $entity->setBranch($branch);
                        $entity->setIsArchived($archived);

                        if (isset($details['Stable'])) {
                            $entity->setIsStable($details['Stable']);
                        }

                        if (isset($details['DefaultEntity'])) {
                            $entity->setIsDefaultEntity($details['DefaultEntity']);
                            if ($entity->getIsDefaultEntity()) {
                                $this->has_default_entity = true;
                            }
                        }

                        $this->registeredEntities->push($entity);
                    }
                }
            }
        }
    }
public function setupEntities ( ) { if ( $ this -> registeredEntities -> Count ( ) > 0 ) { return ; } if ( Config :: inst ( ) -> get ( 'DocumentationManifest' , 'automatic_registration' ) ) { $ this -> populateEntitiesFromInstall ( ) ; } $ registered = Config :: inst ( ) -> get ( 'DocumentationManifest' , 'register_entities' ) ; foreach ( $ registered as $ details ) { // validate the details provided through the YAML configuration $ required = array ( 'Path' , 'Title' ) ; foreach ( $ required as $ require ) { if ( ! isset ( $ details [ $ require ] ) ) { throw new Exception ( "$require is a required key in DocumentationManifest.register_entities" ) ; } } // if path is not an absolute value then assume it is relative from // the BASE_PATH. $ path = $ this -> getRealPath ( $ details [ 'Path' ] ) ; $ key = ( isset ( $ details [ 'Key' ] ) ) ? $ details [ 'Key' ] : $ details [ 'Title' ] ; if ( ! $ path || ! is_dir ( $ path ) ) { trigger_error ( $ details [ 'Path' ] . ' is not a valid documentation directory' , E_USER_WARNING ) ; continue ; } $ version = ( isset ( $ details [ 'Version' ] ) ) ? $ details [ 'Version' ] : '' ; $ versionTitle = isset ( $ details [ 'VersionTitle' ] ) ? $ details [ 'VersionTitle' ] : $ version ; $ archived = ! empty ( $ details [ 'Archived' ] ) ; $ branch = ( isset ( $ details [ 'Branch' ] ) ) ? $ details [ 'Branch' ] : '' ; $ langs = scandir ( $ path ) ; if ( $ langs ) { $ possible = i18n :: get_common_languages ( true ) ; foreach ( $ langs as $ k => $ lang ) { if ( isset ( $ possible [ $ lang ] ) ) { /**
                         * @var DocumentationEntity $entity
                         */ $ entity = Injector :: inst ( ) -> create ( 'DocumentationEntity' , $ key ) ; $ entity -> setPath ( DocumentationHelper :: normalizePath ( Controller :: join_links ( $ path , $ lang , '/' ) ) ) ; $ entity -> setTitle ( $ details [ 'Title' ] ) ; $ entity -> setLanguage ( $ lang ) ; $ entity -> setVersion ( $ version ) ; $ entity -> setVersionTitle ( $ versionTitle ) ; $ entity -> setBranch ( $ branch ) ; $ entity -> setIsArchived ( $ archived ) ; if ( isset ( $ details [ 'Stable' ] ) ) { $ entity -> setIsStable ( $ details [ 'Stable' ] ) ; } if ( isset ( $ details [ 'DefaultEntity' ] ) ) { $ entity -> setIsDefaultEntity ( $ details [ 'DefaultEntity' ] ) ; if ( $ entity -> getIsDefaultEntity ( ) ) { $ this -> has_default_entity = true ; } } $ this -> registeredEntities -> push ( $ entity ) ; } } } } }
Sets up the top level entities.

Either manually registered through the YAML syntax or automatically
loaded through investigating the file system for `docs` folder.
Sets up the top level entities .