• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Extending CacheRebuilder

guiltar

Well-known member
#1
Is it possible to extend XenForo_CacheRebuilder_Abstract in order to add new caches?
All I need is equivallent to adding
PHP:
'Blog' => 'AddonBlog_CacheRebuilder_Blog',
to the $builders variable. By default it is
PHP:
    public static $builders = array(
        'AdminTemplate' => 'XenForo_CacheRebuilder_AdminTemplate',
        'DailyStats' => 'XenForo_CacheRebuilder_DailyStats',
        'EmailTemplate' => 'XenForo_CacheRebuilder_EmailTemplate',
        'Forum' => 'XenForo_CacheRebuilder_Forum',
        'ImportAdminTemplate' => 'XenForo_CacheRebuilder_ImportAdminTemplate',
        'ImportEmailTemplate' => 'XenForo_CacheRebuilder_ImportEmailTemplate',
        'ImportMasterData' => 'XenForo_CacheRebuilder_ImportMasterData',
        'ImportPhrase' => 'XenForo_CacheRebuilder_ImportPhrase',
        'ImportTemplate' => 'XenForo_CacheRebuilder_ImportTemplate',
        'Phrase' => 'XenForo_CacheRebuilder_Phrase',
        'Permission' => 'XenForo_CacheRebuilder_Permission',
        'Poll' => 'XenForo_CacheRebuilder_Poll',
        'SearchIndex' => 'XenForo_CacheRebuilder_SearchIndex',
        'Template' => 'XenForo_CacheRebuilder_Template',
        'Thread' => 'XenForo_CacheRebuilder_Thread',
        'User' => 'XenForo_CacheRebuilder_User'
    );
 

James

Well-known member
#2
Try creating a listener on the init_dependencies hook that does something like this:
PHP:
<?php

class AddonBlog_Listener
{
    /**
    * Listen to the "init_dependencies" code event.
    *
    * @param XenForo_Dependencies_Abstract $dependencies
    * @param array $data
    */
	
    public static function init(XenForo_Dependencies_Abstract $dependencies, array $data)
    {
        XenForo_CacheRebuilder_Abstract::$builders  += array(
            'Blog' => 'AddonBlog_CacheRebuilder_Blog'
        );
    }
}
 

Robbo

Well-known member
#3
Yeah, it is a public static variable for that exact reason. Personally when I add things like this though I like to do it when that class is loaded instead of on init.