Rename createInstance to getInstance for consistency with getInstances function

This commit is contained in:
Paul Weidner 2023-08-11 09:01:25 -07:00 committed by Michael Stenta
parent 4fcc647115
commit 7506862308
5 changed files with 11 additions and 11 deletions

View File

@ -21,7 +21,7 @@ function farm_quick_help($route_name, RouteMatchInterface $route_match) {
// Load help text for individual quick forms.
if ($route_name == 'farm_quick.quick_form') {
if (($quick_form_id = $route_match->getParameter('quick_form')) && $quick_form = \Drupal::service('quick_form.instance_manager')->createInstance($quick_form_id)) {
if (($quick_form_id = $route_match->getParameter('quick_form')) && $quick_form = \Drupal::service('quick_form.instance_manager')->getInstance($quick_form_id)) {
if ($help_text = $quick_form->getHelpText()) {
$output .= '<p>' . $help_text . '</p>';
}

View File

@ -153,7 +153,7 @@ class ConfigureQuickForm extends EntityForm {
* The quick form instance or NULL if does not exist.
*/
protected function getQuickFormInstance(string $quick_form_id) {
return $this->quickFormInstanceManager->createInstance($quick_form_id);
return $this->quickFormInstanceManager->getInstance($quick_form_id);
}
}

View File

@ -64,7 +64,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
$form_id = $this->getBaseFormId();
$id = $this->getRouteMatch()->getParameter('quick_form');
if (!is_null($id)) {
$form_id .= '_' . $this->quickFormInstanceManager->createInstance($id)->getPlugin()->getFormId();
$form_id .= '_' . $this->quickFormInstanceManager->getInstance($id)->getPlugin()->getFormId();
}
return $form_id;
}
@ -79,7 +79,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
* Quick form title.
*/
public function getTitle(string $quick_form) {
return $this->quickFormInstanceManager->createInstance($quick_form)->getLabel();
return $this->quickFormInstanceManager->getInstance($quick_form)->getLabel();
}
/**
@ -94,7 +94,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
* The access result.
*/
public function access(AccountInterface $account, string $quick_form) {
if ($quick_form = $this->quickFormInstanceManager->createInstance($quick_form)) {
if ($quick_form = $this->quickFormInstanceManager->getInstance($quick_form)) {
return $quick_form->getPlugin()->access($account);
}
@ -111,7 +111,7 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
$this->quickFormId = $quick_form;
// Load the quick form.
$form = $this->quickFormInstanceManager->createInstance($quick_form)->getPlugin()->buildForm($form, $form_state);
$form = $this->quickFormInstanceManager->getInstance($quick_form)->getPlugin()->buildForm($form, $form_state);
// Add a submit button, if one wasn't provided.
if (empty($form['actions']['submit'])) {
@ -132,14 +132,14 @@ class QuickForm extends FormBase implements BaseFormIdInterface {
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
$this->quickFormInstanceManager->createInstance($this->quickFormId)->getPlugin()->validateForm($form, $form_state);
$this->quickFormInstanceManager->getInstance($this->quickFormId)->getPlugin()->validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->quickFormInstanceManager->createInstance($this->quickFormId)->getPlugin()->submitForm($form, $form_state);
$this->quickFormInstanceManager->getInstance($this->quickFormId)->getPlugin()->submitForm($form, $form_state);
}
}

View File

@ -78,7 +78,7 @@ class QuickFormInstanceManager implements QuickFormInstanceManagerInterface {
/**
* {@inheritdoc}
*/
public function createInstance($id) {
public function getInstance($id) {
// First attempt to load a quick form instance config entity.
$entity = $this->entityTypeManager->getStorage('quick_form')->load($id);

View File

@ -16,7 +16,7 @@ interface QuickFormInstanceManagerInterface {
public function getInstances();
/**
* Create an instance of a quick form.
* Get an instance of a quick form.
*
* @param string $id
* The quick form ID.
@ -24,6 +24,6 @@ interface QuickFormInstanceManagerInterface {
* @return \Drupal\farm_quick\Entity\QuickFormInstanceInterface|null
* Returns an instantiated quick form object.
*/
public function createInstance($id);
public function getInstance($id);
}