. * * 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\Binding; use Espo\Core\Utils\Module; use Espo\Binding; class EspoBindingLoader implements BindingLoader { /** @var string[] */ private array $moduleNameList; public function __construct( Module $module, private ?BindingProcessor $binding = null, ) { $this->moduleNameList = $module->getOrderedList(); } public function load(): BindingData { $data = new BindingData(); $binder = new Binder($data); (new Binding())->process($binder); foreach ($this->moduleNameList as $moduleName) { $this->loadModule($binder, $moduleName); } $this->loadCustom($binder); $this->binding?->process($binder); return $data; } private function loadModule(Binder $binder, string $moduleName): void { $className = 'Espo\\Modules\\' . $moduleName . '\\Binding'; if (!class_exists($className)) { return; } /** @var class-string $className */ (new $className())->process($binder); } private function loadCustom(Binder $binder): void { /** @var class-string|string $className */ $className = 'Espo\\Custom\\Binding'; if (!class_exists($className)) { return; } /** @var class-string $className */ (new $className())->process($binder); } }