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

Pseudo-routing take two #168

Merged
merged 54 commits into from
Jul 4, 2022
Merged

Pseudo-routing take two #168

merged 54 commits into from
Jul 4, 2022

Conversation

caendesilva
Copy link
Member

@caendesilva caendesilva commented Jul 4, 2022

A simpler, less prematurely abstracted, and more tested, take on #112


Pseudo-Router for Hyde.

This is not a router in the traditional sense that it decides where to go.
Instead, it creates a pre-generated object encapsulating the Hyde autodiscovery.

If successful, this will not only let us emulate Laravel route helpers, but also
serve as the canonical source of truth for the Hyde autodiscovery process.

The routes defined can then also be used to power the RealtimeCompiler without
having to reverse-engineer the source file mapping.

Routes cannot be added manually, instead the route index is created using the
exact same rules as the current autodiscovery process and compiled file output.

The route index shall serve as a multidimensional mapping allowing you to
determine where a source file will be compiled to, and where a compiled
file was generated from.

Update Router.php
    /**
     * Construct a new Route instance for the given page model and add it to the router.
     *
     * @internal This is an internal helper method.
     * @param \Hyde\Framework\Contracts\PageContract $page
     * @return $this<\Hyde\Framework\Modules\Routing\RouteContract>
     */
    public function discover(PageContract $page): self;
@codecov
Copy link

codecov bot commented Jul 4, 2022

Codecov Report

Merging #168 (df4eee3) into master (6d2a973) will not change coverage.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##              master      #168   +/-   ##
===========================================
  Coverage     100.00%   100.00%           
- Complexity       751       769   +18     
===========================================
  Files             97       100    +3     
  Lines           1949      1991   +42     
===========================================
+ Hits            1949      1991   +42     
Impacted Files Coverage Δ
packages/framework/src/Contracts/AbstractPage.php 100.00% <100.00%> (ø)
packages/framework/src/Modules/Routing/Route.php 100.00% <100.00%> (ø)
...ork/src/Modules/Routing/RouteNotFoundException.php 100.00% <100.00%> (ø)
packages/framework/src/Modules/Routing/Router.php 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6d2a973...df4eee3. Read the comment docs.

@caendesilva
Copy link
Member Author

Would be neat with a Route facade (basically, just class aliasing the route class), and a route() helper method as well?

@caendesilva caendesilva marked this pull request as ready for review July 4, 2022 10:09
@caendesilva caendesilva merged commit f1a3be1 into master Jul 4, 2022
@caendesilva caendesilva deleted the pseudo-routing-take-two branch July 4, 2022 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants