ReferenceDescription.php
1 <?php
2 /**
3  * wCMF - wemove Content Management Framework
4  * Copyright (C) 2005-2020 wemove digital solutions GmbH
5  *
6  * Licensed under the terms of the MIT License.
7  *
8  * See the LICENSE file distributed with this work for
9  * additional information.
10  */
11 namespace wcmf\lib\persistence;
12 
15 
16 /**
17  * Instances of ReferenceDescription describe reference attributes of PersistentObjects
18  *
19  * @author ingo herwig <ingo@wemove.com>
20  */
22 
23  protected $otherType = '';
24  protected $otherName = '';
25 
26  /**
27  * Constructor.
28  * @param $name The name of the reference
29  * @param $otherType The name of the referenced type (must be the role name, @see RelationDescription)
30  * @param $otherName The name of the referenced attribute in the referenced type
31  */
32  public function __construct($name, $otherType, $otherName) {
33  $this->name = $name;
34  $this->otherType = $otherType;
35  $this->otherName = $otherName;
36  }
37 
38  /**
39  * Get the name of the referenced type
40  * @return String
41  */
42  public function getOtherType() {
43  return $this->otherType;
44  }
45 
46  /**
47  * Get the name of the referenced attribute in the referenced type
48  * @return String
49  */
50  public function getOtherName() {
51  return $this->otherName;
52  }
53 
54  /**
55  * Get the attribute name
56  * @return String
57  */
58  public function getName() {
59  return $this->name;
60  }
61 
62  /**
63  * Get the attribute type
64  * @return String
65  */
66  public function getType() {
67  $attribute = $this->getReferencedAttribute();
68  return $attribute->getType();
69  }
70 
71  /**
72  * Get the application specific tags that this attribute is tagged with
73  * @return Array of String
74  */
75  public function getTags() {
76  $attribute = $this->getReferencedAttribute();
77  return $attribute->getTags();
78  }
79 
80  /**
81  * Get the default value
82  * @return Mixed
83  */
84  public function getDefaultValue() {
85  $attribute = $this->getReferencedAttribute();
86  return $attribute->getDefaultValue();
87  }
88 
89  /**
90  * Get the validation type for the value
91  * @return String
92  */
93  public function getValidateType() {
94  $attribute = $this->getReferencedAttribute();
95  return $attribute->getValidateType();
96  }
97 
98  /**
99  * Get the description for the validation type
100  * @return String
101  */
102  public function getValidateDescription() {
103  $attribute = $this->getReferencedAttribute();
104  return $attribute->getValidateDescription();
105  }
106 
107  /**
108  * Check whether the attribute should be editable
109  * @return Boolean
110  */
111  public function getIsEditable() {
112  return false;
113  }
114 
115  /**
116  * Get the input type for the value
117  * @return String
118  */
119  public function getInputType() {
120  $attribute = $this->getReferencedAttribute();
121  return $attribute->getInputType();
122  }
123 
124  /**
125  * Get the display type for the value
126  * @return String
127  */
128  public function getDisplayType() {
129  $attribute = $this->getReferencedAttribute();
130  return $attribute->getDisplayType();
131  }
132 
133  /**
134  * Get the referenced attribute
135  * @return AttributeDescription instance
136  */
137  private function getReferencedAttribute() {
138  $mapper = ObjectFactory::getInstance('persistenceFacade')->getMapper($this->otherType);
139  return $mapper->getAttribute($this->otherName);
140  }
141 }
142 ?>
getTags()
Get the application specific tags that this attribute is tagged with.
getIsEditable()
Check whether the attribute should be editable.
getOtherName()
Get the name of the referenced attribute in the referenced type.
getDisplayType()
Get the display type for the value.
Persistence layer related interfaces and classes.
Definition: namespaces.php:42
getValidateDescription()
Get the description for the validation type.
getOtherType()
Get the name of the referenced type.
getValidateType()
Get the validation type for the value.
getInputType()
Get the input type for the value.
Instances of AttributeDescription describe attributes of PersistentObjects.
Instances of ReferenceDescription describe reference attributes of PersistentObjects.
static getInstance($name, $dynamicConfiguration=[])
__construct($name, $otherType, $otherName)
Constructor.
ObjectFactory implements the service locator pattern by wrapping a Factory instance and providing sta...