Skip to content
Snippets Groups Projects

Issue #3516271: Improve positioning of GraphViz sections

1 file
+ 23
17
Compare changes
  • Side-by-side
  • Inline
+ 23
17
@@ -48,17 +48,22 @@ function template_preprocess_migration_visualize_graphviz(array &$variables) {
$typeAttributes = _migrate_visualize_graph_type_attributes();
$groups = [
'source' => 0,
'process' => 1,
'destination' => 2
];
/** @var \Fhaculty\Graph\Vertex $vertex */
foreach ($graph->getVertices() as $k => $vertex) {
foreach ($graph->getVertices() as $vertex) {
if ($type = $vertex->getAttribute('migrate_visualize.type')) {
$groups = ['source' => 0, 'process' => 1, 'destination' => 2];
$groupId = explode(':', $type)[0];
if (isset($groups[$groupId])) {
$vertex->setGroup($groups[$groupId]);
}
}
$vertex->setAttribute('graphviz.class', HTML::cleanCssIdentifier(str_replace(':', '-', $vertex->getId())));
$vertex->setAttribute('graphviz.class', Html::cleanCssIdentifier(str_replace(':', '-', $vertex->getId())));
$vertexType = $vertex->getAttribute('migrate_visualize.type');
if ($label = $vertex->getAttribute('migrate_visualize.label')) {
@@ -71,23 +76,23 @@ function template_preprocess_migration_visualize_graphviz(array &$variables) {
}
}
// Attributes for edges.
$graphvizAttributes = [
'colorscheme' => 'set19',
'penwidth' => 2,
'penwidth' => 1,
];
// Base edge colors on origin vertex type.
$edgeTypes = [
'source' => ['colorscheme' => 'bupu9'],
'source:field' => ['colorscheme' => 'bupu9'],
'process' => ['colorscheme' => 'bupu9'],
'process:field' => ['colorscheme' => 'bupu9'],
'process:pipeline:step' => ['colorscheme' => 'bupu9'],
'plugin' => ['colorscheme' => 'bupu9'],
'process:plugin' => ['colorscheme' => 'bupu9'],
'destination' => ['color' => 'goldenrod3'],
'destination:field' => ['color' => 'goldenrod3'],
'source' => ['minlen' => 3],
'source:field' => ['minlen' => 3],
'process' => ['minlen' => 3],
'process:field' => ['minlen' => 3],
'process:pipeline' => ['minlen' => 5],
'process:pipeline:step' => ['minlen' => 1],
'plugin' => ['minlen' => 1],
'process:plugin' => ['maxlen' => 1],
'destination' => ['maxlen' => 1],
'destination:field' => ['maxlen' => 5],
'pseudofield' => ['maxlen' => 10],
];
/** @var \Fhaculty\Graph\Edge\Directed $edge */
@@ -123,11 +128,12 @@ function template_preprocess_migration_visualize_graphviz(array &$variables) {
$variables['graphviz'] = $graphViz->createImageHTML($graph);
}
catch (UnexpectedValueException $exception) {
\Drupal::messenger()->addError(t('Unable to invoke graphviz commands. <a href="@docs">Please check GraphViz is installed</a>.', [
\Drupal::messenger()->addError(t('Unable to invoke graphviz commands (error %error). <a href="@docs">Please check GraphViz is installed</a>.', [
'@docs' => 'https://git.drupalcode.org/project/migrate_visualize/-/tree/1.0.x#graphviz-server-install',
'%error' => $exception->getMessage(),
]));
}
catch (Exception $exception) {
catch (\Exception $exception) {
\Drupal::messenger()->addError($exception->getMessage());
}
}
Loading