Skip to content

Commit

Permalink
[Form] Cleaned up ValueTransformerInterface
Browse files Browse the repository at this point in the history
This commit removes CollectionToStringTransformer. Transformers should never change the state of the outside world, otherwise hard-to-track bugs might creap in.

This functionality needs to be implemented as a custom FieldType (see EntityChoiceField).
  • Loading branch information
Bernhard Schussek authored and fabpot committed Feb 6, 2011
1 parent bd3e6c6 commit 74d0ac8
Show file tree
Hide file tree
Showing 13 changed files with 13 additions and 395 deletions.
Expand Up @@ -47,7 +47,7 @@ public function transform($value)
* @param string $value String value.
* @return Boolean Boolean value.
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string');
Expand Down

This file was deleted.

Expand Up @@ -95,7 +95,7 @@ public function transform($dateTime)
* @param array $value Localized date string/array
* @return DateTime Normalized date
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
if (null === $value) {
return null;
Expand Down
Expand Up @@ -86,7 +86,7 @@ public function transform($dateTime)
* @param string|array $value Localized date string/array
* @return DateTime Normalized date
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
$inputTimezone = $this->getOption('input_timezone');

Expand Down
Expand Up @@ -62,7 +62,7 @@ public function transform($value)
* @param string $value A value as produced by PHP's date() function
* @return DateTime A DateTime object
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
if (empty($value)) {
return null;
Expand Down
Expand Up @@ -60,7 +60,7 @@ public function transform($value)
* @param string $value A value as produced by PHP's date() function
* @return DateTime A DateTime object
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
if (null === $value) {
return null;
Expand Down
Expand Up @@ -58,9 +58,9 @@ public function transform($value)
* @param string $value Localized money string
* @return number Normalized number
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
$value = parent::reverseTransform($value, $originalValue);
$value = parent::reverseTransform($value);

if (null !== $value) {
$value *= $this->getOption('divisor');
Expand Down
Expand Up @@ -74,7 +74,7 @@ public function transform($value)
*
* @param string $value
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string');
Expand Down
Expand Up @@ -82,7 +82,7 @@ public function transform($value)
* @param number $value Percentage value.
* @return number Normalized value.
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
if (!is_string($value)) {
throw new UnexpectedTypeException($value, 'string');
Expand Down
Expand Up @@ -48,7 +48,7 @@ public function transform($value)
/**
* {@inheritDoc}
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
return $this->reversedTransformer->transform($value);
}
Expand Down
Expand Up @@ -66,10 +66,10 @@ public function transform($value)
* @param mixed $value The transformed value
* @return mixed The reverse-transformed value
*/
public function reverseTransform($value, $originalValue)
public function reverseTransform($value)
{
for ($i = count($this->transformers) - 1; $i >= 0; --$i) {
$value = $this->transformers[$i]->reverseTransform($value, $originalValue);
$value = $this->transformers[$i]->reverseTransform($value);
}

return $value;
Expand Down
Expand Up @@ -65,11 +65,9 @@ function transform($value);
* is passed.
*
* @param mixed $value The value in the transformed representation
* @param mixed $originalValue The original value from the datasource that is about to be overwritten by the new value.
* @return mixed The value in the original representation
* @throws UnexpectedTypeException when the argument is not of the
* expected type
* @throws ValueTransformerException when the transformation fails
*/
function reverseTransform($value, $originalValue);
function reverseTransform($value);
}

0 comments on commit 74d0ac8

Please sign in to comment.