Equivalent to 'eventListener' in PHP

0

I have a series of PHP classes that build my HTML structures based on Bootstrap CSS already added with their respective actions in Javascript, example this call:

$VIDB_button = new \vidbModel\buttonElement();
$btn = $VIDB_button->color('primary')->content('Salvar')->addicionalClassnames('pull-right exec-save-new-company')->event('submit_fake_form')->calls('caller|classname|Classe|metodo')->actions('closeClosestModalOnSuccess|primary-modal|SweetAlertByResponse')->dataType('json')->event_post_content(null)->type('button')->button(0);

This method makes a button with the actions of submitting the form that it is in, already indicate the data concatenated to the POST, indicate the JS method that will close the modal that the form is in, and respond in a SweetAlert result, indicates that response must be json, and the calls method indicates which PHP methods should be called when submitting the form.

Well, I have a small problem is that the methods need to be started in a specific order for this to work, ie if I change anything in the order of the call something does not work right.

I would like to know how to 'listen' to a method that has been called, to make cadence mandatory and to return an error if something is out of place, eg

'To hear that the button class was called' or 'to hear that the calls method of the buttons class was called before event , and thus to inform a error the correct order', something as the following hypothetical function:

class classe {

    public function observar(){

        if(ClasseAnterior::metodo_observado() == 'foi_chamado'){
            \verificar a execução do metodo_observado(), poder executar algo antes dele, e depois confirmar a execução do mesmo 
        }

    }

}
  

There is something 'natural' about PHP to monitor / hear method shots and   classes?

     

If not, how could something related be created?

     

If there is no way to create something related, what would be a viable option   to have a similar result?

    
asked by anonymous 30.10.2017 / 12:34

0 answers