Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Property group exclusion for embedded resource(s) is not working #245

Open
jkobus opened this issue Feb 2, 2017 · 3 comments
Open

Property group exclusion for embedded resource(s) is not working #245

jkobus opened this issue Feb 2, 2017 · 3 comments

Comments

@jkobus
Copy link

jkobus commented Feb 2, 2017

Expected behaviour:

  • Block is embedded within the Section,
  • exclusion policy defined in Section should not allow Block's "title" property to render.

Actual:

  • embedded Block still has its "title" present.

Code:

use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation as Serializer;

/**
 * @Serializer\ExclusionPolicy("all")
 * @Hateoas\Relation("block",
 *     embedded = @Hateoas\Embedded(
 *      "expr(object.getBlock())",
 *      exclusion = @Hateoas\Exclusion(groups="extended" )
 *     )
 * )
 */
class Section
{
    public function getBlock(){...}
use Hateoas\Configuration\Annotation as Hateoas;
use JMS\Serializer\Annotation as Serializer;

/**
 * @Serializer\ExclusionPolicy("all")
 */
class Block
{
    /**
     * @Serializer\Groups({"extended"})
     * @Serializer\Expose
     * @var string
     */
    private $title;

   ...
}

Am I doing something wrong?

I noticed, that the JmsSerializer is not aware of any exclusion strategy for that property so it simply skips the rest of the checks.

refs #154 #141

@zdhz
Copy link

zdhz commented Mar 14, 2017

@jkobus Did you find a solution to this?

@jkobus
Copy link
Author

jkobus commented Mar 14, 2017

No, not yet. Didn't have time to investigate further.

@kptLucek
Copy link

Okay i know that this issue is kinda old but...

I have very similar case, however for me annotations are working but yml mappings are not, to be more precise - exclude, expose, exclusion_policy provided by JMS are not being parsed, but (for example) virtual_properties are working fine.

If i'll use annotation like @jkobus mentioned, everything is working just fine, however i do use yml mapping mostly because of extending vendor models

I do use:

Package version
willdurand/hateoas 3.6.0
willdurand/hateoas-bundle 2.1.0
jms/serializer 3.9.0
jms/serializer-bundle 3.7.0
symfony/* 5.1.5

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

No branches or pull requests

3 participants