webCOMAND

cObject::after_approve()

Called after an object has been approved to the repository.

Prototype

void after_approve(mixed $data)

Parameters

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();
        }
    }
}

Related