Phalcon\Acl\Adapter\Database::addInherit PHP Method

addInherit() public method

public addInherit ( string $roleName, string $roleToInherit )
$roleName string
$roleToInherit string
    public function addInherit($roleName, $roleToInherit)
    {
        $sql = "SELECT COUNT(*) FROM {$this->roles} WHERE name = ?";
        $exists = $this->connection->fetchOne($sql, null, [$roleName]);
        if (!$exists[0]) {
            throw new Exception("Role '{$roleName}' does not exist in the role list");
        }
        $exists = $this->connection->fetchOne("SELECT COUNT(*) FROM {$this->rolesInherits} WHERE roles_name = ? AND roles_inherit = ?", null, [$roleName, $roleToInherit]);
        if (!$exists[0]) {
            $this->connection->execute("INSERT INTO {$this->rolesInherits} VALUES (?, ?)", [$roleName, $roleToInherit]);
        }
    }