neo4jphp icon indicating copy to clipboard operation
neo4jphp copied to clipboard

load node data before calling nodeFactory

Open achtan opened this issue 11 years ago • 1 comments

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

achtan avatar Feb 14 '14 15:02 achtan

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:

  1. the node is constructed
  2. the node is inserted into a command
  3. the data is fetched from the database (through some function calls in php)
  4. eventually the command is responsible for initiating the data loading into the node

The shortcut (untested) would be to:

  1. Get the raw data
  2. Construct your own node class by calling your factory directly
  3. Call the entity mapper to populare your node

flip111 avatar Jul 09 '15 21:07 flip111