XF 2.0 How do I call rebuildNoticeCache()

mmcguire

Member
I have an external script that sets a notice active directly in the database.

SQL:
update xf_notice set active = 1 where notice_id = 3;

Now I need to know how I can call rebuildNoticeCache() so the notice shows up on the site. Any help is appreciated.
 
PHP:
\XF::repository('XF:Notice')->rebuildNoticeCache();

Or better yet have the script use the entity system instead of setting it directly in the database:
PHP:
$notice = \XF::em()->find('XF:Notice', 3);
$notice->active = true;
$notice->save();

Either way you'll have to bootstrap XF first if you haven't already:
PHP:
<?php

// bootstrap framework
$dir = __DIR__;
require($dir . '/src/XF.php');

\XF::start($dir);
 
Back
Top Bottom