injectableFactory = $injectableFactory; $this->metadata = $metadata; } public function create(string $method, bool $isPortal = false) : Login { $className = $this->metadata->get(['authenticationMethods', $method, 'implementationClassName']); if (!$className) { $sanitizedName = preg_replace('/[^a-zA-Z0-9]+/', '', $method); $className = "Espo\\Custom\\Core\\Authentication\\Login\\" . $sanitizedName; if (!class_exists($className)) { $className = "Espo\\Core\\Authentication\\Login\\" . $sanitizedName; } } return $this->injectableFactory->createWith($className, [ 'isPortal' => $isPortal, ]); } }