How to move treenodes with Gedmo's NestedSet Behaviour - doctrine-orm

i'm using Doctrine 2 and the NestedSet extension.
In Doctrine 1 you had the functions moveAsPrevSiblingOf, moveAsNextSiblingOf and moveAsLastChildOf To move nodes around.
In the documentation of the nested extension only moving a node within the same parent is explained. Move a node to another node is not mention. How can this be done?
Are there easy to use functions as found in Doctrine 1 available?

In the documentation there are examples on how to move the nodes.
$treeRepository
->persistAsFirstChild($food)
->persistAsFirstChildOf($fruits, $food)
->persistAsLastChildOf($vegitables, $food)
->persistAsNextSiblingOf($carrots, $fruits);

Related

How to do deep copy of rte_lpm?

I wanted to create a clone of one existing rte_lpm structure. It looks like there is no function available in DPDK to do this directly.
Docs: https://doc.dpdk.org/api/rte__lpm_8h.html
Is there any way to clone it manually ?
Unfortunately, there is no such functionality. Also there is also no functionality to iterate over the rules. But there are few options:
We can keep the original routing table along the LPM structure. For example, a simple list. This list will be used to show to a user the routing table.
There are few examples in DPDK, have a look at the l3fwd: https://doc.dpdk.org/guides/sample_app_ug/l3_forward.html
So, instead of creating a deep copy of LPM, we can just create a new one and populate it with the rules form this list.
We can create two LMPs and the very beginning and add rules to both of them. This might slow down the add/delete rule process, but once you need a copy -- you always have it.
Another cons is that you will have just one copy, i.e. if you need a few -- this all not work.
So instead of creating a deep copy of LPM, we just always keep two tables.

Drupal 8 hook_node_load not working

I am facing the following challenge for porting my module "Country Specific Nodes" to D8.
I need to finding the right replacement of Drupal 7's hook_node_load in Drupal 8. I tried hook_entity_load as well as hook_ENTITY_TYPE_load, but it returns the Entity objects and not the actual node objects as in D7's hook_node_load.
Please let me know the right approach to this. Thanks for reading out and helping.
Thanks.
I found the solution for this. Use >hook_ENTITY_TYPE_load($entities) for loading nodes. Actually this hook is not called every time a page loads. This is called only when the node is accessed or iterated.
Thanks.

modeling self referencing nodes in EMF and edit them with ECP

I'm trying to model a network with EMF.
The network should be made up of nodes connected to each other.
Each node should have one or many connections to the others, like a mesh network.
The model should be editable by the EMF Client Platforms (ECP) Demo Application.
When the user creates nodes, in ECPs model-explorer, he/she can set the connections to the other nodes, preferably in a list.
First try was a self-reference, but the problem is there are no bidirectional self-references. This results in, not seeing the connection from the opposite node.
My next idea was to use an intermediate connection class, which leads to another problem. I would like to create this connection automatically without a connection class appearing in the model-explorer. Which would be possible to achieve in the generated EMF viewer, but not in the ECP demo application I'm using.
Third Idea: The only way I can think of solving the last idea, is using a tableControl in the view of the node, to edit the connection class in there. But then the problem with hiding the connection class in the model-explorer remains and the connection class appears in the project folder (highest level) and not in their containing class (in my case a network class).
Doe's anyone have some ideas, how to solve any of my problems?
edit: additional information
The connections between the nodes are by definition full duplex.
And the graph should afterwards be used as input for a shortest path algorithm.
Your first try is the good one. Actually, you can model opposite in Ecore. To do so, you have to model two EReferences towards the same object (so two reflexives references), then set the property eOpposite of one of your EReference to the other one.
Here is a simple metamodel with the eOpposite set: https://repository.genmymodel.com/vincent.aranega/NodeGraph
In the Ecore-XMI, it looks like this (note the eOpposite value):
<eStructuralFeatures xsi:type="ecore:EReference" xmi:id="_pwXZhv1pEeW9zv77lynsJg"
name="references" upperBound="-1" eType="#_pwXZg_1pEeW9zv77lynsJg" eOpposite="#_pwXZiv1pEeW9zv77lynsJg"/>
<eStructuralFeatures xsi:type="ecore:EReference" xmi:id="_pwXZiv1pEeW9zv77lynsJg"
name="relatives" upperBound="-1" eType="#_pwXZg_1pEeW9zv77lynsJg" eOpposite="#_pwXZhv1pEeW9zv77lynsJg" />
With this metamodel, you are able to create a Graph that contains many Node. Each node can reference other nodes. If a Node A as a reference to another named B, the relatives collection of B is automatically updated with A.

Override html template per NODE type in Drupal 7?

I know how to override the standard html.tpl.php file. The problem is, I need to apply a certain HTML template for node type one, and another html.tpl.php for node type two. Is there an easy way to just include a template that would work like this? I was hoping if my node has the type "mynode", that it would be as simple as overriding:
html--mynode.tpl.php
But that doesn't seem to work. Am I missing something?
You might need to add some additional code, in YOURTHEME_preprocess_html, according to the following thread in the Drupal forums:
https://www.drupal.org/node/1041768.
Hope that helps,

Need help setting up doctrine 2 cascade deletes

I am quite confused setting up cascade deletes in Doctrine 2. Here's what my setup looks like
I want to setup cascading so that I can do something like $list->getStages()->clear()
I tried in Stage class
/**
* #OneToMany(targetEntity="TaskProgress", mappedBy="stage", cascade={"remove"})
*/
protected $taskStages;
But that did nothing, I even tried putting the same thing in other classes like List, TaskProgress or Task but nothing seem to work, I may have done it wrong tho ..
Cascade remove is not used when calling "clear". Its called when you pass the Stage class to EntityManager#remove(), then all TaskProgress entities are also deleted.