<?php
/**
 * @package     DOCman
 * @copyright   Copyright (C) 2019 Timble CVBA. (http://www.timble.net)
 * @license     GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link        http://www.joomlatools.com
 */

namespace Foliolabs\Docman;

use Foliolabs\Library;

class DatabaseTablePermissions extends Library\DatabaseTableAbstract
{
    public function __construct(Library\ObjectConfig $config)
    {
        parent::__construct($config);

        $clear_permissions = function(Library\DatabaseContextInterface  $context) {
            $this->getObject('docman.users')->clearPermissions();
        };

        $this->addCommandCallback('after.insert', $clear_permissions);
        $this->addCommandCallback('after.update', $clear_permissions);
        $this->addCommandCallback('after.delete', $clear_permissions);
    }
}