I am new programming in SuiteCRM and I need to know how I can call classes in a logic hook; for example:
for this example, the file that contains the class “example_class” is in the path: /custom/new_class/example_class.php and my custom logic hook is in the path: /custom/new_logic/my_logic_after_save.php
These are sample data, what interests me is knowing how it is handled
class example_class
{
public $variable = "something value";
public function print_log()
{
$GLOBALS['log']->info($variable);
}
}
//my_logic_after_save.php
include '../custom/new_class/example_class.php';
class my_logic_after_save_class
{
function my_logic_after_save_method(&$bean, $event, $arguments)
{
$example = new example_class();
$example->print_log();
}
}
I’m trying to do it this way but it doesn’t work, thanks for your help.
Thanks for you reply, i’m sure that my hook is being called; the file logic_hook in custom/extension contains:
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(1, 'after_save', 'custom/new_logic/my_logic_after_save.php','my_logic_after_save_class', 'my_logic_after_save_method');
?>
what I need is to know how I invoke class methods within a logic hook, because the way I am doing it does not work
So my logic hook is executed properly, what I have not managed to do is find the class that I call in the include, because when I create the object of this class does not recognize it.
Basically - if you have a PHP error, you have a message in the PHP log. If you don’t, I don’t see why your code doesn’t work, sorry. It looks correct to me on a first glance.