Commit 8f3dbdb6 authored by gvso's avatar gvso

Remove unused form abstract class

parent b96c974b
<?php
/**
* @file
* Contains \Drupal\social_api\Form\NetworkFormBase.
*/
namespace Drupal\social_api\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Form\ConfigFormBase;
use Drupal\Core\Utility\Error;
use Drupal\social_api\Plugin\NetworkInterface;
use Drupal\social_api\SocialApiException;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class NetworkFormBase.
*
* @package Drupal\social_api\Form
*/
abstract class NetworkFormBase extends ConfigFormBase {
/**
* The network plugin.
*
* @var NetworkInterface
*/
protected $network;
/**
* Constructs a \Drupal\system\ConfigFormBase object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
*
* @param NetworkInterface $network
*/
public function __construct(ConfigFactoryInterface $config_factory, NetworkInterface $network = NULL) {
parent::__construct($config_factory);
$this->network = $network;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$network = NULL;
try {
$network = $container->get('plugin.network.manager')
->createInstance(static::getNetworkMachineName());
}
catch (SocialApiException $exception) {
$message = '%type: @message in %function (line %line of %file).';
$variables = Error::decodeException($exception);
$container
->get('logger.factory')
->get('social_autopost')
->log('warning', $message, $variables);
}
return new static($container->get('config.factory'), $network);
}
/**
* Get the machine name of the network implementing the form.
*
* @return string
* The plugin ID.
*
* @throws SocialApiException
* When the method is not implemented.
*/
protected static function getNetworkMachineName() {
throw new SocialApiException('This method needs to be implemented.');
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment