public function control_panel__post_publish($publish_data)
 {
     // check that caching is turned on
     if (!$this->core->isEnabled()) {
         return;
     }
     // we only need one key from the hook's value
     $file = $publish_data['file'];
     // update the cache
     _Cache::update();
     ContentService::loadCache(true);
     // grab data
     $triggers = $this->fetchConfig('publish_invalidation', array(), 'is_array', false, false);
     $content = Content::find(Path::tidy(str_replace(Config::getContentRoot(), '/', $file)));
     if ($triggers && $content) {
         foreach ($triggers as $trigger) {
             $folders = Parse::pipeList(array_get($trigger, 'folder', null));
             $key = array_get($trigger, 'key', null);
             if (!$folders || !$key) {
                 // not checking this
                 continue;
             }
             // check
             $invalidate = false;
             foreach ($folders as $folder) {
                 if ($folder === "*" || $folder === "/*") {
                     // include all
                     $invalidate = true;
                     break;
                 } elseif (substr($folder, -1) === "*") {
                     // wildcard check
                     if (strpos($content['_folder'], substr($folder, 0, -1)) === 0) {
                         $invalidate = true;
                         break;
                     }
                 } else {
                     // plain check
                     if ($folder == $content['_folder']) {
                         $invalidate = true;
                         break;
                     }
                 }
             }
             // invalidate if needed
             if ($invalidate) {
                 $this->core->deleteByKey(Parse::pipeList($key));
             }
         }
     }
 }
Пример #2
0
|--------------------------------------------------------------------------
|
| Numerous tag variables, helpers, and other config-dependent options
| need to be loaded *before* the page is parsed.
|
*/
Statamic::setDefaultTags();
// mark milestone for debug panel
Debug::markMilestone('app defaults set');
/*
|--------------------------------------------------------------------------
| Caching
|--------------------------------------------------------------------------
|gt
| Look for updated content to cache
|
*/
_Cache::update();
//_Cache::dump();
// mark milestone for debug panel
Debug::markMilestone('caches updated');
/*
|--------------------------------------------------------------------------
| The Routes
|--------------------------------------------------------------------------
|
| Route it up fellas!
|
*/
require_once __DIR__ . '/routes.php';
return $app;