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

[NodeBundle, GeneratorBundle] Deprecated the service method in Pages in favour of controller methods #290

Merged
merged 1 commit into from Apr 10, 2015

Conversation

Projects
None yet
4 participants
@woutervandamme
Copy link
Contributor

woutervandamme commented Apr 9, 2015

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? yes
Fixed tickets #211

instead of putting logic in the entity pages (service method), it is now possible to just implement the SlugActionInterface and specify which controller method must be executed.

  • Gather feedback for my changes
  • update relevant CHANGELOG and UPGRADE files;

UPGRADE

Deprecated the service method in Pages in favour of controller methods

You need to remove the service method in your entities and replace them by implementing the SlugActionInterface. Add the method getControllerAction and make it return a callable string.

    public function getControllerAction()
    {
        return 'Bundle:Controller:service';
    }

In your controller just add the serviceAction method, let it handle the logic and set the renderContext in the request attributes.

    public function serviceAction(Request $request)
    {
        ..logic..
        $context['variable'] = $variable;

        $request->attributes->set('_renderContext',$context);
    }

@roderik roderik changed the title [NodeBundle, GeneratorBundle] deprecated service method [NodeBundle, GeneratorBundle] Deprecated the service method in Pages in favour of controller methods Apr 9, 2015

@roderik

This comment has been minimized.

Copy link
Contributor

roderik commented Apr 9, 2015

after open tasks and squash, 👍 for merge

@krispypen

This comment has been minimized.

Copy link
Member

krispypen commented Apr 9, 2015

$request = $event->getRequest();
$nodeTranslation = $request->attributes->get('_nodeTranslation');
if($nodeTranslation)

This comment has been minimized.

@wimvds

wimvds Apr 9, 2015

Contributor

Check the Symfony coding standards for correct code structure (http://symfony.com/doc/current/contributing/code/standards.html - or format your code automatically in your IDE using Symfony coding standards :p).

- { name: kernel.event_listener, event: kernel.controller, method: onKernelController }

kunstmaan_node.slug.security.listener:
class: Kunstmaan\NodeBundle\EventListener\SlugSecurityListener

This comment has been minimized.

@wimvds

wimvds Apr 9, 2015

Contributor

This class should be a parameter, so users can easily override it with their own implementation.

@@ -120,3 +120,21 @@ services:
class: Kunstmaan\NodeBundle\Command\FixTimestampsCommand
calls:
- [setContainer, ["@service_container"] ]

kunstmaan_node.slug.listener:
class: Kunstmaan\NodeBundle\EventListener\SlugListener

This comment has been minimized.

@wimvds

wimvds Apr 9, 2015

Contributor

This class should be a parameter, so users can easily override it with their own implementation.

- { name: kernel.event_listener, event: kunstmaan_node.slug.security, method: onSlugSecurityEvent }

kunstmaan_node.render.context.listener:
class: Kunstmaan\NodeBundle\EventListener\RenderContextListener

This comment has been minimized.

@wimvds

wimvds Apr 9, 2015

Contributor

This class should be a parameter, so users can easily override it with their own implementation.

* @param EntityManager $em
* @param EngineInterface $templating
*/
public function __construct(EntityManager $em, EngineInterface $templating)

This comment has been minimized.

@wimvds

wimvds Apr 9, 2015

Contributor

Why is the EntityManager injected here? It's not used ...

return;
}
$request = $event->getrequest();

This comment has been minimized.

@wimvds

wimvds Apr 9, 2015

Contributor

Change getrequest() to getRequest(), and move this line up, before the if. Use $request in the if (makes the code a tiny bit more readable).

@krispypen krispypen added this to the Q1 2015 - v3.1 milestone Apr 10, 2015

KUNSTMAAN
Added SlugControllerListener to listen for kernel.controller event so…
… it can intercept the SlugController.

If you want to do this, you must implement the SlugControllerActionInterface and specify the action to perform on which controller

removed comment from interface

added the listeners and event

added comment to the slug security event

removes twigEngine dependency

moved the security part over to a seperate event and put the rendering is seperate method

removes service method

@woutervandamme woutervandamme force-pushed the woutervandamme:deprecate-service-method branch from ad47d88 to b463539 Apr 10, 2015

krispypen added a commit that referenced this pull request Apr 10, 2015

Merge pull request #290 from woutervandamme/deprecate-service-method
[NodeBundle, GeneratorBundle] Deprecated the service method in Pages in favour of controller methods

@krispypen krispypen merged commit a917421 into Kunstmaan:master Apr 10, 2015

1 of 2 checks passed

Scrutinizer Created
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@woutervandamme woutervandamme deleted the woutervandamme:deprecate-service-method branch May 5, 2015

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