Skip to content

Commit

Permalink
LabelOptionsAwareInterface => LabelAwareInterface
Browse files Browse the repository at this point in the history
this should not be a BC break because the interface is not included in
any release yet, change only affect develop branch
  • Loading branch information
Stefano Torresi committed Mar 5, 2014
1 parent 69f059f commit fdbbf24
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 16 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Form/Element.php
Expand Up @@ -17,7 +17,7 @@ class Element implements
ElementAttributeRemovalInterface,
ElementInterface,
InitializableInterface,
LabelOptionsAwareInterface
LabelAwareInterface
{
/**
* @var array
Expand Down
Expand Up @@ -9,8 +9,23 @@

namespace Zend\Form;

interface LabelOptionsAwareInterface
interface LabelAwareInterface
{
/**
* Set the label (if any) used for this element
*
* @param $label
* @return ElementInterface
*/
public function setLabel($label);

/**
* Retrieve the label (if any) used for this element
*
* @return string
*/
public function getLabel();

/**
* Set the attributes to use with the label
*
Expand Down
Expand Up @@ -9,7 +9,7 @@

namespace Zend\Form;

class LabelOptionsAwareTrait
class LabelAwareTrait
{
/**
* Label specific html attributes
Expand All @@ -29,7 +29,7 @@ class LabelOptionsAwareTrait
* Set the attributes to use with the label
*
* @param array $labelAttributes
* @return LabelOptionsAwareInterface
* @return LabelAwareInterface
*/
public function setLabelAttributes(array $labelAttributes)
{
Expand Down
4 changes: 2 additions & 2 deletions library/Zend/Form/View/Helper/FormButton.php
Expand Up @@ -11,7 +11,7 @@

use Zend\Form\ElementInterface;
use Zend\Form\Exception;
use Zend\Form\LabelOptionsAwareInterface;
use Zend\Form\LabelAwareInterface;

class FormButton extends FormInput
{
Expand Down Expand Up @@ -93,7 +93,7 @@ public function render(ElementInterface $element, $buttonContent = null)
}
}

if ($element instanceof LabelOptionsAwareInterface) {
if ($element instanceof LabelAwareInterface) {
if (! $element->getLabelOption('disable_html_escape')) {
$escapeHtmlHelper = $this->getEscapeHtmlHelper();
$buttonContent = $escapeHtmlHelper($buttonContent);
Expand Down
6 changes: 3 additions & 3 deletions library/Zend/Form/View/Helper/FormLabel.php
Expand Up @@ -11,7 +11,7 @@

use Zend\Form\ElementInterface;
use Zend\Form\Exception;
use Zend\Form\LabelOptionsAwareInterface;
use Zend\Form\LabelAwareInterface;

class FormLabel extends AbstractHelper
{
Expand Down Expand Up @@ -64,7 +64,7 @@ public function __invoke(ElementInterface $element = null, $labelContent = null,
);
}

if ($element instanceof LabelOptionsAwareInterface) {
if ($element instanceof LabelAwareInterface) {
if (! $element->getLabelOption('disable_html_escape')) {
$escapeHtmlHelper = $this->getEscapeHtmlHelper();
$label = $escapeHtmlHelper($label);
Expand Down Expand Up @@ -127,7 +127,7 @@ public function openTag($attributesOrElement = null)
}

$labelAttributes = array();
if ($attributesOrElement instanceof LabelOptionsAwareInterface) {
if ($attributesOrElement instanceof LabelAwareInterface) {
$labelAttributes = $attributesOrElement->getLabelAttributes();
}

Expand Down
6 changes: 3 additions & 3 deletions library/Zend/Form/View/Helper/FormMultiCheckbox.php
Expand Up @@ -12,7 +12,7 @@
use Zend\Form\ElementInterface;
use Zend\Form\Element\MultiCheckbox as MultiCheckboxElement;
use Zend\Form\Exception;
use Zend\Form\LabelOptionsAwareInterface;
use Zend\Form\LabelAwareInterface;

class FormMultiCheckbox extends FormInput
{
Expand Down Expand Up @@ -156,7 +156,7 @@ protected function renderOptions(MultiCheckboxElement $element, array $options,
$globalLabelAttributes = array();
$closingBracket = $this->getInlineClosingBracket();

if ($element instanceof LabelOptionsAwareInterface) {
if ($element instanceof LabelAwareInterface) {
$labelOptions = $element->getLabelOptions();
$globalLabelAttributes = $element->getLabelAttributes();
}
Expand Down Expand Up @@ -229,7 +229,7 @@ protected function renderOptions(MultiCheckboxElement $element, array $options,
);
}

if ($element instanceof LabelOptionsAwareInterface && !$element->getLabelOption('disable_html_escape')) {
if ($element instanceof LabelAwareInterface && !$element->getLabelOption('disable_html_escape')) {
$label = $escapeHtmlHelper($label);
}

Expand Down
8 changes: 4 additions & 4 deletions library/Zend/Form/View/Helper/FormRow.php
Expand Up @@ -12,7 +12,7 @@
use Zend\Form\Element\Button;
use Zend\Form\ElementInterface;
use Zend\Form\Exception;
use Zend\Form\LabelOptionsAwareInterface;
use Zend\Form\LabelAwareInterface;

class FormRow extends AbstractHelper
{
Expand Down Expand Up @@ -164,7 +164,7 @@ public function render(ElementInterface $element)
$labelOptions = array();
$labelAttributes = array();

if ($element instanceof LabelOptionsAwareInterface) {
if ($element instanceof LabelAwareInterface) {
$labelOptions = $element->getLabelOptions();
$labelAttributes = $element->getLabelAttributes();

Expand All @@ -189,7 +189,7 @@ public function render(ElementInterface $element)
// Ensure element and label will be separated if element has an `id`-attribute.
// If element has label option `always_wrap` it will be nested in any case.
if ($element->hasAttribute('id')
&& ($element instanceof LabelOptionsAwareInterface && !$element->getLabelOption('always_wrap'))
&& ($element instanceof LabelAwareInterface && !$element->getLabelOption('always_wrap'))
) {
$labelOpen = '';
$labelClose = '';
Expand All @@ -200,7 +200,7 @@ public function render(ElementInterface $element)
}

if ($label !== '' && (!$element->hasAttribute('id'))
|| ($element instanceof LabelOptionsAwareInterface && $element->getLabelOption('always_wrap'))
|| ($element instanceof LabelAwareInterface && $element->getLabelOption('always_wrap'))
) {
$label = '<span>' . $label . '</span>';
}
Expand Down

0 comments on commit fdbbf24

Please sign in to comment.