mirror of
https://github.com/silverstripe/silverstripe-docsviewer
synced 2024-10-22 11:05:56 +02:00
Prevent automatic registration running multiple times
Fix up automatic registration details.
This commit is contained in:
parent
9cf55c57d7
commit
db2a94b56c
@ -59,6 +59,11 @@ class DocumentationManifest {
|
|||||||
*/
|
*/
|
||||||
private $entity;
|
private $entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var boolean
|
||||||
|
*/
|
||||||
|
private $automaticallyPopulated = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var ArrayList
|
* @var ArrayList
|
||||||
*/
|
*/
|
||||||
@ -91,6 +96,10 @@ class DocumentationManifest {
|
|||||||
* loaded through investigating the file system for `docs` folder.
|
* loaded through investigating the file system for `docs` folder.
|
||||||
*/
|
*/
|
||||||
public function setupEntities() {
|
public function setupEntities() {
|
||||||
|
if($this->registeredEntities->Count() > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if(Config::inst()->get('DocumentationManifest', 'automatic_registration')) {
|
if(Config::inst()->get('DocumentationManifest', 'automatic_registration')) {
|
||||||
$this->populateEntitiesFromInstall();
|
$this->populateEntitiesFromInstall();
|
||||||
}
|
}
|
||||||
@ -172,23 +181,26 @@ class DocumentationManifest {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function populateEntitiesFromInstall() {
|
public function populateEntitiesFromInstall() {
|
||||||
$entities = array();
|
if($this->automaticallyPopulated) {
|
||||||
|
// already run
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
foreach(scandir(BASE_PATH) as $key => $entity) {
|
foreach(scandir(BASE_PATH) as $key => $entity) {
|
||||||
if($key == "themes") {
|
if($key == "themes") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dir = is_dir(Controller::join_links(BASE_PATH, $entity));
|
$dir = Controller::join_links(BASE_PATH, $entity);
|
||||||
|
|
||||||
if($dir) {
|
if(is_dir($dir)) {
|
||||||
// check to see if it has docs
|
// check to see if it has docs
|
||||||
$docs = Controller::join_links($dir, 'docs');
|
$docs = Controller::join_links($dir, 'docs');
|
||||||
|
|
||||||
if(is_dir($docs)) {
|
if(is_dir($docs)) {
|
||||||
$entities[] = array(
|
$entities[] = array(
|
||||||
'BasePath' => $entity,
|
'Path' => $docs,
|
||||||
'Folder' => $key,
|
'Title' => DocumentationHelper::clean_page_name($entity),
|
||||||
'Version' => 'master',
|
'Version' => 'master',
|
||||||
'Stable' => true
|
'Stable' => true
|
||||||
);
|
);
|
||||||
@ -197,8 +209,10 @@ class DocumentationManifest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Config::inst()->update(
|
Config::inst()->update(
|
||||||
'DocumentationManifest', 'registered_entities', $entities
|
'DocumentationManifest', 'register_entities', $entities
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->automaticallyPopulated = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user