PR-5.1-dev Pending

User tests: Successful: Unsuccessful:

avatar CraftException
CraftException
23 Oct 2023

No Issue (Just something that annoyed me tbh)

Summary of Changes

I've added to methods to the Joomla\CMS\MVC\View\AbstractView Class:

  • Added $properties to get method. If you want to also provide properties to the model method, you can use other
    parameters after the $properties and $default parameter. Until now, you could only call a method of a model with specific properties by accessing the model diretly:
    $this->getModel("Article")->getById($id)
    But now you can just use the get method:
    $this->get("ById", "Article", $id)
  • Added new method getAll as a shorthand to get all Data of a Model. Until now, you could also only call a method to display all data via the model directly:
    $this->getModel("Article")->getArticles()
    Now you can just use the getAll method:
    $this->getAll("Article") -> $this->get("Articles, "Article") If you have a specific list function (e.g. getAllArticles), you can also provide a second parameter $property, otherwise the model name will automatically be transformed into a plural noun. $this->getAll("Article", "Fields")->$this->get("Fields", "Article")`

Testing Instructions

s. above.

Actual result BEFORE applying this Pull Request

Accessing the model directly in Views needed to call specific methods

Expected result AFTER applying this Pull Request

More convenient methods in AbstractView

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

avatar CraftException CraftException - open - 23 Oct 2023
avatar CraftException CraftException - change - 23 Oct 2023
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Oct 2023
Category Libraries
avatar CraftException CraftException - change - 23 Oct 2023
Title
5.1 dev
More convenient access to models in AbstractView.php
avatar CraftException CraftException - edited - 23 Oct 2023
avatar CraftException CraftException - change - 23 Oct 2023
Labels Added: PR-5.1-dev
avatar CraftException CraftException - change - 23 Oct 2023
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2023-10-23 08:25:03
Closed_By CraftException
avatar CraftException CraftException - close - 23 Oct 2023

Add a Comment

Login with GitHub to post a comment