GithubHelp home page GithubHelp logo

thefootballsocialclub / fschateoasbundle Goto Github PK

View Code? Open in Web Editor NEW
94.0 94.0 26.0 1.06 MB

Please use https://github.com/willdurand/hateoas and https://github.com/willdurand/BazingaHateoasBundle instead.

PHP 100.00%

fschateoasbundle's People

Contributors

adrienbrault avatar ajgarlag avatar amine2z avatar baldurrensch avatar benja-m-1 avatar lsmith77 avatar marapper avatar ninir avatar ruudk avatar sprain avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fschateoasbundle's Issues

Simplify yaml/json representations of links

At the moment, the links in json look like:

{
    "links": {
        "self": {
            "rel": "self",
            "href": "xxx"
        }
    }
}

but it should look like this (to reduce size, and simplify usage)

{
    "links": {
        "self": "xxx"
    }
}

Use the Metadata stack that the serializer provides

The serializer beginning with 0.12 supports a metadata stack. We can use this to delay creating links, and embedding objects, since we can only do that once.

A (failing) testcase is the following controller test:

public function testListPostsJson()
{
        $client = $this->createClient();
        $client->request('GET', '/api/posts?_format=json');

        $response = $client->getResponse(); /** @var $response Response */

        $this->assertEquals(200, $response->getStatusCode());
}

Running this results in

JMS\Serializer\Exception\InvalidArgumentException: There is already data for "links".

This is only a problem for JSON, not XML, but will ultimately allow us to inline the HalPagerfanta inside another model that can contain additional properties, links, and embedded resources.

Ignore link if parameter is not null

I have the following schema:

Path\To\My\Foo
    relations:
        - rel: self
          href:
              route: get_foo
              parameters:
                  id: .id
        - rel: bar
          href:
              route: get_bar
              parameters:
                  id: .bar.id

Basically, bar is not required and may be null, therefore generating the route would throw an exception.

Is there a way to only generate the bar link if the foo has resource bar only? And ignore if it it does not?

[RFC] Non required links

Hey,

I see that many people are interested in non required relation.
An example would be a User that could have a manager, but not always.

The current PR try catch the parameters creation or the url generation. I dot not like this as this could hide an error (configuration, runtime, whatever).

What I propose:

@Relation("manager", @Route("user_get", parameters = {"id" = "manager.id"}), required_parameters = {"manager"})

Without the new required_parameters option, the behavior would stay the same.
required_parameters would accept an array of propertyPaths. If one of the propertyPath is null or false, then the relation link would not be created.

WDYT ?

Allow iterating over a collection to generate links

We should be able to generate links off of collections, so you would specify a parameter to create a link for each element in that array.

For example, you have an array of authors, and you want to generate a link for each author

/**
 * @Rest\Relation("self",      
 *   href = @Rest\Route("author", collection_parameters = { "id" = ".author[].id" }))
 */

Add annotation driver

Many people will wonder why the example uses annotations for the serializer metadata, and yaml for the hateoas metadata.
In addition to this, annotations will let people define serializer and hateoas metadata in the same file.

make it possible to set the url from a model

Right now its only possible to define the url by hardcoding it in the annotation. However in some cases the URL needs to be fetched dynamically from the model.

/**
* @Rest\Relation("foo", href = ".someUrl")
*/

PagerfantaHandler should trigger onPreSerialize

JMSSerializerBundle has a DoctrineProxySubscriber which loads Doctrine Proxies before serializing them.

When I serialize a Pagerfanta object with, for example, 2 users. One user is a Proxy and 1 user is loaded completely. I've set @XmlRoot("user"). When I serialize the Pagerfanta object to XML one user has a <entry> root and one has a <user> root.

How can this be fixed? Should the PagerfantaHandler trigger some kind of event?

Form value should be in CDATA section

XmlFormViewSerializer Do not serialize value with CDATA section. Which can create some issues is the value contains some xml tag.

What I did:

    /*
        <textarea {{ block('widget_attributes') }}>{{ value }}</textarea>
    */
    protected function serializeTextareaWidget(\DOMElement $parentElement, FormView $view, $variables)
    {
        $textareaElement = $parentElement->ownerDocument->createElement('textarea');
        $textareaElement->appendChild($parentElement->ownerDocument->createCDATASection($variables['value']));
        $parentElement->appendChild($textareaElement);

        $this->addWidgetAttributes($textareaElement, $view, $variables);
    }

Do you want a PR ? Should i CDATAize all the field ?

Tag and release

Thank you for your bundle! Would it be possible to tag and release a version?
This will make using the library via composer easier.

To fix this the following would need to be done:

  • Tagging the library (for instance with v0.5.0)
  • Drafting a release on GitHub
  • Updating Packagist (if not done automatically)

Thank you in advance!

[Enhancement] Implement handling KnpPagination and Doctrine Paginator

I would like to know if there is any special reason why this bundle is bound to Pagerfanta? As far as I saw from a quick look into the RelationsManager, only the current and max page are needed from the paginator and it shouldnt be that hard to get broader support into the bundle. The only catch would be the existing type-hinting and BC if I'm not overseeing something.

I'm interested in getting support for, at least, KnpPaginator into the bundle because I'm using it all over the place and love the sorting- and filtering-capabilities.

Another candidate for implementation would be the new Doctrine Paginator.

Can't install FSCHateoasBundle, conflict with JMS/metadata

I'm getting this error when running composer update

Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for fsc/hateoas-bundle 0.4.x-dev -> satisfiable by fsc/hateoas-bundle 0.4.x
    - Conclusion: remove jms/metadata dev-master
    - fsc/hateoas-bundle 0.4.x-dev requires jms/metadata >=1.1.0,<1.3-dev -> satisfiable by jms/metada
data 1.2.0-RC.
    - Can only install one of: jms/metadata dev-master, jms/metadata 1.1.1.
    - Can only install one of: jms/metadata dev-master, jms/metadata 1.2.0-RC.
    - Installation request for jms/metadata == 9999999-dev -> satisfiable by jms/metadata dev-master.

support adding specific request attributes to the parameters in generateUrl()

i have some examples where I also support setting the _format via the URL, so to generate the correct URLs I would need to also have the _format request attributed passed to the generateUrl() call.

then again do we really want to cover this use case? we can just assume that people are using proper accept header to request the format they want.

furthermore fixing this will require the link classes to gain access to the request instance, which is a bit iffy in general.

Create library

Hey,

The JMS serializer is now a library, and can be used without symfony2. The relevant part of the hateoas bundle should be extracted into a php library, that could be used with the serializer.

Performance issues

We realized we are having performance issues because of this bundle. If we remove the @Rest\Relation annotations from our entities (about 4-6 per entity) we can cut our reponse times in half! (From 0.6s to 0.3s)

Allow using a different URL Generator

We should be able to specify a different URL generator service for a route. This would allow using a RFC6570 compliant router generator to be used instead (for templated links).

ODM and embedded documents

I'm using ODM, and it's automatically adding links to all my embedded documents... Is there a way to only show HATEOAS stuff when configured to do so instead on all serialized stuff?

Update to use Symfony 2.3

This bundle currently does not work if you try to upgrade to Symfony 2.3, which has now been released.

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.