Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Hydrator naming strategy zend filter dependency #6928

Closed
wants to merge 1 commit into from

Conversation

zspine
Copy link
Contributor

@zspine zspine commented Nov 26, 2014

Hydrator naming strategy not working without zend filter package (Anyway not sure how zf2 dependency works)

/**
 * Class UserHydrator
 *
 * @package AppAuth\Mapper
 */
class UserHydrator extends ClassMethods
{

    /**
     * @param object $object
     *
     * @return array
     * @throws Exception
     */
    public function extract($object)
    {
        if (!$object instanceof User) {
            throw new Exception('$object must be an instance of AppAuth\Entity\User');
        }

        $data = parent::extract($object);
        return $data;
    }

Error:
Class 'Zend\Filter\FilterChain' not found
/vendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php

 protected function getCamelCaseToUnderscoreFilter()
{
if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) {
return static::$camelCaseToUnderscoreFilter;
}
$filter = new FilterChain();
$filter->attachByName('WordCamelCaseToUnderscore');
$filter->attachByName('StringToLower');

Hydrator naming strategy not working without zend filter package (Anyway not sure how zf2 dependency works)

```php
/**
 * Class UserHydrator
 *
 * @Package PimAuth\Mapper
 */
class UserHydrator extends ClassMethods
{

    /**
     * @param object $object
     *
     * @return array
     * @throws Exception
     */
    public function extract($object)
    {
        if (!$object instanceof User) {
            throw new Exception('$object must be an instance of PimAuth\Entity\User');
        }

        $data = parent::extract($object);
        return $data;
    }
```

Error:
Class 'Zend\Filter\FilterChain' not found 
/vendor/zendframework/zend-stdlib/Zend/Stdlib/Hydrator/NamingStrategy/UnderscoreNamingStrategy.php

```php
 protected function getCamelCaseToUnderscoreFilter()
{
if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) {
return static::$camelCaseToUnderscoreFilter;
}
$filter = new FilterChain();
$filter->attachByName('WordCamelCaseToUnderscore');
$filter->attachByName('StringToLower');
```
@Ocramius Ocramius added this to the 2.3.4 milestone Nov 26, 2014
@Ocramius Ocramius self-assigned this Nov 26, 2014
@Ocramius
Copy link
Member

This is actually a SNAFU of the Zend\Stdlib component: the filter dependency should never have been in there in first place.

@Ocramius Ocramius closed this in af8a511 Nov 27, 2014
Ocramius added a commit that referenced this pull request Nov 27, 2014
@Ocramius
Copy link
Member

@zspine merged, thank you!

master: af8a511
develop: 8d1dab4

gianarb pushed a commit to zendframework/zend-stdlib that referenced this pull request May 15, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants