Version 1.2.0 - Stable
How to install / upgrade
Download joomla-entity-v1.2.0.zip an install through Joomla! Extension Manager.
New Features
- New
loadFromData()
method to load entities by specified columns data:
$userGroup = UserGroup::loadFromData(['title' => 'Registered', 'parent_id' => 1]);
if ($userGroup->isLoaded())
{
echo $userGroup->get('title') . ' user groups exists!';
}
- New
delete()
method to easily delete entities:
Article::delete(23);
// A DeleteException will be thrown if something fails so at this point we are sure delete worked.
echo 'Article 23 was successfully deleted';
// Delete multiple articles passing an array
Article::delete([23, 24, 25]);
// Example catching exception
$msg = 'Article 23 was successfully deleted';
try
{
Article::delete(23);
}
catch (DeleteException $e)
{
$msg = $e->getMessage();
}
echo $msg;
- New FieldGroup entity:
$fieldGroup = FieldGroup::find(1);
foreach ($fieldGroup->fields() as $field)
{
echo 'Field `'. $field->get('title') . '` is in the field group `' . $fieldGroup->get('title') . '`';
}
- Now it's possible to check and retrieve field group from field entity:
$field = Field::find(1);
if ($field->hasFieldGroup())
{
echo 'Field `'. $field->get('title') . '` is in the field group `' . $field->fieldGroup()->get('title') . '`';
}
- Now it's possible to check if an entity has associated fields with
hasFields()
:
$article = Article::find(12);
if ($article->hasFields())
{
foreach ($article->fields() as $field)
{
// Do something
}
}
- New
VielLevel
entity:
$viewLevel = ViewLevel::find(1);
// This will echo something like: Public
echo $viewLevel->get('title');
// Check if a view level has user groups
if ($viewLevel->hasUserGroups())
{
// Do something
}
// Check if a view level has an user group
if ($viewLevel->hasUserGroup(1))
{
// Do something
}
- Now it's possible to retrieve user view levels:
$user = User::find(42);
// This returns a collection of ViewLevel entities
$viewLevels = $user->viewLevels();
// Check if user has view levels
if ($user->hasViewLevels())
{
// Do something
}
// Check if user has a specific view level
if ($user->hasViewLevel(1))
{
// Do something
}