Zend Framework  3.0
Public Member Functions | Protected Attributes | List of all members
ClassMethods Class Reference

Public Member Functions

 __construct ($underscoreSeparatedKeys=true)
 Define if extract values will use camel case or name with underscore.
 
 setOptions ($options)
 
 setUnderscoreSeparatedKeys ($underscoreSeparatedKeys)
 
 getUnderscoreSeparatedKeys ()
 
 extract ($object)
 Extract values from an object with class methods.
 
 hydrate (array $data, $object)
 Hydrate an object by populating getter/setter methods.
 
 addFilter ($name, $filter, $condition=Filter\FilterComposite::CONDITION_OR)
 Add a new filter to take care of what needs to be hydrated.To exclude e.g. the method getServiceLocator: $composite->addFilter( "servicelocator", function ($property) { list($class, $method) = explode('::', $property); if ($method === 'getServiceLocator') { return false; } return true; }, FilterComposite::CONDITION_AND );
Parameters
string$nameIndex in the composite
callable | Filter\FilterInterface$filter
int$condition
Returns
Filter

 
 removeFilter ($name)
 Remove a filter from the composition.To not extract "has" methods, you simply need to unregister it $filterComposite->removeFilter('has');
Parameters
$name
Returns
Filter

 
 setNamingStrategy (NamingStrategy\NamingStrategyInterface $strategy)
 Adds the given naming strategy.
Parameters
NamingStrategy\NamingStrategyInterface$strategyThe naming to register.
Returns
self

 
 removeNamingStrategy ()
 Removes the naming with the given name.
Returns
self

 
- Public Member Functions inherited from AbstractHydrator
 __construct ()
 Initializes a new instance of this class.
 
 getStrategy ($name)
 Gets the strategy with the given name.
 
 hasStrategy ($name)
 Checks if the strategy with the given name exists.
 
 addStrategy ($name, Strategy\StrategyInterface $strategy)
 Adds the given strategy under the given name.
 
 removeStrategy ($name)
 Removes the strategy with the given name.
 
 extractValue ($name, $value, $object=null)
 Converts a value for extraction.
 
 hydrateValue ($name, $value, $data=null)
 Converts a value for hydration.
 
 extractName ($name, $object=null)
 Convert a name for extraction.
 
 hydrateName ($name, $data=null)
 Converts a value for hydration.
 
 getFilter ()
 Get the filter instance.
 
 addFilter ($name, $filter, $condition=Filter\FilterComposite::CONDITION_OR)
 Add a new filter to take care of what needs to be hydrated.
 
 hasFilter ($name)
 Check whether a specific filter exists at key $name or not.
 
 removeFilter ($name)
 Remove a filter from the composition.
 
 setNamingStrategy (NamingStrategy\NamingStrategyInterface $strategy)
 Adds the given naming strategy.
 
 getNamingStrategy ()
 Gets the naming strategy.
 
 hasNamingStrategy ()
 Checks if a naming strategy exists.
 
 removeNamingStrategy ()
 Removes the naming strategy.
 

Protected Attributes

 $underscoreSeparatedKeys = true
 
- Protected Attributes inherited from AbstractHydrator
 $strategies
 
 $namingStrategy
 
 $filterComposite
 

Constructor & Destructor Documentation

__construct (   $underscoreSeparatedKeys = true)

Define if extract values will use camel case or name with underscore.

Parameters
bool | array$underscoreSeparatedKeys

Member Function Documentation

addFilter (   $name,
  $filter,
  $condition = Filter\FilterComposite::CONDITION_OR 
)

Add a new filter to take care of what needs to be hydrated.To exclude e.g. the method getServiceLocator: $composite->addFilter( "servicelocator", function ($property) { list($class, $method) = explode('::', $property); if ($method === 'getServiceLocator') { return false; } return true; }, FilterComposite::CONDITION_AND );

Parameters
string$nameIndex in the composite
callable | Filter\FilterInterface$filter
int$condition
Returns
Filter

Implements FilterEnabledInterface.

extract (   $object)

Extract values from an object with class methods.

Extracts the getter/setter of the given $object.

Parameters
object$object
Returns
array
Exceptions
Exception\BadMethodCallExceptionfor a non-object $object

Implements ExtractionInterface.

getUnderscoreSeparatedKeys ( )
Returns
bool
hydrate ( array  $data,
  $object 
)

Hydrate an object by populating getter/setter methods.

Hydrates an object by getter/setter methods of the object.

Parameters
array$data
object$object
Returns
object
Exceptions
Exception\BadMethodCallExceptionfor a non-object $object

Implements HydrationInterface.

removeFilter (   $name)

Remove a filter from the composition.To not extract "has" methods, you simply need to unregister it $filterComposite->removeFilter('has');

Parameters
$name
Returns
Filter

Implements FilterEnabledInterface.

removeNamingStrategy ( )

Removes the naming with the given name.

Returns
self

Implements NamingStrategyEnabledInterface.

setNamingStrategy ( NamingStrategy\NamingStrategyInterface  $strategy)

Adds the given naming strategy.

Parameters
NamingStrategy\NamingStrategyInterface$strategyThe naming to register.
Returns
self

Implements NamingStrategyEnabledInterface.

setOptions (   $options)
Parameters
array | Traversable$options
Returns
ClassMethods
Exceptions
Exception\InvalidArgumentException

Implements HydratorOptionsInterface.

setUnderscoreSeparatedKeys (   $underscoreSeparatedKeys)
Parameters
bool$underscoreSeparatedKeys
Returns
ClassMethods

Member Data Documentation

$underscoreSeparatedKeys = true
protected