tfa = $tfa; $this->session = $session; if (!isset($data['provider'])) { throw new \InvalidArgumentException('A provider must be specified'); } } /** * @inheritdoc */ public function getJsLayout() { $providers = []; foreach ($this->getProvidersList() as $provider) { $providers[] = [ 'code' => $provider->getCode(), 'name' => $provider->getName(), 'auth' => $this->getUrl($provider->getAuthAction()), 'icon' => $this->getViewFileUrl($provider->getIcon()), ]; } $this->jsLayout['components']['msp-twofactorauth-change-provider']['switchIcon'] = $this->getViewFileUrl('MSP_TwoFactorAuth::images/change_provider.png'); $this->jsLayout['components']['msp-twofactorauth-change-provider']['providers'] = $providers; return parent::getJsLayout(); } /** * Get user * @return User|null */ private function getUser() { return $this->session->getUser(); } /** * Get a list of available providers * @return ProviderInterface[] */ private function getProvidersList() { $res = []; $providers = $this->tfa->getUserProviders($this->getUser()->getId()); foreach ($providers as $provider) { if ($provider->getCode() != $this->getData('provider')) { $res[] = $provider; } } return $res; } }