jadell / neo4jphp

PHP wrapper of the Neo4j REST interface
Other
532 stars 137 forks source link

Support new GEOFF syntax #35

Open jadell opened 12 years ago

jadell commented 12 years ago

http://py2neo.org/geoff/

Also, the GEOFF extension: https://github.com/neo4j/neo4j-geoff

Consider deprecating or removing the client-side GEOFF implementation.

technige commented 12 years ago

Damn, beat me to it... was going to raise this as an issue! :-P

jadell commented 12 years ago

Yeah, I knew it was going to have to happen. What I'll probably end up doing is checking to see if the extension is available and forwarding to that if it is, otherwise parse it on the client side. I may have to change the API around a bit, but I don't think many people are using it in Neo4jPHP, so it hopefully won't affect too many users.

technige commented 12 years ago

That's basically what I do in py2neo:

    def load(self, file, **params):
        if self.graph_db._geoff_uri is None:
            batch = self.compile(file, **params)
            results = batch.submit()
            return neo4j.Node(results[batch.first_node_id]['location'])
        else:
            response = graph_db._post(
                graph_db._geoff_uri,
                {'rules': file.read(), 'params': dict(params)}
            )
            return response['params']

On construction of a GraphDatabaseService instance, I query the extensions and store recognisable URIs. In this case the Geoff plugin URI is stored in graph_db._geoff_uri so it's a simple case of checking whether or not that has a value.

Feel free to rip off my code as much as you like :-)

jadell commented 12 years ago

I plan to :-)