Welcome Guest, Not a member yet? Register   Sign In
Using Event file
#3

(03-23-2020, 09:06 AM)MGatner Wrote: You need to pass a valid callback: https://www.php.net/manual/en/language.t...llable.php
If you're going to use the array format it needs to be [$object, $method] where object is an instance or a class name. For example if you have "app/Libraries/Compress.php" you could use something like:
Events::on('pre_system', ['App\Libraries\Compress', 'compresstest']);


Thanks! I solved the problem using this

Events.php

PHP Code:
<?php namespace Config;

use 
CodeIgniter\Events\Events;
use 
App\Eventos\Compress;

$Compress = new Compress();

Events::on('pre_system', [$Compress'Compression']); 

Compress.php

PHP Code:
<?php namespace App\Eventos;

class 
Compress {
public function 
Compression(){

echo 
"test";

  }



Anyway, thank you very much!
Reply


Messages In This Thread
Using Event file - by EtZeta - 03-16-2020, 09:28 AM
RE: Using Event file - by MGatner - 03-23-2020, 09:06 AM
RE: Using Event file - by EtZeta - 03-23-2020, 11:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB