easyrdf icon indicating copy to clipboard operation
easyrdf copied to clipboard

customizable Graph class

Open madbob opened this issue 4 years ago • 2 comments

Would be useful to add a TypeMapper::setDefaultGraphClass() method to permit customization (and extension) of the base Graph class.

Actually I had such a need, but the only solution I found was to get the Graph from Sparql\Client::query() and translate it within my own class:

use EasyRdf\Graph;

class MyGraph extends Graph
{
    public static function extend($real_graph)
    {
        $contents = $real_graph->serialise('turtle');
        return new self($real_graph->getUri(), $contents, 'turtle');
    }

    // ... my own stuff... 
}

Not very efficient...

madbob avatar Apr 04 '21 23:04 madbob

Sounds like an interesting enhancement. Out of interest, what customisations are you doing to your Graph class?

njh avatar Apr 05 '21 08:04 njh

Pull request #381

(I'm intercepting add() and deleteSingleProperty() calls to keep track of modifications operated directly into the Graph and provide further elaborations).

madbob avatar Apr 06 '21 00:04 madbob