4545 */
4646class VisualizerTask extends HttpTask
4747{
48- public const FORMAT_EPS = 'eps ' ;
49- public const FORMAT_PNG = 'png ' ;
50- public const FORMAT_PUML = 'puml ' ;
51- public const FORMAT_SVG = 'svg ' ;
52- public const SERVER = 'http://www.plantuml.com/plantuml ' ;
53- public const STATUS_OK = 200 ;
54- public const XSL_CALLS = __DIR__ . '/calls.xsl ' ;
55- public const XSL_FOOTER = __DIR__ . '/footer.xsl ' ;
56- public const XSL_HEADER = __DIR__ . '/header.xsl ' ;
57- public const XSL_TARGETS = __DIR__ . '/targets.xsl ' ;
48+ protected const ARROWS_HORIZONTAL = 'horizontal ' ;
49+ protected const ARROWS_VERTICAL = 'vertical ' ;
50+ protected const FORMAT_EPS = 'eps ' ;
51+ protected const FORMAT_PNG = 'png ' ;
52+ protected const FORMAT_PUML = 'puml ' ;
53+ protected const FORMAT_SVG = 'svg ' ;
54+ protected const SERVER = 'http://www.plantuml.com/plantuml ' ;
55+ protected const STATUS_OK = 200 ;
56+ protected const XSL_CALLS = __DIR__ . '/calls.xsl ' ;
57+ protected const XSL_FOOTER = __DIR__ . '/footer.xsl ' ;
58+ protected const XSL_HEADER = __DIR__ . '/header.xsl ' ;
59+ protected const XSL_TARGETS = __DIR__ . '/targets.xsl ' ;
5860
5961 /**
6062 * @var string Diagram format
@@ -71,6 +73,11 @@ class VisualizerTask extends HttpTask
7173 */
7274 protected $ server ;
7375
76+ /**
77+ * @var string Arrows' direction
78+ */
79+ protected $ direction ;
80+
7481 /**
7582 * Setting some default values and checking requirements
7683 */
@@ -92,6 +99,7 @@ public function init(): void
9299 }
93100 $ this ->setFormat (VisualizerTask::FORMAT_PNG );
94101 $ this ->setServer (VisualizerTask::SERVER );
102+ $ this ->setDirection (VisualizerTask::ARROWS_VERTICAL );
95103 }
96104
97105 /**
@@ -170,6 +178,7 @@ protected function transformToPuml(File $buildfile, string $xslFile): string
170178 $ xsl = $ this ->loadXmlFile ($ xslFile );
171179
172180 $ processor = new XSLTProcessor ();
181+ $ processor ->setParameter ('' , 'direction ' , $ this ->getDirection ());
173182 $ processor ->importStylesheet ($ xsl );
174183
175184 return $ processor ->transformToXml ($ xml ) . PHP_EOL ;
@@ -259,7 +268,7 @@ public function getDestination(): ?string
259268 *
260269 * @return \Phing\Task\Ext\VisualizerTask
261270 */
262- public function setDestination (?string $ destination ): VisualizerTask
271+ public function setDestination (?string $ destination ): self
263272 {
264273 $ this ->destination = $ destination ;
265274
@@ -354,7 +363,7 @@ public function getServer(): string
354363 *
355364 * @return \Phing\Task\Ext\VisualizerTask
356365 */
357- public function setServer (string $ server ): VisualizerTask
366+ public function setServer (string $ server ): self
358367 {
359368 if (!filter_var ($ server , FILTER_VALIDATE_URL )) {
360369 $ exceptionMessage = 'Invalid PlantUml server ' ;
@@ -366,6 +375,26 @@ public function setServer(string $server): VisualizerTask
366375 return $ this ;
367376 }
368377
378+ /**
379+ * @return string
380+ */
381+ public function getDirection (): string
382+ {
383+ return $ this ->direction ;
384+ }
385+
386+ /**
387+ * @param string $direction
388+ *
389+ * @return \Phing\Task\Ext\VisualizerTask
390+ */
391+ public function setDirection (string $ direction ): self
392+ {
393+ $ this ->direction = $ direction === self ::ARROWS_HORIZONTAL ? self ::ARROWS_HORIZONTAL : self ::ARROWS_VERTICAL ;
394+
395+ return $ this ;
396+ }
397+
369398 /**
370399 * Receive server's response
371400 *
0 commit comments