/** * Load all of the plugins. * * @param array $config */ protected function loadPlugins(array $config) { $plugins = isset($config['plugins']) ? $config['plugins'] : []; foreach ($plugins as $plugin => $config) { $plugin .= '\\Plugin'; if (class_exists($plugin, true)) { $pluginObj = new $plugin($this->pluginManager, $config); $this->pluginManager->registerPlugin($plugin, $pluginObj); } } }
/** * @param string $provider * @param Request $request * @return bool|\Martha\Core\Domain\Entity\User */ public function authenticateWithOAuthProvider($provider, Request $request) { $provider = $this->pluginManager->getAuthenticationProvider($provider); if ($provider) { if (($authResult = $provider->validateResult($request)) !== false) { $user = $this->userRepository->getByEmail($authResult->getEmails()); if (!$user) { $user = (new UserFactory())->createFromAuthenticationResult($authResult); $this->system->getEventManager()->trigger('user.created', $user, $provider); $this->userRepository->persist($user)->flush(); } else { $updater = new UserUpdaterService(); $updater->updateUserFromAuthenticationResult($user, $authResult); $this->userRepository->flush(); } return $user; } } return false; }