Closed Nek- closed 10 years ago
New gallery controller
Why controller? I guess you won't be accepting Request
and an argument, isn't service (or just in the Shortcode
class) a better place for it?
Repository class for Post items
:+1:
Here is an example of gallery, in fact it's out of the post, so it should be in a controller.
With my implementation the user will be able to redefine the template of the shortcode so he's not obliged to use the controller gallery (that will not be so awesome but follow wordpress).
@Nek- In fact AttachmentManager can act as a repository already. (Bad naming? This was my first bundle so I didn't know the difference between Manager
and Repository
...)
Anyway, I would keep Controller out of this bundle, because the goal of this bundle is to help developer to create their own app by providing a set of services / utilities, not to create one for them. Also we are not going to provide any routing in this bundle, so I don't think anyone is going to use the Controller we provide anyway.
An gallery can be as simple as this:
public galleryAction($post)
{
return [
'gallery' => $this->get('kayue_wordpress.attachment.manager')->findAttachmentsByPost($post);
];
}
About Manager/Repository, bad naming indeed. I'm going to keep your logic.
About the controller, when you say galleryAction
, you're speaking about a controller :) . But you don't want one... Weird isn't it ?
I don't see the problem to have a controller in the bundle.
@Nek- I didn't meant to have galleryAction
in this bundle. My point is we have already made the code so simple, why do we bother creating the Controller for the developer?
I believe every app's business logic (Controller) is different, we can never create a Controller that can fit everybody. Some people might want render gallery in a Twig function, some might want to use this bundle to create a REST API. I think we should let the developer decide how they want to use this bundle.
It's the same deal as FOSControllers :) . But they provide some. And a lot of people use them... Because they don't need complexe Controllers.
Also since I'm going to provide an (overidable) template for the shortcut that will have a link to another page... I need to have something at the other page.
@Nek- Alright then. It doesn't hurt to provide more. =)
Okep :) . I'm going to write some tests and I PR !
In order to transform galery shortcodes I suggest a solution with many improvements:
Anything against this suggestion ?