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

Work with handlers as service #12

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

Conversation

WBerredo
Copy link

According this guide the best way to work with REST APIS is using handlers. The model of work was implemented based on this guide, but with other functionalities.

PS: This form, the PUT and PATCH functions work correctly

@davidwdan
Copy link
Member

@WBerredo When we first built this generator, we just wanted to create a very simple REST equivalent of the CRUD form generator.

That being said, a lot more people are using this than I had anticipated and I see the benefit to using the handler.

I'm open to merging this, if we can get a couple of issues worked out.

I tested this on the AcmeDemoBundle and it generated the Controller along with the Handler, but it jacked up Acme\DemoBundle\DependencyInjection\AcmeDemoExtension

<?php

namespace Acme\DemoBundle\DependencyInjection;

use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\Config\FileLocator;

class AcmeDemoExtension extends Extension
{
    public function load(array $configs, ContainerBuilder $container)
    {
        $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
        $loader->load('services.xml');


    public function getAlias()
    {
        return 'acme_demo';

        $loader2 = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
        $loader2->load('servicesREST.xml');
    }
}

@WBerredo
Copy link
Author

This really was a bug, I fixed it in last commit.

@davidwdan
Copy link
Member

@WBerredo That works much better now.

There are two other issues that I see:

  1. Can you make the use of apidocs optional?
  2. The current bundle does not include the resource type in the response. I know that there are different schools of thought on that, so maybe that's something that should also be optional.

Other than that, it looks pretty good.

@WBerredo
Copy link
Author

These are a good points, so, they were added on last commits.
The two points are now optionals, for use resource type and documentation you need use resource and document options respectively.

The new form to call the generator is:
voryx:generate:rest [--entity="..."] [--route-prefix="..."] [--overwrite] [--resource] [--document]

@davidwdan
Copy link
Member

@WBerredo I'm still planning to merge this, I just haven't had time to test it. Hoping to get to it next week.

@davidwdan davidwdan added this to the 0.3.0 milestone Feb 3, 2015
@RomainLegouverneur
Copy link

Hi,

Have you some news about this feature to included in voryx's branch ?

Thank's for your time.

@davidwdan
Copy link
Member

@RomainLegouverneur at the moment there are some conflicts with master, which need to be resolved before I can merge. Anyone willing to take that on?

@WickedSilver
Copy link

@davidwdan, i'll be merging this tomorrow into my own fork (https://github.com/Extendas/restgeneratorbundle). I will share my test results here.

@WickedSilver
Copy link

Implemented and merged this in #38

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

Successfully merging this pull request may close these issues.

None yet

5 participants