10000 Removed dotkernel/dot-controller and replaced with handlers by MarioRadu · Pull Request #33 · dotkernel/light · GitHub
[go: up one dir, main page]

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

Removed dotkernel/dot-controller and replaced with handlers #33

Merged
merged 8 commits into from
Feb 14, 2025
Merged

Conversation

MarioRadu
Copy link
Member

No description provided.

Copy link
github-actions bot commented Feb 11, 2025

Qodana for PHP

24 new problems were found

Inspection name Severity Problems
Parameter type 🔶 Warning 18
Undefined class 🔶 Warning 6

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Detected 34 dependencies

Third-party software list

This page lists the third-party software dependencies used in project

Dependency Version Licenses
brick/varexporter 0.5.0 MIT
dotkernel/dot-errorhandler 4.1.1 MIT
dotkernel/dot-log 4.1.1 MIT
fig/http-message-util 1.1.5 MIT
laminas/laminas-component-installer 3.5.0 BSD-3-Clause
laminas/laminas-config-aggregator 1.17.0 BSD-3-Clause
laminas/laminas-diactoros 3.5.0 BSD-3-Clause
laminas/laminas-escaper 2.15.0 BSD-3-Clause
laminas/laminas-httphandlerrunner 2.11.0 BSD-3-Clause
laminas/laminas-servicemanager 4.4.0 BSD-3-Clause
laminas/laminas-stdlib 3.20.0 BSD-3-Clause
laminas/laminas-stratigility 3.13.0 BSD-3-Clause
laminas/laminas-translator 1.1.0 BSD-3-Clause
laminas/laminas-validator 3.0.1 BSD-3-Clause
mezzio/mezzio-fastroute 3.12.0 BSD-3-Clause
mezzio/mezzio-helpers 5.17.0 BSD-3-Clause
mezzio/mezzio-router 3.18.0 BSD-3-Clause
mezzio/mezzio-template 2.11.0 BSD-3-Clause
mezzio/mezzio-twigrenderer 2.17.0 BSD-3-Clause
mezzio/mezzio 3.20.1 BSD-3-Clause
nikic/fast-route v1.3.0 BSD-3-Clause
nikic/php-parser v5.4.0 BSD-3-Clause
psr/container 2.0.2 MIT
psr/http-client 1.0.3 MIT
psr/http-factory 1.1.0 MIT
psr/http-message 2.0 MIT
psr/http-server-handler 1.0.2 MIT
psr/http-server-middleware 1.0.2 MIT
symfony/deprecation-contracts v3.5.1 MIT
symfony/polyfill-ctype v1.31.0 MIT
symfony/polyfill-mbstring v1.31.0 MIT
twig/twig v3.20.0 BSD-3-Clause
webimpress/safe-writer 2.2.0 BSD-2-Clause
webmozart/assert 1.11.0 MIT
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@MarioRadu MarioRadu requested a review from alexmerlin February 12, 2025 09:37
@alexmerlin
Copy link
Member

Leaving these here for reference:

src/Page/src/Handler/PageHandler.php

$routeName = $request->getAttribute(RouteResult::class)->getMatchedRouteName();
return new HtmlResponse(
    $this->template->render(str_replace('page.', 'page::', $routeName))
);

src/Page/src/RoutesDelegator.php

$app->get('/page/about', [PageHandler::class], 'page.about');
$app->get('/page/who-we-are', [PageHandler::class], 'page.who-we-are');

src/App/templates/layout/default.html.twig

<div class="dropdown-menu" aria-labelledby="pageDropdown">
    <a class="dropdown-item" href="{{ url('app.index') }}">Home</a>
    <a class="dropdown-item" href="{{ url('page.about') }}">About Us</a>
    <a class="dropdown-item" href="{{ url('page.who-we-are') }}">Who We Are</a>
</div>

We'll comment on them today during the TSC meeting.

@arhimede
Copy link
Member

Summary:

  • create a new config file , called static.php
  • pageHandler _> rename StaticHandler
  • read config file with routes in RouteDelegator ( the handler should not be in config ) OR in routes.php

Signed-off-by: MarioRadu <magda_marior@yahoo.com>
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
Signed-off-by: MarioRadu <magda_marior@yahoo.com>
@@ -1,6 +1,7 @@
{% extends '@layout/default.html.twig' %}

{% block title %}{{ status }} {{ reason }}{% endblock %}
{% block canonical %}{% endblock %}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arhimede
It's not a 404 page, so we have a matched route, which means that we CAN parse the canonical URL of the page.
Not sure if we SHOULD, though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not bother to have a canonical in 404 pages

It doesn't matter in the slightest for Google, all content, including headers, are dropped when a 404 status code is seen.
So no matter what you'd put in there, google wouldn't process and use it.

Copy link
Member
@alexmerlin alexmerlin Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said:

It's not a 404 page, so we have a matched route...

My question was if we should have a canonical URL on a 500 (or any other non-404) page.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, useless

$app->get('/', [PageController::class], 'home');

$app->get('/page[/{action}]', [PageController::class], 'page');
$routes = $container->get('config')['routes'] ?? [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏🏻

sprintf('%s::%s', $moduleName, $templateName)
);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👋🏻 👏🏻

@arhimede
Copy link
Member

It is deployed on light.dotkernel.net
cache deleted, local.php updated, composer installed

https://light.dotkernel.net/page/who-we-arexxx
is returning 500 instead of 404

"ERR","message":"An exception has been thrown during the rendering of a template ("Cannot generate URI for route "page::about"; route not found").

Signed-off-by: MarioRadu <magda_marior@yahoo.com>
@arhimede arhimede merged commit 005fe88 into 1.0 Feb 14, 2025
31 checks passed
@alexmerlin alexmerlin deleted the issue-27 branch February 14, 2025 11:57
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.

3 participants
0