How is `BHaml` a Module?

I was tracing some code with the intent of discovering where the template renders like BHaml, BTwig, etc. were added to the system and bootstrapped. A debug backtrace in the BHaml bootstrap method

#0  BHAML::bootstrap()
#1  call_user_func(BHAML::bootstrap) called at [/Users/alanstorm/Sites2014/selvana-alpha-all.dev/core/FCom/Core/buckyball/com/module.php:1260]
#2  BModule->bootstrap() called at [/Users/alanstorm/Sites2014/selvana-alpha-all.dev/core/FCom/Core/buckyball/com/module.php:586]
#3  BModuleRegistry->bootstrap() called at [/Users/alanstorm/Sites2014/selvana-alpha-all.dev/core/FCom/Core/buckyball/com/core.php:221]
#4  BApp->run() called at [/Users/alanstorm/Sites2014/selvana-alpha-all.dev/core/FCom/Core/Main.php:34]
#5  FCom_Core_Main->run(FCom_Frontend) called at [/Users/alanstorm/Sites2014/selvana-alpha-all.dev/core/index.php:9]

pointed me towards towards the main module bootstrap loop.

#File: FCom/Core/buckyball/com/module.php
class BModuleRegistry {
    foreach ($this->_modules as $mod) {

This is a little confusing — at first glance it appears that a Fulleron module is something in the FCom/* folder hierarchy (or in local or dlc), with a manifest configuration. This is obiously incorrect since the BHaml class doesn't exist in these folders, and isn't mentioned in any of the existing module's manifest.yml files.

Is a special case made for the classes in core/FCom/Core/buckyball/plugins/*? Are all these automatically considered modules? If so, where does this happen? Are there other "special" folders/classes that are treated like modules? (i.e. Where are modules added to the registry's _modules array?)

1 Answer


The plugins were originally shipped with Buckyball library, and were part of its hierarchy. They are regular modules, the same way as others, just located in Buckyball file tree for historical reasons. I didn't know where things will go, and whether Buckyball will ever be used on its own, so they've remained bundled with Buckyball. Also, there's a logical distinction in that they are small and don't provide independent functionality, to be called modules.

As of where they're loaded, it happens together with other module directories, in FCom_Core_Main::initModules:

        if (defined('BUCKYBALL_ROOT_DIR')) {
            $this->_modulesDirs[] = BUCKYBALL_ROOT_DIR.'/plugins';
            // if minified version used, need to load plugins manually
        $this->_modulesDirs[] = $dirConf['storage_dir'].'/custom'; // Custom module
        $this->_modulesDirs[] = $dirConf['local_dir'].'/*/*'; // Local modules
        $this->_modulesDirs[] = $dirConf['dlc_dir'].'/*/*'; // Downloaded modules
        $this->_modulesDirs[] = $dirConf['root_dir'].'/FCom/*'; // Core modules

Hope this helps,