1: <?php
2:
3: namespace Charcoal\Property;
4:
5: use InvalidArgumentException;
6:
7:
8: use Charcoal\Property\PropertyInterface;
9: use Charcoal\Property\StructureProperty;
10: use Charcoal\Property\TemplateProperty;
11:
12: 13: 14:
15: class TemplateOptionsProperty extends StructureProperty
16: {
17: 18: 19: 20: 21:
22: public function type()
23: {
24: return 'template-options';
25: }
26:
27: 28: 29: 30: 31: 32: 33: 34:
35: public function addStructureInterface($interface)
36: {
37: if ($interface instanceof TemplateProperty) {
38: $choice = $interface->choice($interface->val());
39: if (isset($choice['controller'])) {
40: $interface = $choice['controller'];
41: } elseif (isset($choice['template'])) {
42: $interface = $choice['template'];
43: } else {
44: throw new InvalidArgumentException(
45: 'Template structure interface invalid'
46: );
47: }
48: }
49:
50: return parent::addStructureInterface($interface);
51: }
52: }
53: