| @@ 68-70 (lines=3) @@ | ||
| 65 | * @return EEM_Base | EEM_Soft_Delete_Base |
|
| 66 | */ |
|
| 67 | public function model() { |
|
| 68 | if( ! $this->_model instanceof EEM_Base ) { |
|
| 69 | throw new EE_Error( sprintf( __( 'Cannot generate capability restrictions because model has not yet been set on the %s. Please ensure _construct_finalize() was called', 'event_espresso' ), get_class( $this ) ) ); |
|
| 70 | } |
|
| 71 | return $this->_model; |
|
| 72 | } |
|
| 73 | ||
| @@ 43-45 (lines=3) @@ | ||
| 40 | if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) { |
|
| 41 | $this->_model = $options_array['model']; |
|
| 42 | } |
|
| 43 | if (! $this->_model || ! $this->_model instanceof EEM_Base) { |
|
| 44 | throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", |
|
| 45 | "event_espresso"))); |
|
| 46 | } |
|
| 47 | if (isset($options_array['subsection_args'])) { |
|
| 48 | $subsection_args = $options_array['subsection_args']; |
|
| @@ 347-349 (lines=3) @@ | ||
| 344 | */ |
|
| 345 | public function save() |
|
| 346 | { |
|
| 347 | if (! $this->_model_object) { |
|
| 348 | throw new EE_Error(sprintf(__("Cannot save the model form's model object (model is '%s') because there is no model object set. You must either set it, or call receive_form_submission where it is set automatically", |
|
| 349 | "event_espresso"), get_class($this->_model))); |
|
| 350 | } |
|
| 351 | //ok so the model object is set. Just set it with the submitted form data |
|
| 352 | foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name => $field_value) { |
|
| @@ 1103-1105 (lines=3) @@ | ||
| 1100 | //error proof if the name has EEM in it |
|
| 1101 | $this->_model_name = str_replace('EEM', '', $this->_model_name); |
|
| 1102 | $this->_model = EE_Registry::instance()->load_model($this->_model_name); |
|
| 1103 | if (! $this->_model instanceof EEM_Base) { |
|
| 1104 | throw new EE_Error( |
|
| 1105 | sprintf( |
|
| 1106 | __( |
|
| 1107 | 'This string passed in to %s to represent a EEM_Base model class was not able to be used to instantiate the class. Please ensure that the string is a match for the EEM_Base model name (not including the EEM_ part). This was given: %s', |
|
| 1108 | 'event_espresso' |
|