before_save file fails to copy via Module Installer

Hello,

I am trying to create a custom logic hook with the before_save class that auto generates a record ID for a custom module. However, each time I attempt to install my package through module loader I face an error saying that the before_save_class.php file failed to copy. I have checked syntax and permissions many times over, but can’t seem to figure out what the issue is.

The manifest file looks as such

$installdefs = array (
  'id' => 'project_AdvIncUpdates',
  'copy' =>
  array (
    0 =>
    array (
      'from' => '<basepath>/AdvIncUpdates',
      'to' => 'custom/modulebuilder/packages/AdvIncUpdates',
    ),
    1 =>
    array(
      'from' => '<basebath>/before_save_class.php',
      'to' => 'custom/modules/ao_Adverse_Incidents/before_save_class.php',
    ),
    2 =>
    array(
      'from' => '<basebath>/adverseIncidentsID.php',
      'to' => 'custom/Extension/modules/ao_Adverse_Incidents/Ext/LogicHooks/adverseIncidentsID.php',
    ),
  ),
);

and the before_save_class file itself looks like this

<?php

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

class before_save_class {

    /**
     * Before save hook does following:
     * 1. Auto Generates an Incident id
     * Format:AdvInc-{0000}
     * @global type $db
     * @param type $bean
     * @param type $event
     * @param type $arguments
     */
    public function before_save($bean, $event, $arguments) {
        global $db;
        if (!isset($bean->fetched_row['name'])) {
            $incidentCount = "Select count(*) as count FROM adverse_incidents";
            $result = $db->query($incidentCount);
            $result = $db->fetchByAssoc($result);
            $bean->name = 'AdvInc-'. str_pad($result['count'], 4, 0, STR_PAD_LEFT);
        }
    }

}

The error I receive simply looks like this

Any help or suggestions would be greatly appreciated.

Changing basebath to basepath might help.

Wow, I feel incredibly silly. Apparently, I’d been staring at it way too long. Thank you so much for taking the time!

Hello,

The correct way to install logic hook via manifest is by writing array in manifest.php

You can find more information here https://docs.suitecrm.com/developer/module-installer/