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

[5.3] Refactoring views to directly call models (installation & API) #44169

Open
wants to merge 6 commits into
base: 5.3-dev
Choose a base branch
from

Conversation

Hackwar
Copy link
Member

@Hackwar Hackwar commented Sep 30, 2024

Summary of Changes

This PR refactors the views to get the model object and then directly call the methods of the model instead of going through the View::get() indirection. This refactors the views of the Joomla installation and of the web API.

Testing Instructions

Everything should work the same.

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@@ -41,7 +41,7 @@ class JsonapiView extends BaseApiView
public function displayList(?array $items = null)
{
try {
$component = ComponentHelper::getComponent($this->get('component_name'));
$component = ComponentHelper::getComponent($this->component_name);
Copy link
Member

Choose a reason for hiding this comment

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

Can you please define the variable here as "public" or find a better solution?
because component_name is set by the controller with the LegacyPropertyManagementTrait::set method, which sets the property dynamic, as alternative a setComponentName() is needed which sets a protected/private property.

Copy link
Member Author

Choose a reason for hiding this comment

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

So, after all this refactoring we still have some cases where set and get are used outside of the HtmlView.php files. To me that is another PR. Quite frankly, in this case I would rather revert this line and do that in another PR as well to not delay merging the rest. Would that be okay?

@@ -43,7 +43,11 @@ class DefaultView extends BaseHtmlView
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$model = $this->getModel();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$model = $this->getModel();
$model = $this->getModel();

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.

4 participants