Last active
September 7, 2021 15:09
-
-
Save dzhuryn/fb3c90794c33d0f8ac6b410800756dfb to your computer and use it in GitHub Desktop.
pb.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getConfig($elements=[],$folder = '') | |
{ | |
$folderPath = $folderName = ''; | |
if(!empty($folder) ){ | |
$folderPath = $folder.'/'; | |
$folderName = $folder.'_'; | |
} | |
foreach (scandir($this->path.$folderPath) as $entry) { | |
if($entry == '.' || $entry == '..'){ | |
continue; | |
} | |
if (pathinfo($entry, PATHINFO_EXTENSION) == 'php') { | |
$name = pathinfo($entry, PATHINFO_FILENAME); | |
$elements[] = [ | |
'name'=>$folderName.$name, | |
'folder'=>$folderPath.$name, | |
]; | |
} | |
if(is_dir($this->path.$folderPath.$entry)){ | |
$elements = $this->getConfig($elements,$folderPath.$entry); | |
} | |
} | |
return $elements; | |
} | |
//в методе fetch переписываем цыкл | |
// Loading all config files, that complied with filters | |
foreach ($this->getConfig() as $entry) { | |
$name = $entry['name']; | |
$block = include($this->path . $entry['folder'].'.php'); | |
$block['isContainer'] = strpos($name, 'container.') === 0; | |
$block['name'] = $name = str_replace('container.', '', $name); | |
if ($this->canIncludeBlock($block, $docid)) { | |
if ($this->isBackend) { | |
unset($block['templates']); | |
} | |
if (!isset($block['order'])) { | |
$block['order'] = PHP_INT_MAX; | |
} | |
if ($block['isContainer']) { | |
$block['sections'] = []; | |
$this->containers[$name] = $block; | |
} else { | |
if (!isset($block['container'])) { | |
$block['container'] = 'default'; | |
} | |
$block['name'] = $name; | |
$this->conf[$name] = $block; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment