neo4jphp
neo4jphp copied to clipboard
load node data before calling nodeFactory
its rly cool that i can set my own nodeFactory! I want use different node class for different labels. For example if i have label Movie i want create MovieNode, for label Person i want PersonNode, etc. But i cant decide what node i should create before the node data is actually loaded. This situation is happening in $client->getNode() on 332 is node created https://github.com/jadell/neo4jphp/blob/fe6337c41eaab981b6e874c0b1180329d91ef6f6/lib/Everyman/Neo4j/Client.php#L332 and on 340 is data loaded https://github.com/jadell/neo4jphp/blob/fe6337c41eaab981b6e874c0b1180329d91ef6f6/lib/Everyman/Neo4j/Client.php#L340
The conveniant functions don't allow you to inspect the data before the node is constructed. I inspected the code and it seems it would need a lot of refactoring. Because now it works like this:
- the node is constructed
- the node is inserted into a command
- the data is fetched from the database (through some function calls in php)
- eventually the command is responsible for initiating the data loading into the node
The shortcut (untested) would be to:
- Get the raw data
- Construct your own node class by calling your factory directly
- Call the entity mapper to populare your node