- ⌂ cObject
- Methods
- Constructor
- add_variant()
- after_approve()
- approve()
- as_array()
- before_approve()
- can_add_variant()
- can_delete_variant()
- can_edit_variant()
- can_reorder_variant()
- clone()
- delete()
- edit_variant()
- enum()
- get_active_object()
- get_all_variants()
- get_attributes()
- get_dimensions()
- get_dimension_with()
- get_parent()
- get_primary_cpath()
- get_variant()
- Keywords()
- lock_object()
- meta()
- requires_approve()
- reload_data()
- repo()
- revert()
- save()
- store()
- unlock_object()
- update_from_array()
- validate()
cObject::before_approve()
Called right before an object is approved to the repository. The object's fields will be set to what will be written to the repository, but has not been written yet.
Prototype
mixed before_approve(array $options)
Parameters
- options - Options that should be passed to parent::approve() if called.
Return
The value that is returned will be passed to after_approve() for use after the object is approved.
Example
<?php
namespace com_example_www\models;
class Contact extends \io_comand_repo\models\Content {
public function before_approve(array $options): mixed {
// approve embedded notes, even if they haven't updated
$notes_to_approve = [];
foreach($this->Notes as $note) {
if($note->Update) {
$notes_to_approve []= $note;
}
}
return [
'options' => $options,
'notes_to_approve' => $notes_to_approve,
];
}
public function after_approve(mixed $data): void {
// approve embedded notes, even if they haven't updated
foreach($data['notes_to_approve'] as $note) {
$note->approve();
}
}
}