Skip to content

Commit

Permalink
Make use if 'ignore´ instead of explicitly unsetting array keys
Browse files Browse the repository at this point in the history
refs #5525
  • Loading branch information
Johannes Meyer committed Aug 12, 2014
1 parent e6bcda2 commit fe63ce6
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 42 deletions.
3 changes: 2 additions & 1 deletion application/forms/Authentication/LoginForm.php
Expand Up @@ -57,7 +57,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Login')
'ignore' => true,
'label' => t('Login')
)
);
}
Expand Down
7 changes: 3 additions & 4 deletions application/forms/Config/Authentication/BaseBackendForm.php
Expand Up @@ -20,7 +20,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Save Changes')
'ignore' => true,
'label' => t('Save Changes')
)
);

Expand Down Expand Up @@ -75,9 +76,6 @@ public function getBackendConfig()
$values = $this->getValues();
$name = $values['name'];
unset($values['name']);
unset($values['btn_submit']);
unset($values['force_creation']);
unset($values[$this->getTokenElementName()]);
return array($name, $values);
}

Expand All @@ -104,6 +102,7 @@ protected function addForceCreationCheckbox()
'force_creation',
array(
'order' => 0,
'ignore' => true,
'label' => t('Force Changes'),
'helptext' => t('Check this box to enforce changes without connectivity validation')
)
Expand Down
3 changes: 2 additions & 1 deletion application/forms/Config/ConfirmRemovalForm.php
Expand Up @@ -28,7 +28,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Confirm Removal')
'ignore' => true,
'label' => t('Confirm Removal')
)
);
}
Expand Down
3 changes: 2 additions & 1 deletion application/forms/Config/GeneralForm.php
Expand Up @@ -46,7 +46,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Save Changes')
'ignore' => true,
'label' => t('Save Changes')
)
);

Expand Down
18 changes: 2 additions & 16 deletions application/forms/Config/LoggingForm.php
Expand Up @@ -134,28 +134,14 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Save')
'ignore' => true,
'label' => t('Save')
)
);

return $this;
}

/**
* Retrieve all form element values
*
* Returns all configuration relevant element values.
*
* @return array
*/
public function getValues()
{
$values = parent::getValues();
unset($values['btn_submit']);
unset($values[$this->getTokenElementName()]);
return $values;
}

/**
* Return the default logging directory for type "file"
*
Expand Down
7 changes: 3 additions & 4 deletions application/forms/Config/ResourceForm.php
Expand Up @@ -83,7 +83,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Save Changes')
'ignore' => true,
'label' => t('Save Changes')
)
);

Expand Down Expand Up @@ -197,9 +198,6 @@ public function getResourceConfig()
$values = $this->getValues();
$name = $values['name'];
unset($values['name']);
unset($values['btn_submit']);
unset($values['force_creation']);
unset($values[$this->getTokenElementName()]);
return array($name, $values);
}

Expand Down Expand Up @@ -228,6 +226,7 @@ protected function getForceCreationCheckbox()
'force_creation',
array(
'order' => 0,
'ignore' => true,
'label' => t('Force Changes'),
'helptext' => t('Check this box to enforce changes without connectivity validation')
)
Expand Down
13 changes: 8 additions & 5 deletions application/forms/Dashboard/AddUrlForm.php
Expand Up @@ -56,8 +56,9 @@ public function createElements(array $formData)
'submit',
'use_existing_dashboard',
array(
'label' => t('Use An Existing Pane'),
'style' => 'display: inline-block'
'ignore' => true,
'label' => t('Use An Existing Pane'),
'style' => 'display: inline-block'
)
);
}
Expand All @@ -76,8 +77,9 @@ public function createElements(array $formData)
'submit',
'create_new_pane',
array(
'label' => t('Create A New Pane'),
'style' => 'display: inline-block'
'ignore' => true,
'label' => t('Create A New Pane'),
'style' => 'display: inline-block'
)
);
}
Expand All @@ -103,7 +105,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Add To Dashboard')
'ignore' => true,
'label' => t('Add To Dashboard')
)
);

Expand Down
3 changes: 2 additions & 1 deletion application/forms/Preference/GeneralForm.php
Expand Up @@ -138,7 +138,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Save Changes')
'ignore' => true,
'label' => t('Save Changes')
)
);

Expand Down
3 changes: 2 additions & 1 deletion library/Icinga/Web/Form.php
Expand Up @@ -216,7 +216,8 @@ public function addCsrfToken()
'hidden',
$this->tokenElementName,
array(
'value' => $this->generateCsrfToken()
'ignore' => true,
'value' => $this->generateCsrfToken()
)
);
}
Expand Down
5 changes: 2 additions & 3 deletions modules/monitoring/application/forms/Config/BackendForm.php
Expand Up @@ -74,7 +74,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Save Changes')
'ignore' => true,
'label' => t('Save Changes')
)
);

Expand All @@ -98,8 +99,6 @@ public function getBackendConfig()
}

unset($values['name']);
unset($values['btn_submit']);
unset($values[$this->getTokenElementName()]);
return array($name, $values);
}

Expand Down
9 changes: 4 additions & 5 deletions modules/monitoring/application/forms/Config/InstanceForm.php
Expand Up @@ -33,6 +33,7 @@ public function createElements(array $formData)
'type',
array(
'required' => true,
'ignore' => true,
'label' => t('Instance Type'),
'class' => 'autosubmit',
'helptext' => t(
Expand Down Expand Up @@ -92,6 +93,7 @@ public function createElements(array $formData)
'hitchhiker',
array(
'required' => true,
'ignore' => true,
'value' => 'Arthur'
)
);
Expand Down Expand Up @@ -119,7 +121,8 @@ public function addSubmitButton()
'submit',
'btn_submit',
array(
'label' => t('Save Changes')
'ignore' => true,
'label' => t('Save Changes')
)
);

Expand All @@ -138,10 +141,6 @@ public function getInstanceConfig()
$values = $this->getValues();
$name = $values['name'];
unset($values['name']);
unset($values['type']);
unset($values['hitchhiker']);
unset($values['btn_submit']);
unset($values[$this->getTokenElementName()]);
return array($name, $values);
}

Expand Down

0 comments on commit fe63ce6

Please sign in to comment.