Skip to content

Commit

Permalink
minor #55 Clean up (sstok)
Browse files Browse the repository at this point in the history
This PR was merged into the 1.0-dev branch.

9b67df3 commit 1
  • Loading branch information
sstok authored Nov 5, 2016
2 parents fdfec72 + 9b67df3 commit d22220c
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 3 deletions.
76 changes: 76 additions & 0 deletions DataTransformerInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<?php

/*
* This file is part of the RollerworksSearch package.
*
* (c) Sebastiaan Stok <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Rollerworks\Component\Search;

use Rollerworks\Component\Search\Exception\TransformationFailedException;

/**
* Transforms a value between different representations.
*
* @author Sebastiaan Stok <[email protected]>
*/
interface DataTransformerInterface
{
/**
* Transforms a value from the original representation to a transformed representation.
*
* This method is called on two occasions:
*
* 1. When data from an input is submitted using to transform the new input data
* back into the renderable format. For example if you have a date field and submit '2009-10-10'
* you might accept this value because its easily parsed, but the transformer still writes back
* "2009/10/10" onto the display field (for further displaying or other purposes).
*
* This method must be able to deal with empty values. Usually this will
* be NULL, but depending on your implementation other empty values are
* possible as well (such as empty strings). The reasoning behind this is
* that value transformers must be chainable. If the transform() method
* of the first value transformer outputs NULL, the second value transformer
* must be able to process that value.
*
* By convention, transform() should return an empty string if NULL is
* passed.
*
* @param mixed $value The value in the original representation
*
* @throws TransformationFailedException When the transformation fails.
*
* @return mixed The value in the transformed representation
*/
public function transform($value);

/**
* Transforms a value from the transformed representation to its original
* representation.
*
* This method is called to transform the requests tainted data
* into an acceptable format for your data processing layer.
*
* This method must be able to deal with empty values. Usually this will
* be an empty string, but depending on your implementation other empty
* values are possible as well (such as empty strings). The reasoning behind
* this is that value transformers must be chainable. If the
* reverseTransform() method of the first value transformer outputs an
* empty string, the second value transformer must be able to process that
* value.
*
* By convention, reverseTransform() should return NULL if an empty string
* is passed.
*
* @param mixed $value The value in the transformed representation
*
* @throws TransformationFailedException When the transformation fails.
*
* @return mixed The value in the original representation
*/
public function reverseTransform($value);
}
2 changes: 1 addition & 1 deletion FieldTypeExtensionInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ interface FieldTypeExtensionInterface
* @see FieldTypeInterface::buildType()
*
* @param FieldConfigInterface $builder The config builder
* @param array $options The options
* @param array $options The options
*/
public function buildType(FieldConfigInterface $builder, array $options);

Expand Down
2 changes: 1 addition & 1 deletion ResolvedFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,6 @@ protected function newField($name, array $options)
*/
protected function newFieldView(FieldConfigInterface $config)
{
return new SearchFieldView($config);
return new SearchFieldView($config);
}
}
2 changes: 1 addition & 1 deletion Searches.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* <code>
* use Rollerworks\Component\Search\Searches;
*
* $searchFactory = Searches::createSearchFactory();
* $searchFactory = Searches::cre ateSearchFactory();
*
* $fieldSet = $searchFactory->createFieldSetBuilder('fieldset-name')
* ->add('firstName', 'text')
Expand Down

0 comments on commit d22220c

Please sign in to comment.