/** * Retrieve layout file from all module but just in current theme * * @return mixed */ public function scanLayout() { $key = $this->getKey(['scan', 'all-layout', 'in', 'all-modules', 'but', 'only', 'in', 'current-theme']); if (is_null($this->getData($key))) { $pathModules = $this->module->getPath(); $moduleDirectories = scandir($pathModules); foreach ($moduleDirectories as $moduleDir) { if (!in_array($moduleDir, [".", ".."])) { /*Layouts path của module hiện tại*/ $currentFolderLayoutsPathInModule = $pathModules . '/' . $moduleDir . '/themes/' . $this->izTheme->getCurrentThemeName() . '/layouts'; /*Check layouts path file exist*/ if (!file_exists($currentFolderLayoutsPathInModule)) { continue; } $layoutFiles = scandir($currentFolderLayoutsPathInModule); foreach ($layoutFiles as $layoutFile) { if (!in_array($layoutFile, [".", ".."])) { if (pathinfo($layoutFile, PATHINFO_EXTENSION) !== 'php') { continue; } $layoutFileNameWithoutExt = preg_replace('/(\\.blade\\.php)$/', '', $layoutFile); $this->_layouts[] = $layoutFileNameWithoutExt; } } } } $this->setData($key, $this->_layouts); } return $this->getData($key); }
/** * Retrieve all file xml in all theme but just in current theme * FIXME: Need cache here * * @return mixed */ protected function scanThemeXml() { /*FIXME: need cache xml*/ $key = $this->getKey(['retrieve', 'all-xml', 'in', 'all-modules', 'only', 'current-theme']); if (is_null($this->getData($key))) { $pathModules = $this->module->getPath(); $moduleDirectories = scandir($pathModules); foreach ($moduleDirectories as $moduleDir) { if (!in_array($moduleDir, [".", ".."])) { /*Xml path của module hiện tại*/ $currentFolderXmlPathInModule = $pathModules . '/' . $moduleDir . '/themes/' . $this->getCurrentTheme() . '/xml'; /*Check xml path file exist*/ if (!file_exists($currentFolderXmlPathInModule)) { continue; } $xmlFiles = scandir($currentFolderXmlPathInModule); foreach ($xmlFiles as $xmlFile) { if (!in_array($xmlFile, [".", ".."])) { if (pathinfo($xmlFile, PATHINFO_EXTENSION) !== 'xml') { continue; } $currentXMLDir = $currentFolderXmlPathInModule . '/' . $xmlFile; $xml = simplexml_load_file($currentXMLDir); $xmlFile = preg_replace('/\\.[^.\\s]{3,4}$/', '', $xmlFile); // May have many xml for this path in themes each modules if (!isset($this->xmlThemeData[$xmlFile])) { $this->xmlThemeData[$xmlFile] = []; } foreach ($xml as $node => $scope) { switch ($node) { case 'bower_components': $this->convertXmlScopeBowerComponent($scope, $xmlFile); break; case 'custom_assets': $this->convertXmlScopeCustomAssets($scope, $xmlFile); break; case 'view_data': $this->convertXmlScopeViewData($scope, $xmlFile); break; case 'app_dependencies': $this->convertXmlScopeAppDependency($scope, $xmlFile); break; } } } } } } $this->setData($key, $this->xmlThemeData); } return $this->getData($key); }
/** * Get all assets in each theme in each module * * @return array * @throws \Exception */ public function getAssetsTree() { if (is_null($this->assets)) { $this->assets = []; $pathModules = $this->module->getPath(); $moduleDirs = scandir($pathModules); foreach ($moduleDirs as $moduleDir) { if (!in_array($moduleDir, [".", ".."])) { /*Path Config/Vendor của module hiện tại*/ $currentModuleThemePaths = $pathModules . '/' . $moduleDir . '/themes'; /*Kiểm tra xem module hiện tại có thư mục themes không*/ if (!file_exists($currentModuleThemePaths)) { continue; } $themePath = scandir($currentModuleThemePaths); foreach ($themePath as $themDir) { if (!in_array($themDir, [".", ".."])) { $currentThemeDir = $currentModuleThemePaths . '/' . $themDir . '/config.php'; // Check file config.php existed if (!file_exists($currentThemeDir)) { continue; } $themeConfig = (include $currentThemeDir); if (isset($themeConfig['assets'])) { $assetWithThemeName = []; foreach ($themeConfig['assets'] as $k => $asset) { $asset['theme_name'] = $themDir; $assetWithThemeName[$k] = $asset; } $this->assets = array_merge($this->assets, $assetWithThemeName); } } } } } } return $this->assets; }
/** * Get a module path. * * @return string * @static */ public static function getPath() { return \Pingpong\Modules\Repository::getPath(); }