isAllowedToEditComment
The isAllowedToEditComment hook is triggered to determine permission on a
comment from unknown source in the back end. It passes the comment parent ID and
source table and expects a boolean as return value.
Parameters
int
$parentIdThe parent record ID.
string
$parentTableThe parent table name.
Return Values
If you return true, access to the comment is granted. Return false if access
is prohibited or your function is not responsible for this comment.
Example
// src/EventListener/IsAllowedToEditCommentListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('isAllowedToEditComment')]
class IsAllowedToEditCommentListener
{
public function __invoke(int $parentId, string $parentTable): bool
{
// Check the access to your custom module
if (\Contao\BackendUser::getInstance()->hasAccess('custom', 'modules')) {
return true;
}
return false;
}
}