1 | <?php |
||
10 | class Tree implements Buildable, Extension |
||
11 | { |
||
12 | const MACRO_METHOD = 'tree'; |
||
13 | |||
14 | /** |
||
15 | * @var Buildable |
||
16 | */ |
||
17 | private $strategy; |
||
18 | |||
19 | /** |
||
20 | * @var Fluent |
||
21 | */ |
||
22 | private $builder; |
||
23 | |||
24 | /** |
||
25 | * @param Fluent $builder |
||
26 | */ |
||
27 | 9 | public function __construct(Fluent $builder) |
|
31 | |||
32 | /** |
||
33 | * Enable extension |
||
34 | */ |
||
35 | public static function enable() |
||
53 | |||
54 | /** |
||
55 | * Sets the tree strategy to NestedSet, returning it for further customization. |
||
56 | * See {@link https://en.wikipedia.org/wiki/Nested_set_model} for more information on nested set trees. |
||
57 | * |
||
58 | * @return NestedSet |
||
59 | */ |
||
60 | 3 | public function asNestedSet() |
|
64 | |||
65 | /** |
||
66 | * Sets the tree strategy to MaterializedPath, returning it for further customization. |
||
67 | * See {@link https://bojanz.wordpress.com/2014/04/25/storing-hierarchical-data-materialized-path/} for |
||
68 | * more information on materialized path trees. |
||
69 | * |
||
70 | * @return MaterializedPath |
||
71 | */ |
||
72 | 2 | public function asMaterializedPath() |
|
76 | |||
77 | /** |
||
78 | * Sets the tree strategy to ClosureTable, returning it for further customization. |
||
79 | * See {@link https://coderwall.com/p/lixing/closure-tables-for-browsing-trees-in-sql} for more |
||
80 | * information on closure table trees. |
||
81 | * |
||
82 | * @return ClosureTable |
||
83 | */ |
||
84 | 2 | public function asClosureTable() |
|
88 | |||
89 | /** |
||
90 | * Execute the build process |
||
91 | */ |
||
92 | 4 | public function build() |
|
96 | |||
97 | /** |
||
98 | * @param Buildable $strategy |
||
99 | * |
||
100 | * @return Buildable |
||
101 | */ |
||
102 | 7 | protected function strategy(Buildable $strategy) |
|
106 | } |
||
107 |