| @@ 481-492 (lines=12) @@ | ||
| 478 | * @param Datastore_Interface $datastore |
|
| 479 | * @return object $this |
|
| 480 | **/ |
|
| 481 | public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) { |
|
| 482 | if ( $set_as_default && ! $this->has_default_datastore() ) { |
|
| 483 | return $this; // datastore has been overriden with a custom one - abort changing to a default one |
|
| 484 | } |
|
| 485 | $this->datastore = $datastore; |
|
| 486 | $this->has_default_datastore = $set_as_default; |
|
| 487 | ||
| 488 | foreach ( $this->fields as $field ) { |
|
| 489 | $field->set_datastore( $this->get_datastore(), true ); |
|
| 490 | } |
|
| 491 | return $this; |
|
| 492 | } |
|
| 493 | ||
| 494 | /** |
|
| 495 | * Get the DataStore instance |
|
| @@ 153-164 (lines=12) @@ | ||
| 150 | * |
|
| 151 | * @param Datastore_Interface $datastore |
|
| 152 | */ |
|
| 153 | public function set_datastore( Datastore_Interface $datastore, $set_as_default = false ) { |
|
| 154 | if ( $set_as_default && ! $this->has_default_datastore() ) { |
|
| 155 | return $this; // datastore has been overriden with a custom one - abort changing to a default one |
|
| 156 | } |
|
| 157 | $this->datastore = $datastore; |
|
| 158 | $this->has_default_datastore = $set_as_default; |
|
| 159 | ||
| 160 | foreach ( $this->groups as $group ) { |
|
| 161 | $group->set_datastore( $this->get_datastore(), true ); |
|
| 162 | } |
|
| 163 | return $this; |
|
| 164 | } |
|
| 165 | ||
| 166 | /** |
|
| 167 | * Retrieve all groups of fields. |
|