Code Monkey home page Code Monkey logo

Comments (7)

enov avatar enov commented on September 28, 2024

We can't have PSR-1 and PSR-2 at this point, @WinterSilence.

I would go one step further to define the interfaces for those classes.

  • Make Router interface dependent on Route interface
  • Make the Request dependent on Router interface

This way we can have multiple implementations of Route:

  • Route_Legacy (the route we currently have with directory and prefix
  • Route_Dynamic (the route we want to acheive in #571 with FCQN controller maybe with namespace and suffix Controller
  • Route_Static (a static route that does not get affected by a controller parameter, it just routes to the controller and action defined in that route)

Also, we can have multiple implementation of Router interface, one of them would be to load from config.

Moreover:

  • add a process method to Router, so that processing will be handled inside the Router from Request and should return matched Route along with the controller.

Add unit tests :)

Cheers!

from core.

WinterSilence avatar WinterSilence commented on September 28, 2024

@enov

At this stage, discuss common issues.

I don't suggest using these classes, this is only sketches. At first, we need to discuss the principles of classes. I just described my classes to highlight the major changes.

from core.

enov avatar enov commented on September 28, 2024

Alright @WinterSilence. 👍 for separating router and route.

from core.

WinterSilence avatar WinterSilence commented on September 28, 2024

@enov

Make Router interface dependent on Route interface

I agree, but we need to make a list of the main methods.

Moreover: add a process method to Router, so that processing will be handled inside the Router from Request and should return matched Route along with the controller.

I dont understand, you can write an example?

Add unit tests

Too early for this.

Add sketches for your version - interfaces and dummy-classes (empty methods)

from core.

enov avatar enov commented on September 28, 2024

add a process method to Router

I was saying if we can remove this method from Request and put it where it belongs:

https://github.com/kohana/core/blob/3.3/master/classes/Kohana/Request.php#L457

from core.

WinterSilence avatar WinterSilence commented on September 28, 2024

Update: added interfaces for routes (IRoute), requests (IRequest) and public function Router::process(IRequest $request)

from core.

enov avatar enov commented on September 28, 2024
  • Do not prefix interfaces names with I, we do not have a naming convention for that. Just choose the most generic name possible, in this case Route and Router are sufficient.
  • Add a Router interface with process, get_route and set_route
  • At this point, we should not mess with Request (also there are interfaces for that already), so maybe process should only care about $uri and method? Is there anything else Router needs to process from Request?

from core.

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.