Skip to content

[6.0] Fulfill InstallerScriptInterface with a trait #44381

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

Open
wants to merge 13 commits into
base: 6.0-dev
Choose a base branch
from

Conversation

bembelimen
Copy link
Contributor

@bembelimen bembelimen commented Oct 30, 2024

Summary of Changes

This implements a trait to be used in combination with the InstallerScriptInterface

Testing Instructions

I have no real idea, how to test it. You need an Extension using a install script with the InstallerScriptInterface. Using this trait should resolve the interface and give you some additional options like:

you can set

  • a minimum PHP version which is required
  • a minimum Joomla! version which is required
  • files to be removed
  • creating a dashboard menu onthefly

There are also two "custom" methods to extend preflight/postflight and still benefit from their functionality.

Link to documentations

Please select:

];

if (!$model->save($module)) {
Factory::getApplication()->enqueueMessage(Text::sprintf('JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DASHBOARD', $model->getError()));
Copy link
Member

Choose a reason for hiding this comment

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

Would be nice to have a set/getApplication function instead using the one from the factory.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @laoneo any suggestion how to do this in the trait without causing a lot of hassle for the developer? I guess we have no applicationaware trait yet... If you have a good idea, feel free to create a PR against the branch to improve.

Copy link
Member

Choose a reason for hiding this comment

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

you already use $this->getApplication() in line 331 above.

In my installer script I get the application from the container and set it in the constructor, but I didn't find out where it is set by a quick review.

@laoneo
Copy link
Member

laoneo commented Oct 31, 2024

In general I'm not sure if the trait is the right approach. I would prefer a base class.

@wilsonge
Copy link
Contributor

wilsonge commented Nov 1, 2024

What's the value of deprecating and forcing people to move. I mean I'm not fussed whether we use a base class or a trait to be honest - but I don't see the value of just deprecating and moving to the other one forcing code changes for next to no benefit.

@HLeithner
Copy link
Member

I miss an interface for this trait and I would replace the string type with an enum.

I think the goal is to get type safety with out b/c break.

@laoneo
Copy link
Member

laoneo commented Nov 4, 2024

The interface exists already, but I couldn't change the InstallerClass without braking bc at the time I made it.

@HLeithner HLeithner changed the base branch from 5.3-dev to 6.0-dev March 4, 2025 17:19
@HLeithner
Copy link
Member

This pull request has been automatically rebased to 6.0-dev.

@HLeithner HLeithner changed the title [5.3] Replace InstallerScript class with a trait [6.0] Replace InstallerScript class with a trait Mar 4, 2025
@rdeutz rdeutz removed the PR-5.3-dev label Mar 5, 2025
@bembelimen bembelimen changed the title [6.0] Replace InstallerScript class with a trait [6.0] Fullfill InstallerScriptInterface with a trait Apr 18, 2025
@bembelimen bembelimen changed the title [6.0] Fullfill InstallerScriptInterface with a trait [6.0] Fulfill InstallerScriptInterface with a trait Apr 25, 2025
Copy link
Member

@HLeithner HLeithner left a comment

Choose a reason for hiding this comment

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

I made some annotations maybe can comment on them.

];

if (!$model->save($module)) {
Factory::getApplication()->enqueueMessage(Text::sprintf('JLIB_INSTALLER_ERROR_COMP_INSTALL_FAILED_TO_CREATE_DASHBOARD', $model->getError()));
Copy link
Member

Choose a reason for hiding this comment

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

you already use $this->getApplication() in line 331 above.

In my installer script I get the application from the container and set it in the constructor, but I didn't find out where it is set by a quick review.

{
$client = ApplicationHelper::getClientInfo(1);

$pathname = 'extension_' . ($client ? $client->name : 'root');
Copy link
Member

Choose a reason for hiding this comment

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

can ist be possible that client returns a null object? I mean we use a constant above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants