Skip to content

Commit

Permalink
Remove boilerplate code from SocialAuthSettingsForm implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdubz committed Feb 7, 2019
1 parent 80baeaf commit 409251e
Showing 1 changed file with 2 additions and 44 deletions.
46 changes: 2 additions & 44 deletions src/Form/PbsAuthSettingsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,15 @@

namespace Drupal\social_auth_pbs\Form;

use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Path\PathValidatorInterface;
use Drupal\Core\Routing\RequestContext;
use Drupal\Core\Routing\RouteProviderInterface;
use Drupal\Core\Url;
use Drupal\social_auth\Form\SocialAuthSettingsForm;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Settings form for Social Auth PBS.
*/
class PbsAuthSettingsForm extends SocialAuthSettingsForm {

/**
* The request context.
*
* @var \Drupal\Core\Routing\RequestContext
*/
protected $requestContext;

/**
* Constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The configuration factory.
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* Used to check if route exists.
* @param \Drupal\Core\Path\PathValidatorInterface $path_validator
* Used to check if path is valid and exists.
* @param \Drupal\Core\Routing\RequestContext $request_context
* Holds information about the current request.
*/
public function __construct(ConfigFactoryInterface $config_factory, RouteProviderInterface $route_provider, PathValidatorInterface $path_validator, RequestContext $request_context) {
parent::__construct($config_factory, $route_provider, $path_validator);
$this->requestContext = $request_context;
}

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
// Instantiates this class.
return new static(
// Load the services required to construct this class.
$container->get('config.factory'),
$container->get('router.route_provider'),
$container->get('path.validator'),
$container->get('router.request_context')
);
}

/**
* {@inheritdoc}
*/
Expand Down Expand Up @@ -123,7 +81,7 @@ public function buildForm(array $form, FormStateInterface $form_state) {
'#type' => 'html_tag',
'#tag' => 'p',
'#value' => $this->t('<strong>Callback URL</strong><br/><code>@url</code>', [
'@url' => $GLOBALS['base_url'] . '/user/login/pbs/callback',
'@url' => Url::fromRoute('social_auth_pbs.callback')->setAbsolute()->toString(),
]),
];

Expand Down

0 comments on commit 409251e

Please sign in to comment.