. * * 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\FieldProcessing; use Espo\Core\InjectableFactory; use Espo\ORM\Defs; use Espo\ORM\Entity; use RuntimeException; /** * @since 9.1.0 * @internal Yet experimental. */ class SpecificFieldLoader { public function __construct( private Defs $defs, private InjectableFactory $injectableFactory, ) {} public function process(Entity $entity, string $field): void { /** @var ?class-string> $loaderClassName */ $loaderClassName = $this->defs ->getEntity($entity->getEntityType()) ->tryGetField($field) ?->getParam('loaderClassName'); if (!$loaderClassName) { return; } $loader = $this->injectableFactory->create($loaderClassName); if (!$loader instanceof Loader) { throw new RuntimeException("Bad field loader."); } $loader->process($entity, Loader\Params::create()); } }