| @@ 540-551 (lines=12) @@ | ||
| 537 | * @param Datastore_Interface $datastore |
|
| 538 | * @return object $this |
|
| 539 | **/ |
|
| 540 | public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) { |
|
| 541 | if ( $set_as_default && ! $this->has_default_datastore() ) { |
|
| 542 | return $this; // datastore has been overriden with a custom one - abort changing to a default one |
|
| 543 | } |
|
| 544 | $this->datastore = $datastore; |
|
| 545 | $this->has_default_datastore = $set_as_default; |
|
| 546 | ||
| 547 | foreach ( $this->fields as $field ) { |
|
| 548 | $field->set_datastore( $this->get_datastore(), true ); |
|
| 549 | } |
|
| 550 | return $this; |
|
| 551 | } |
|
| 552 | ||
| 553 | /** |
|
| 554 | * Get the DataStore instance |
|
| @@ 219-230 (lines=12) @@ | ||
| 216 | * |
|
| 217 | * @param Datastore_Interface $datastore |
|
| 218 | */ |
|
| 219 | public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) { |
|
| 220 | if ( $set_as_default && ! $this->has_default_datastore() ) { |
|
| 221 | return $this; // datastore has been overriden with a custom one - abort changing to a default one |
|
| 222 | } |
|
| 223 | $this->datastore = $datastore; |
|
| 224 | $this->has_default_datastore = $set_as_default; |
|
| 225 | ||
| 226 | foreach ( $this->groups as $group ) { |
|
| 227 | $group->set_datastore( $this->get_datastore(), true ); |
|
| 228 | } |
|
| 229 | return $this; |
|
| 230 | } |
|
| 231 | ||
| 232 | /** |
|
| 233 | * Return a clone of a field with hierarchy settings applied |
|