Skip to content
This repository has been archived by the owner on Jun 14, 2023. It is now read-only.

[2.5] PropertyAccess api changed #106

Closed
rvanlaak opened this issue Jun 4, 2014 · 2 comments
Closed

[2.5] PropertyAccess api changed #106

rvanlaak opened this issue Jun 4, 2014 · 2 comments

Comments

@rvanlaak
Copy link
Contributor

rvanlaak commented Jun 4, 2014

On June 1 a new mayor version of Symfony was released. The way how PropertyAccess works was changed.
https://github.com/symfony/symfony/blob/master/CHANGELOG-2.5.md

This upgrade for me resulted in errors on filters with a custom apply_filter. The error occurs when the filterform was submitted.

Neither the property "activePowerup" nor one of the methods 
"addActivePowerup()"/"removeActivePowerup()", "setActivePowerup()", "activePowerup()", 
"__set()" or "__call()" exist and have public access in class 
"Acme\DemoBundle\Entity\User\Editor".

It seems like the bundle still tries to set/get the specific property of that entity, which it didn't do that before. The documentation states the following about ignoring getter/setter:

If you wish the field to be ignored when reading or writing to the object you can set the 
property_path option to false, but using property_path for this purpose is deprecated, you
should use the mapped option.

http://symfony.com/doc/current/reference/forms/types/form.html

Setting mapped => false in my FilterType solved this for me.

@cedric-g
Copy link
Collaborator

Hi, I did not get this kind of error but I supposed its because of I don't use any data class on my filter types. But the error you get make me think to this issue #95. Does the activePowerup field is a relation ?

@rvanlaak
Copy link
Contributor Author

My activePowerup field is of the type filter_boolean with a custom apply_filter method:

->add('activePowerup', 'filter_boolean', array(
    'apply_filter' => function (ORMQuery $filterBuilder, $field, $values) {

        if (!empty($values['value']) && $values['value'] == BooleanFilterType::VALUE_YES) {
            $filterBuilder->getQueryBuilder()->leftJoin('e.powerups', 'p');
                $filterBuilder->getQueryBuilder()->andWhere('p.dateFinished > CURRENT_TIMESTAMP()');
        }
    },
    'mapped' => false, // Mapping this field to the entity will result in an error
))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants