Skip to content

Version 1.3.0 - Stable

Compare
Choose a tag to compare
@phproberto phproberto released this 16 Aug 13:32

How to install / upgrade

Download joomla-entity-v1.3.0.zip an install through Joomla! Extension Manager.

New Features

  • Fast method to retrieve user identifier for entities using HasUser trait.
// This entity uses the HasUser Trait
$entity = MyEntity::find(42);

// This will compare entity's ID with active user ID
if ($entity->hasUser() && User::active()->id() === $entity->userId())
{
    echo 'Active user is entity user!';
}
  • Methods to add user to one or more user groups:
$user = User::find(42);

// Add user to one user group
$user->addToUserGroup(5);

// Add user to multiple user groups
$user->addToUserGroups([5, 7]);
  • Methods to remove user from one/multiple/all user groups:
$user = User::find(42);

// Remove user from one user group
$user->removeFromUserGroup(5);

// Remove user from multiple user groups
$user->removeFromUserGroups([5, 7]);

// Remove user from all his/her user groups
$user->removeFromAllUserGroups();
  • Method to easily retrieve authorId() on entities implementing HasAuthor trait:
$entity = Article::find(3);

if ($entity->hasAuthor() && User::active()->id() === $entity->authorId())
{
    echo 'You are the author of this article!';
}
  • Method to easily retrieve editorId() on entities implementing HasEditor trait:
$entity = Article::find(3);

if ($entity->hasEditor() && User::active()->id() === $entity->editorId())
{
    echo 'You are the editor of this article!';
}