1 | <?php |
||
17 | class PathBuilder |
||
18 | { |
||
19 | /** |
||
20 | * @var PathSegmentRegistry |
||
21 | */ |
||
22 | private $registry; |
||
23 | |||
24 | /** |
||
25 | * @param PathSegmentRegistry $registry |
||
26 | */ |
||
27 | public function __construct(PathSegmentRegistry $registry) |
||
31 | |||
32 | /** |
||
33 | * Build a path from an array of path segments. |
||
34 | * |
||
35 | * Segments demarcated by "%" characters will be interpreted as path |
||
36 | * segment *names* and their value will be resolved from the PathSegmentRegistry. |
||
37 | * |
||
38 | * Other segments will be interpreted literally. |
||
39 | * |
||
40 | * The following: |
||
41 | * |
||
42 | * ```` |
||
43 | * $path = $pathBuilder->build(array('%base%', 'hello', '%articles%')); |
||
44 | * ```` |
||
45 | * |
||
46 | * Will yield `/cms/hello/articleDirectory` where `%base%` is "cms" and |
||
47 | * `%articles` is "articleDirectory" |
||
48 | * |
||
49 | * @see Sulu\Component\DocumentManager\PathSegmentRegistry |
||
50 | * |
||
51 | * @param array $segments |
||
52 | * |
||
53 | * @return string |
||
54 | */ |
||
55 | public function build(array $segments) |
||
70 | |||
71 | /** |
||
72 | * @param string $segment |
||
73 | */ |
||
74 | private function buildSegment($segment) |
||
88 | } |
||
89 |