/
AfxDslImplementation.php
45 lines (42 loc) · 1.25 KB
/
AfxDslImplementation.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
namespace Neos\Fusion\Afx\Dsl;
/*
* This file is part of the Neos.Fusion.Afx package.
*
* (c) Contributors of the Neos Project - www.neos.io
*
* This package is Open Source Software. For the full copyright and license
* information, please view the LICENSE file which was distributed with this
* source code.
*/
use Neos\Flow\Annotations as Flow;
use Neos\Fusion;
use Neos\Fusion\Core\DslInterface;
use Neos\Fusion\Afx\Service\AfxService;
use Neos\Fusion\Afx\Exception\AfxException;
use Neos\Fusion\Afx\Parser\AfxParserException;
/**
* Class Fusion AFX Dsl
*
* @Flow\Scope("singleton")
*/
class AfxDslImplementation implements DslInterface
{
/**
* Transpile the given dsl-code to fusion-code
*
* @param string $code
* @return string
* @throws Fusion\Exception
*/
public function transpile($code)
{
try {
return AfxService::convertAfxToFusion($code);
} catch (AfxException $afxException) {
throw new Fusion\Exception(sprintf('Error during AFX-transpilation: %s', $afxException->getMessage()));
} catch (AfxParserException $afxException) {
throw new Fusion\Exception(sprintf('Error during AFX-parsing: %s', $afxException->getMessage()));
}
}
}