Git Product home page Git Product logo

Comments (12)

willdurand avatar willdurand commented on July 29, 2024

you should be able to use the service() function in an expression. So I guess this expression should work:

@Hateoas\Exclusion(excludeIf = "expr(service('security.context').isGranted([ ROLE_SOMETHING ]))")

from bazingahateoasbundle.

qooplmao avatar qooplmao commented on July 29, 2024

Well then I feel like an idiot. Sorry man.

from bazingahateoasbundle.

willdurand avatar willdurand commented on July 29, 2024

@qooplmao I reopen the issue. Let me know if it works first.

from bazingahateoasbundle.

adrienbrault avatar adrienbrault commented on July 29, 2024

Wow, never thought of that ... that's pretty awesome 👍

from bazingahateoasbundle.

qooplmao avatar qooplmao commented on July 29, 2024

Sorry for the delay.. Christmas and that.

It seems I can't get it to work but I'm assuming it's with how I am setting it up/using it.

If I use $hateoas = HateoasBuilder::create()..->build() and $hateoas->serialize() then I get 'The function "service" does not exist around position 1.'
If I use $this->container->get('serializer')->serialize() then I get "Undefined index: container in ../Symfony/Component/DependencyInjection/ExpressionLanguage.php line 33"

Also data in the PagerfantaFactory comes out as _embedded rather than as a collection but that's another issue.

from bazingahateoasbundle.

willdurand avatar willdurand commented on July 29, 2024

You should use: $this->container->get('serializer')->serialize(), but the issue comes from symfony itself obviously... /cc @fabpot

from bazingahateoasbundle.

willdurand avatar willdurand commented on July 29, 2024

let me setup a test case.

from bazingahateoasbundle.

qooplmao avatar qooplmao commented on July 29, 2024

I was thinking that (usage wise).

Will be interested to see any results from a test case.

from bazingahateoasbundle.

willdurand avatar willdurand commented on July 29, 2024

Oh. I know. Which Symfony version are you using? I am pretty sure it does not work with Symfony < 2.4... because of the ContainerBuilder.

from bazingahateoasbundle.

willdurand avatar willdurand commented on July 29, 2024

Well no, unfortunately it works fine. See:

from bazingahateoasbundle.

qooplmao avatar qooplmao commented on July 29, 2024

Managed to get it to work as expected.
I was using version 0.1.1 which gave the issues above with Symfony 2.4.
Updated to dev-master and it is working a treat, also downgraded to 2.3 for LTS and it's still good.
I feel I probably should have realised this earlier.

Thanks a lot for looking at it.

from bazingahateoasbundle.

willdurand avatar willdurand commented on July 29, 2024

cool, I just tagged 0.2.0.

from bazingahateoasbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.