. * * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU Affero General Public License version 3. * * In accordance with Section 7(b) of the GNU Affero General Public License version 3, * these Appropriate Legal Notices must retain the display of the "EspoCRM" word. ************************************************************************/ namespace Espo\Core\Utils\Autoload; use Espo\Core\Utils\File\Manager as FileManager; class Loader { public function __construct( private NamespaceLoader $namespaceLoader, private FileManager $fileManager ) {} /** * * @param array{ * psr-4?: array, * psr-0?: array, * classmap?: array, * autoloadFileList?: array, * files?: array, * } $data */ public function register(array $data): void { /* load "psr-4", "psr-0", "classmap" */ $this->namespaceLoader->register($data); /* load "autoloadFileList" */ $this->registerAutoloadFileList($data); /* load "files" */ $this->registerFiles($data); } /** * @param array $data */ private function registerAutoloadFileList(array $data): void { $keyName = 'autoloadFileList'; if (!isset($data[$keyName])) { return; } foreach ($data[$keyName] as $filePath) { if ($this->fileManager->exists($filePath)) { require_once($filePath); } } } /** * @param array $data */ private function registerFiles(array $data): void { $keyName = 'files'; if (!isset($data[$keyName])) { return; } foreach ($data[$keyName] as $filePath) { if ($this->fileManager->exists($filePath)) { require_once($filePath); } } } }