63 $result = $arrayOrValue;
64 foreach ($this->swapClasses as $original => $replacement) {
65 if (\is_array($arrayOrValue)) {
68 $result = $this->
swapValue($result, $original, $replacement);
76 foreach ($values as $k => $v) {
80 $result[$k] = $this->
swapValue($v, $original, $replacement);
90 public function parse($modelClass) {
91 $instance =
new $modelClass();
101 if (\
sizeof(
$yuml) > 0) {
102 $this->yuml =
$yuml[0];
105 foreach ($properties as $property) {
106 $propName = $property->getName();
108 $this->fieldNames[$propName] = $fieldName;
109 $this->memberNames[$fieldName] = $propName;
114 if (! $serializable) {
115 $this->notSerializableMembers[] = $propName;
122 if (\array_search($fieldName,
$primaryKeys) !==
false && DbTypes::isInt($type)) {
127 $this->nullableMembers[] = $propName;
129 $this->fieldTypes[$propName] = $type;
130 $accesseur =
'set' . \ucfirst($propName);
131 if (! isset($this->accessors[$fieldName]) && \method_exists($modelClass, $accesseur)) {
132 $this->accessors[$fieldName] = $accesseur;
136 $this->primaryKeys[$pk] = $this->fieldNames[$pk] ?? $pk;
151 $result[
'#transformers'] = [];
153 if (isset($this->yuml))
154 $result[
'#yuml'] = $this->yuml->getPropertiesAndValues();
155 foreach ($this->oneToManyMembers as $member => $annotation) {
156 $result[
'#oneToMany'][$member] = $annotation->getPropertiesAndValues();
158 foreach ($this->manyToManyMembers as $member => $annotation) {
159 $result[
'#manyToMany'][$member] = $annotation->getPropertiesAndValues();
162 foreach ($this->joinTableMembers as $member => $annotation) {
163 $result[
'#joinTable'][$member] = $annotation->getPropertiesAndValues();
166 if (\class_exists(
'Ubiquity\\contents\\transformation\\TransformersManager')) {
168 foreach ($this->transformers as $member => $annotation) {
169 $goodTransformer =
false;
170 if (\array_search($member, $this->notSerializableMembers,
false) !==
false) {
171 throw new TransformerException(sprintf(
'%s member is not serializable and does not supports transformers!', $member));
174 if ($trans ==
null) {
175 throw new TransformerException(sprintf(
'%s value is not a declared transformer.', $annotation->name));
178 if (\is_subclass_of($trans, $transInterface,
true)) {
179 $goodTransformer =
true;
180 $result[
'#transformers'][$transType][$member] = $trans;
183 if (! $goodTransformer) {
184 throw new TransformerException(sprintf(
'%s does not implements %s', $trans,
'TransformerInterfaces'));
190 foreach ($this->joinColumnMembers as $member => $annotation) {
191 $result[
'#joinColumn'][$member] = $this->
swapValues($annotation->getPropertiesAndValues());
192 $result[
'#invertedJoinColumn'][$annotation->name] = [
194 'className' => $this->
swapValues($annotation->className)