public function getHooksDefinitionsFromFiles($module, $byFiles = true)
    {
        $modulesList = array_keys($this->getEntryPoint()->getBeansList());
        if (!in_array($module, $modulesList)) {
            throw new BeanNotFoundException("$module is not a valid module name");
        }

        $hooks = array();

        // Create a new find to locate all the files where hooks could be defined
        $beanManager = new Bean($this->getEntryPoint());
        $bean = $beanManager->newBean($module);

        $files = array();
        // process the main file
        $mainFile = 'custom/modules/' . $beanManager->getModuleDirectory($module) . '/logic_hooks.php';
        if (file_exists($mainFile)) {
            $files[] = $mainFile;
        }

        // find files in ExtDir
        $customExtDir = 'custom/Extension/modules/' . $beanManager->getModuleDirectory($module) . '/Ext/LogicHooks/';
        if (is_dir($customExtDir)) {
            $finder = new Finder();
            $finder->files()->in($customExtDir)->name('*.php');
            foreach ($finder as $file) {
                $files[] = $customExtDir . $file->getRelativePathname();
            }
        }

        // read file and exit as soon as we find one
        $hooksDefs = array();
        foreach ($files as $file) {
            if ($byFiles === true) {
                $hook_array = array();
            }
            require($file);
            $hooksDefs[$file] = $hook_array;
        }

        return ($byFiles === true ? $hooksDefs : $hook_array);
    }