Documentation

IdentityNamingStrategy — Zend Framework 2 2.4.9 documentation

Zend\Stdlib

IdentityNamingStrategy

Zend\Stdlib\Hydrator\NamingStrategy\IdentityNamingStrategy Will use the key it is given for hydration and extraction.

Basic Usage

1
2
3
4
 $namingStrategy = new Zend\Stdlib\Hydrator\NamingStrategy\IdentityNamingStrategy();

 echo $namingStrategy->hydrate('foo'); // outputs: foo
 echo $namingStrategy->extract('bar'); // outputs: bar

This strategy can be used in hydrators as well:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 class Foo
 {
     public $foo;
 }

 $namingStrategy = new Zend\Stdlib\Hydrator\NamingStrategy\IdentityNamingStrategy();
 $hydrator = new Zend\Stdlib\Hydrator\ObjectProperty();
 $hydrator->setNamingStrategy($namingStrategy);

 $foo = new Foo();
 $hydrator->hydrate(array('foo' => 123), $foo);

 print_r($foo); // Foo Object ( [foo] => 123 )
 print_r($hydrator->extract($foo)); // Array ( [foo] => 123 )

Copyright

© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts