Giter Club home page Giter Club logo

Comments (8)

kayue avatar kayue commented on August 14, 2024

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

👍

from kayuewordpressbundle.

Nek- avatar Nek- commented on August 14, 2024

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).

Screenshoot of my wordpress test website

from kayuewordpressbundle.

kayue avatar kayue commented on August 14, 2024

@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);
  ];
}

from kayuewordpressbundle.

Nek- avatar Nek- commented on August 14, 2024

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.

from kayuewordpressbundle.

kayue avatar kayue commented on August 14, 2024

@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.

from kayuewordpressbundle.

Nek- avatar Nek- commented on August 14, 2024

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.

from kayuewordpressbundle.

kayue avatar kayue commented on August 14, 2024

@Nek- Alright then. It doesn't hurt to provide more. =)

from kayuewordpressbundle.

Nek- avatar Nek- commented on August 14, 2024

Okep :) . I'm going to write some tests and I PR !

from kayuewordpressbundle.

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.