3
0
Fork 0
mirror of https://github.com/farmOS/farmOS.git synced 2024-02-23 11:37:38 +01:00

Rename QuickFormManager to QuickFormPluginManager.

This commit is contained in:
Michael Stenta 2023-08-03 15:32:15 -04:00
parent 42fe4bc50e
commit 3f559e77e9
7 changed files with 44 additions and 44 deletions

View file

@ -1,4 +1,4 @@
services:
plugin.manager.quick_form:
class: Drupal\farm_quick\QuickFormManager
class: Drupal\farm_quick\QuickFormPluginManager
parent: default_plugin_manager

View file

@ -5,7 +5,7 @@ namespace Drupal\farm_quick\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\Core\Url;
use Drupal\farm_quick\QuickFormManager;
use Drupal\farm_quick\QuickFormPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -18,15 +18,15 @@ class QuickFormController extends ControllerBase {
/**
* The quick form manager.
*
* @var \Drupal\farm_quick\QuickFormManager
* @var \Drupal\farm_quick\QuickFormPluginManager
*/
protected $quickFormManager;
protected $quickFormPluginManager;
/**
* Quick form controller constructor.
*/
public function __construct(QuickFormManager $quick_form_manager) {
$this->quickFormManager = $quick_form_manager;
public function __construct(QuickFormPluginManager $quick_form_plugin_manager) {
$this->quickFormPluginManager = $quick_form_plugin_manager;
}
/**
@ -45,7 +45,7 @@ class QuickFormController extends ControllerBase {
* Returns a render array.
*/
public function index(): array {
$quick_forms = $this->quickFormManager->getDefinitions();
$quick_forms = $this->quickFormPluginManager->getDefinitions();
$items = [];
foreach ($quick_forms as $quick_form) {
$url = Url::fromRoute('farm.quick.' . $quick_form['id']);

View file

@ -6,7 +6,7 @@ use Drupal\Core\Form\BaseFormIdInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Session\AccountInterface;
use Drupal\farm_quick\QuickFormManager;
use Drupal\farm_quick\QuickFormPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -17,11 +17,11 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class QuickForm extends FormBase implements BaseFormIdInterface {
/**
* The quick form manager.
* The quick form plugin manager.
*
* @var \Drupal\farm_quick\QuickFormManager
* @var \Drupal\farm_quick\QuickFormPluginManager
*/
protected $quickFormManager;
protected $quickFormPluginManager;
/**
* The quick form ID.
@ -33,11 +33,11 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
/**
* Class constructor.
*
* @param \Drupal\farm_quick\QuickFormManager $quick_form_manager
* The quick form manager.
* @param \Drupal\farm_quick\QuickFormPluginManager $quick_form_plugin_manager
* The quick form plugin manager.
*/
public function __construct(QuickFormManager $quick_form_manager) {
$this->quickFormManager = $quick_form_manager;
public function __construct(QuickFormPluginManager $quick_form_plugin_manager) {
$this->quickFormPluginManager = $quick_form_plugin_manager;
}
/**
@ -63,7 +63,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
$form_id = $this->getBaseFormId();
$id = $this->getRouteMatch()->getParameter('id');
if (!is_null($id)) {
$form_id .= '_' . $this->quickFormManager->createInstance($id)->getFormId();
$form_id .= '_' . $this->quickFormPluginManager->createInstance($id)->getFormId();
}
return $form_id;
}
@ -78,7 +78,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
* Quick form title.
*/
public function getTitle(string $id) {
return $this->quickFormManager->createInstance($id)->getLabel();
return $this->quickFormPluginManager->createInstance($id)->getLabel();
}
/**
@ -93,7 +93,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
* The access result.
*/
public function access(AccountInterface $account, string $id) {
return $this->quickFormManager->createInstance($id)->access($account);
return $this->quickFormPluginManager->createInstance($id)->access($account);
}
/**
@ -105,7 +105,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
$this->quickFormId = $id;
// Load the quick form.
$quick_form = $this->quickFormManager->createInstance($id);
$quick_form = $this->quickFormPluginManager->createInstance($id);
$form = $quick_form->buildForm($form, $form_state);
// Add a submit button, if one wasn't provided.
@ -127,14 +127,14 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$this->quickFormManager->createInstance($this->quickFormId)->validateForm($form, $form_state);
$this->quickFormPluginManager->createInstance($this->quickFormId)->validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->quickFormManager->createInstance($this->quickFormId)->submitForm($form, $form_state);
$this->quickFormPluginManager->createInstance($this->quickFormId)->submitForm($form, $form_state);
}
}

View file

@ -4,7 +4,7 @@ namespace Drupal\farm_quick\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Drupal\farm_quick\QuickFormManager;
use Drupal\farm_quick\QuickFormPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -13,20 +13,20 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class QuickFormMenuLink extends DeriverBase implements ContainerDeriverInterface {
/**
* The quick form manager.
* The quick form plugin manager.
*
* @var \Drupal\farm_quick\QuickFormManager
* @var \Drupal\farm_quick\QuickFormPluginManager
*/
protected $quickFormManager;
protected $quickFormPluginManager;
/**
* FarmQuickMenuLink constructor.
*
* @param \Drupal\farm_quick\QuickFormManager $quick_form_manager
* The quick form manager.
* @param \Drupal\farm_quick\QuickFormPluginManager $quick_form_plugin_manager
* The quick form plugin manager.
*/
public function __construct(QuickFormManager $quick_form_manager) {
$this->quickFormManager = $quick_form_manager;
public function __construct(QuickFormPluginManager $quick_form_plugin_manager) {
$this->quickFormPluginManager = $quick_form_plugin_manager;
}
/**
@ -45,7 +45,7 @@ class QuickFormMenuLink extends DeriverBase implements ContainerDeriverInterface
$links = [];
// Load quick forms.
$quick_forms = $this->quickFormManager->getDefinitions();
$quick_forms = $this->quickFormPluginManager->getDefinitions();
// Add a top level menu parent.
if (!empty($quick_forms)) {

View file

@ -9,10 +9,10 @@ use Drupal\Core\Plugin\DefaultPluginManager;
/**
* Quick form manager class.
*/
class QuickFormManager extends DefaultPluginManager {
class QuickFormPluginManager extends DefaultPluginManager {
/**
* Constructs a QuickFormManager object.
* Constructs a QuickFormPluginManager object.
*
* @param \Traversable $namespaces
* An object that implements \Traversable which contains the root paths

View file

@ -4,7 +4,7 @@ namespace Drupal\farm_quick\Routing;
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
use Drupal\farm_quick\Form\QuickForm;
use Drupal\farm_quick\QuickFormManager;
use Drupal\farm_quick\QuickFormPluginManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
@ -17,9 +17,9 @@ class QuickFormRoutes implements ContainerInjectionInterface {
/**
* The quick form manager.
*
* @var \Drupal\farm_quick\QuickFormManager
* @var \Drupal\farm_quick\QuickFormPluginManager
*/
protected $quickFormManager;
protected $quickFormPluginManager;
/**
* Constructs a QuickFormRoutes object.
@ -27,8 +27,8 @@ class QuickFormRoutes implements ContainerInjectionInterface {
* @param \Drupal\farm_quick\QuickFormManager $quick_form_manager
* The quick form manager.
*/
public function __construct(QuickFormManager $quick_form_manager) {
$this->quickFormManager = $quick_form_manager;
public function __construct(QuickFormPluginManager $quick_form_plugin_manager) {
$this->quickFormPluginManager = $quick_form_plugin_manager;
}
/**
@ -48,7 +48,7 @@ class QuickFormRoutes implements ContainerInjectionInterface {
*/
public function routes(): RouteCollection {
$route_collection = new RouteCollection();
foreach ($this->quickFormManager->getDefinitions() as $id => $definition) {
foreach ($this->quickFormPluginManager->getDefinitions() as $id => $definition) {
$route = new Route(
"/quick/$id",
[

View file

@ -13,11 +13,11 @@ use Drupal\KernelTests\KernelTestBase;
class QuickFormTest extends KernelTestBase {
/**
* The quick form manager.
* The quick form plugin manager.
*
* @var \Drupal\farm_quick\QuickFormManager
* @var \Drupal\farm_quick\QuickFormPluginManager
*/
protected $quickFormManager;
protected $quickFormPluginManager;
/**
* {@inheritdoc}
@ -45,7 +45,7 @@ class QuickFormTest extends KernelTestBase {
*/
protected function setUp(): void {
parent::setUp();
$this->quickFormManager = \Drupal::service('plugin.manager.quick_form');
$this->quickFormPluginManager = \Drupal::service('plugin.manager.quick_form');
$this->installEntitySchema('asset');
$this->installEntitySchema('log');
$this->installEntitySchema('taxonomy_term');
@ -62,14 +62,14 @@ class QuickFormTest extends KernelTestBase {
public function testQuickFormDiscovery() {
// Load quick form definitions.
$quick_forms = $this->quickFormManager->getDefinitions();
$quick_forms = $this->quickFormPluginManager->getDefinitions();
// Confirm that one quick form was discovered.
$this->assertEquals(1, count($quick_forms));
// Initialize the test quick form.
/** @var \Drupal\farm_quick\Plugin\QuickForm\QuickFormInterface $test_quick_form */
$test_quick_form = $this->quickFormManager->createInstance('test');
$test_quick_form = $this->quickFormPluginManager->createInstance('test');
// Confirm the label, description, helpText, and permissions.
$this->assertEquals('Test quick form', $test_quick_form->getLabel());