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

chore: merge the app with the container & implement the ApplicationContract #3862

Merged
merged 8 commits into from
Sep 15, 2023

Conversation

SychO9
Copy link
Member

@SychO9 SychO9 commented Aug 9, 2023

Changes proposed in this pull request:
Illuminate components always expect the app to be the container, but also expect the app to be implementing the laravel app contract. This means that very often between minor illuminate updates we get a call to a method on the app that doesn't exist in the Flarum app. This fixes the issue once and for all.

Reviewers should focus on:
The application contract implementation was separated into a trait to reduce the bloat because all those methods we don't actually need/use, so it can serve as a readable way of telling.

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

…ntract

Illuminate components always expect the app to be the container, but also expect the app to be implementing the laravel app contract. This means that very often between minor illuminate updates we get a call to a method on the app that doesn't exist in the Flarum app. This fixes the issue once and for all.
@SychO9 SychO9 requested a review from a team as a code owner August 9, 2023 09:41
framework/core/src/Foundation/Config.php Outdated Show resolved Hide resolved
@@ -46,6 +46,8 @@ protected function tearDown(): void
protected function app()
{
if (is_null($this->app)) {
$this->config('env', 'testing');
Copy link
Member

Choose a reason for hiding this comment

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

Why was this added / why wasn't it needed before?

Copy link
Member Author

Choose a reason for hiding this comment

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

since we now implement the laravel ApplicationContract which has the environement method that can be called internally in illuminate components, we might as well also make sure the value is correct in testing. (that's the gist of the changes in this PR)

* Implementation of the Laravel Application Contract,
* for the sake of better integration with Laravel packages/ecosystem.
*/
trait InteractsWithLaravel
Copy link
Member

Choose a reason for hiding this comment

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

A lot of this stuff feels familiar, didn't we have it written somewhere before?

Copy link
Member Author

Choose a reason for hiding this comment

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

predates my time in flarum, but it might have implemented the laravel ApplicationContract at some point and then removed.

return false;
}

public function registerConfiguredProviders()
Copy link
Member

Choose a reason for hiding this comment

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

What's up with the empty ones?

Copy link
Member Author

Choose a reason for hiding this comment

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

has no actual meaning within our architecture, but have to implement the contract.

Copy link
Member

Choose a reason for hiding this comment

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

Are any of the methods / code in this trait used for our needs at all?

Copy link
Member

Choose a reason for hiding this comment

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

Also, could we mark all these as deprecated to discourage using them in Flarum code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are any of the methods / code in this trait used for our needs at all?

Indirectly, within illuminate components we use, like runningInUnitTests or runningInConsole, terminating. At any moment an Illuminate component could start calling one of these methods.

@SychO9 SychO9 force-pushed the sm/laravel-tight-coupling branch from cb9a9ff to 47a0298 Compare August 11, 2023 08:31
@SychO9 SychO9 force-pushed the sm/laravel-tight-coupling branch from fe68e67 to 3e49aeb Compare August 11, 2023 08:34
@SychO9 SychO9 merged commit ec5cb98 into 2.x Sep 15, 2023
@SychO9 SychO9 deleted the sm/laravel-tight-coupling branch September 15, 2023 08:30
@SychO9 SychO9 added this to the 2.0 milestone Sep 15, 2023
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