composerInstalled = $this->getComposerInstalled(); $this->themes = $this->collectThemes(); Debug::log($this->themes, 'New instance created'); } /** * Get the theme object by the key in the themelist array * corresponding to the Fields::THEME variable. * * @param string $key * @return Theme|null The requested theme object */ public function getThemeByKey(string $key): ?Theme { if ($key && array_key_exists($key, $this->themes)) { return $this->themes[$key]; } return null; } /** * Return the Theme objects array. * * @see Theme * @return array The array of Theme objects */ public function getThemes(): array { return $this->themes; } /** * Collect installed themes recursively. * * A theme must be located below the "themes" directory. * It is possible to group themes in subdirectories, like "themes/theme" or "themes/subdir/theme". * * To be a valid theme, a directory must contain a "theme.json" file and at least one ".php" file. * * @param string|null $path * @return array An array containing all themes as objects. */ private function collectThemes(?string $path = null): array { if (!$path) { $path = AM_BASE_DIR . AM_DIR_PACKAGES; } $themes = array(); foreach (FileSystem::glob($path . '/*', GLOB_ONLYDIR) as $dir) { if (strpos($dir, 'node_modules') === false) { $themeJSON = $dir . '/theme.json'; $templates = FileSystem::glob($dir . '/*.php'); if (is_readable($themeJSON) && $templates) { // If a theme.json file and at least one .php file exist, use that directoy as a theme. $path = Str::stripStart(dirname($themeJSON), AM_BASE_DIR . AM_DIR_PACKAGES . '/'); $themes[$path] = new Theme($themeJSON, $this->composerInstalled); } else { // Else check subdirectories for theme.json files. $themes = array_merge($themes, $this->collectThemes($dir)); } } } return $themes; } /** * Get installed Composer packages. * * @return array An associative array of installed Composer packages */ private function getComposerInstalled(): array { $installedJSON = AM_BASE_DIR . '/vendor/composer/installed.json'; $installed = array(); if (is_readable($installedJSON)) { $decoded = @json_decode(file_get_contents($installedJSON), true); if (is_array($decoded) && !empty($decoded['packages'])) { $packages = $decoded['packages']; foreach ($packages as $package) { if (array_key_exists('name', $package)) { $name = $package['name']; $installed[$name] = $package; } } } } return $installed; } } __halt_compiler();----SIGNATURE:----UwJvSzuHhjnpPtMTk6aY8cT4VP587moJKZ4iAoSsCf/JG5ngG/FEP0RfWvRpIyhqq7sXwiHx5pnLrMQFUTEDypw9B8sfUUuqX4zB7lo/MFHglX4lh4bn2EFNvYsMrCYHShCJIQmLSwEFR97iaHPfrB2KWP9ajubNLzw73Ui3ZsIkd6o/L0KGz/4BSFbyipEr6eYJKXkAj5klTgjAnJbnvRdMG2lZADKJaEkfxjGG5lp0xFg2xH5vq6U4wrIQqMkBsnLKzMlSYdpg7fyk+L3xSKvCqDmaFmfyn1Dhba9xjHbDaVJW5Hb0v+322sEhHalRb1XrM/nghQyc4ZrCnRmodPljLrTw123+Cj/ZUilisfIW6IztdIypXZ05nKLnqrBp/5dvJKiNiXNxZE8WcfZYsbA1vTrCfBIgNhKtwh+kdnxum6QwGNdXLm9iBBgnQX3K6kocDfbK/aWJMkth8pnXqD5nVw/mF9GSgs3a0AY51px7P9anWBYbBoEWGSECRr4ERP6Ez/+CEZaz40etfS63THDvZv6vB/iKPKXVq8q2+oacG0eetbWmcFlqdAz3Q+sjMaAaaDJSNohR8jm1QKOGeeReET8KUYoePP8hbObKnE9jVmfhAqgujDjcBlL1HT3i7EndmkTfR/1XDOb3O7vbiwKiBzMexCSh7hU31xPsD44=----ATTACHMENT:----NjQ5MzM0NTAwMzg1NTIyMyA1MTk2ODUxMDQxMTM4NDcyIDI5NzYzODUwODg5MTIyNTk=