php - Enterprise Architect 8 > Displaying Inheritance Chain for a Class
Get the solution ↓↓↓Solution:
This answer applies to EA 9.3. I don't have an old EA 8 lying around but EA is eminently backwards-compatible, so you should upgrade in any case.
There are a couple of ways to follow inheritance chains in EA.
Method 1: add classes to the same diagram.
In a diagram containing the root class of your inheritance hierarchy, right-click the root class and select Add - Related Elements. In the "Insert Related Elements" dialog, select the length of chain ("levels") you want, up to a maximum of 5. Specify "link type" Generalization. You can leave the other options as they are, or play around with them if you like.
This will cause EA to add those classes to the diagram which inherit from the root class in up to 5 steps/levels. You don't have to start from a root class; the option "link direction" in the dialog controls whether relationships should be followed in one or both directions.
You can use this same function to add classes related through other relationships, such as aggregations.
Method 2: Use the Traceability window.
In the main menu, select View - Traceability. This opens the Traceability window, which is a tree view with the currenty selected element at the top, and nodes for all related elements in a hierarchy.
Select the root class and violà, all its inheriting classes are shown as child nodes in the Traceability window, and you can expand them in turn to follow the chains further.
Method 1 puts the information in diagrams, where it is kept and needs to be updated. Method 2 is dynamic and more usefu when you need to check a specific relationship chain.
The relationships in a diagram are automatically updated if the underlying model changes, so if for instance you change the code and reimport it, this will be reflected in the diagram. To be on the safe side, always work with manually created diagrams in a separate package from the source package.
Answer
Solution:
Am not sure if there is existing solution but is something you can easily implement usingReflectionClass
and Google Graph
Example
class A {
}
class B extends A {
}
class C extends B {
}
class D extends C {
}
class E extends D {
}
class F extends E {
}
function getPath($className) {
$class = new ReflectionClass($className);
$name = $class->getParentClass();
if ($name) {
echo $class->getName(), " extends ";
getPath($name->getName());
} else {
echo $class->getName();
}
}
getPath("C");
getPath("F");
Output
C extends B extends A
F extends E extends D extends C extends B extends A
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: cannot set properties of undefined (setting '_dt_cellindex')
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.