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

Extending CacheRebuilder

Discussion in 'XenForo Development Discussions' started by guiltar, Dec 9, 2011.

  1. guiltar

    guiltar Well-Known Member

    Is it possible to extend XenForo_CacheRebuilder_Abstract in order to add new caches?
    All I need is equivallent to adding
    'Blog' => 'AddonBlog_CacheRebuilder_Blog',
    to the $builders variable. By default it is
        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'
  2. James

    James Well-Known Member

    Try creating a listener on the init_dependencies hook that does something like this:

    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'
    guiltar likes this.
  3. Robbo

    Robbo Well-Known Member

    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.
    James likes this.
  4. Fuhrmann

    Fuhrmann Well-Known Member

  5. guiltar

    guiltar Well-Known Member

Share This Page