problem with ghooks

Hi to all, i have a problem with a hook i’ve made.
in custom\modules\Projects i edited logic_hook


$hook_array = Array(); 
// position, file, function 
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(1,'after_save update account name','custom/modules/Projects/update_account_name_class.php', 'update_account_name_class', 'after_save_method');

then in custom\modules\Projects i’ve created the class update_account_name_class


<?php

    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
   
    class update_account_name_class
	{
		function after_save_method($bean, $event, $arguments)
		{
			$bean_projects=BeanFactory::getBean('Project',$bean->project_id);
			$bean_projects->load_relationship('accounts');
			$stringa_aziende ="";
			foreach ($bean_projects->accounts->getBeans() as $account) {
				file_put_contents('C:\SITI\delbarbaCRM\custom\modules\Projects\log3_.txt', print_r($account->name, true), FILE_APPEND);
				$stringa_aziende .=$account->name.", ";
			}
			$bean->nome_azienda_c = substr($stringa_aziende,0,-2);
		}
	}

But nothing happend. i’ve tried to put a die() after function declaration, but still nothing happens. what i’m missing?

thanks all

remove this


    if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

a hook is not an entry point.

thanks for the reply, but nothing changed. seems this file is getting ignored. I don’t get why but if i click save, the project get saved normaly, even if i put a die or a breakpoint in there.

Hhmm ok.

I use this technique when I am completely lost:

https://pgorod.github.io/Audit-File-Accesses/

I would see if its really being ignored entirely by putting a log line at the start of the function.

    class update_account_name_class
	{
		function after_save_method($bean, $event, $arguments)
		{
                  $GLOBALS['log']->debug("update_account_name_class - after_save_method is running");

Also I normally put the $hook_array file here:custom/Extension/modules//Ext/LogicHooks/logic_hooks.php

Did you up a quick repair? Otherwise, the hook won’t be picked up.