Mercurial > hg > isophonics-drupal-site
comparison vendor/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php @ 12:7a779792577d
Update Drupal core to v8.4.5 (via Composer)
author | Chris Cannam |
---|---|
date | Fri, 23 Feb 2018 15:52:07 +0000 |
parents | 4c8ae668cc8c |
children |
comparison
equal
deleted
inserted
replaced
11:bfffd8d7479a | 12:7a779792577d |
---|---|
117 * @throws \BadMethodCallException When no persistent field exists by that name. | 117 * @throws \BadMethodCallException When no persistent field exists by that name. |
118 * @throws \InvalidArgumentException When the wrong target object type is passed to an association. | 118 * @throws \InvalidArgumentException When the wrong target object type is passed to an association. |
119 */ | 119 */ |
120 private function set($field, $args) | 120 private function set($field, $args) |
121 { | 121 { |
122 $this->initializeDoctrine(); | |
123 | |
124 if ($this->cm->hasField($field) && !$this->cm->isIdentifier($field)) { | 122 if ($this->cm->hasField($field) && !$this->cm->isIdentifier($field)) { |
125 $this->$field = $args[0]; | 123 $this->$field = $args[0]; |
126 } else if ($this->cm->hasAssociation($field) && $this->cm->isSingleValuedAssociation($field)) { | 124 } else if ($this->cm->hasAssociation($field) && $this->cm->isSingleValuedAssociation($field)) { |
127 $targetClass = $this->cm->getAssociationTargetClass($field); | 125 $targetClass = $this->cm->getAssociationTargetClass($field); |
128 if (!($args[0] instanceof $targetClass) && $args[0] !== null) { | 126 if (!($args[0] instanceof $targetClass) && $args[0] !== null) { |
144 * | 142 * |
145 * @throws \BadMethodCallException When no persistent field exists by that name. | 143 * @throws \BadMethodCallException When no persistent field exists by that name. |
146 */ | 144 */ |
147 private function get($field) | 145 private function get($field) |
148 { | 146 { |
149 $this->initializeDoctrine(); | |
150 | |
151 if ( $this->cm->hasField($field) || $this->cm->hasAssociation($field) ) { | 147 if ( $this->cm->hasField($field) || $this->cm->hasAssociation($field) ) { |
152 return $this->$field; | 148 return $this->$field; |
153 } else { | 149 } |
154 throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'"); | 150 |
155 } | 151 throw new \BadMethodCallException("no field with name '".$field."' exists on '".$this->cm->getName()."'"); |
156 } | 152 } |
157 | 153 |
158 /** | 154 /** |
159 * If this is an inverse side association, completes the owning side. | 155 * If this is an inverse side association, completes the owning side. |
160 * | 156 * |
188 * @throws \BadMethodCallException | 184 * @throws \BadMethodCallException |
189 * @throws \InvalidArgumentException | 185 * @throws \InvalidArgumentException |
190 */ | 186 */ |
191 private function add($field, $args) | 187 private function add($field, $args) |
192 { | 188 { |
193 $this->initializeDoctrine(); | |
194 | |
195 if ($this->cm->hasAssociation($field) && $this->cm->isCollectionValuedAssociation($field)) { | 189 if ($this->cm->hasAssociation($field) && $this->cm->isCollectionValuedAssociation($field)) { |
196 $targetClass = $this->cm->getAssociationTargetClass($field); | 190 $targetClass = $this->cm->getAssociationTargetClass($field); |
197 if (!($args[0] instanceof $targetClass)) { | 191 if (!($args[0] instanceof $targetClass)) { |
198 throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'"); | 192 throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'"); |
199 } | 193 } |
237 * | 231 * |
238 * @throws \BadMethodCallException | 232 * @throws \BadMethodCallException |
239 */ | 233 */ |
240 public function __call($method, $args) | 234 public function __call($method, $args) |
241 { | 235 { |
236 $this->initializeDoctrine(); | |
237 | |
242 $command = substr($method, 0, 3); | 238 $command = substr($method, 0, 3); |
243 $field = lcfirst(substr($method, 3)); | 239 $field = lcfirst(substr($method, 3)); |
244 if ($command == "set") { | 240 if ($command == "set") { |
245 $this->set($field, $args); | 241 $this->set($field, $args); |
246 } else if ($command == "get") { | 242 } else if ($command == "get") { |