Because developing Joomla extensions should be fun and easy.
Let's use a fast example. This is how you actually can load an article by its id in Joomla:
Where $article
is a stdClass
object. You can access its properties but it's really a dummy thing. An end point.
With an Article entity you can do:
Here $article
is an Article entity. An object that exposes its logic and resources to the developer.
Some awesome things that you can do with that article entity:
// Use article as entity
echo $article->get('title');
// Use params transparently
if ($article->param('show_title', '1') === '1')
{
echo $article->get('title');
}
// Check if article is featured
if ($article->isFeatured())
{
// Do something
}
// Check if article has an intro image
if ($article->hasIntroImage())
{
$image = $article->getIntroImage();
echo '<img src="' . JUri::root(true) . '/' . $image['url'] . '" />';
}
// Check article state
if ($article->isPublished())
{
echo 'Article published!';
}
// Retrieve article category
echo $article->category()->get('title');
// You can modify article properties
$article->set('title', 'My modified title');
// And save it
try
{
$article->save();
}
catch (\RuntimeException $e)
{
echo 'There was an error saving article: ' . $e->getMessage();
}
See the full documentation for other examples.
Go to the releases section and follow the How to install / upgrade
instructions in the latest release.
Documentation is published in https://phproberto.github.io/joomla-entity/.
- PHP 7.1+
- Joomla! CMS v3.9+
This library is licensed under GNU LESSER GENERAL PUBLIC LICENSE.
Copyright (C) 2017-2019 Roberto Segura López - All rights reserved.