invalidateFrontendCache() public static method

Deprecation: : twig doesn't contain this same type of caching out of the box. Use https://github.com/asm89/twig-cache-extension instead
public static invalidateFrontendCache ( string $module = null, string $language = null )
$module string A specific module to clear the cache for.
$language string The language to use.
Example #1
0
 /**
  * @param array $item
  * @return int
  */
 public static function updateVideo(array $item)
 {
     BackendModel::invalidateFrontendCache('productsCache');
     return (int) BackendModel::getContainer()->get('database')->update('catalog_videos', $item, 'id = ?', array($item['id']));
 }
Example #2
0
 /**
  * Update a certain category
  *
  * @param array $item
  *
  * @return bool
  */
 public static function updateCategory(array $item)
 {
     return (bool) BackendModel::getContainer()->get('database')->update('galleria_categories', (array) $item, 'id = ?', array($item['id']));
     BackendModel::invalidateFrontendCache('galleria', BL::getWorkingLanguage());
 }
Example #3
0
 /**
  * @param array $item
  * @return int
  */
 public static function saveImage(array $item)
 {
     if (isset($item['id']) && self::existsImage($item['id'])) {
         self::updateImage($item);
     } else {
         $item['id'] = self::insertImage($item);
     }
     BackendModel::invalidateFrontendCache('agendaCache');
     return (int) $item['id'];
 }
Example #4
0
 /**
  * Updates one or more comments' status
  *
  * @param array  $ids    The id(s) of the comment(s) to change the status for.
  * @param string $status The new status.
  */
 public static function updateCommentStatuses($ids, $status)
 {
     // make sure $ids is an array
     $ids = (array) $ids;
     // loop and cast to integers
     foreach ($ids as &$id) {
         $id = (int) $id;
     }
     // create an array with an equal amount of questionmarks as ids provided
     $idPlaceHolders = array_fill(0, count($ids), '?');
     // get the items and their languages
     $items = (array) BackendModel::getContainer()->get('database')->getPairs('SELECT i.post_id, i.language
          FROM blog_comments AS i
          WHERE i.id IN (' . implode(', ', $idPlaceHolders) . ')', $ids, 'post_id');
     // only proceed if there are items
     if (!empty($items)) {
         // get the ids
         $itemIds = array_keys($items);
         // get the unique languages
         $languages = array_unique(array_values($items));
         // update records
         BackendModel::getContainer()->get('database')->execute('UPDATE blog_comments
              SET status = ?
              WHERE id IN (' . implode(', ', $idPlaceHolders) . ')', array_merge(array((string) $status), $ids));
         // recalculate the comment count
         self::reCalculateCommentCount($itemIds);
         // invalidate the cache for blog
         foreach ($languages as $language) {
             BackendModel::invalidateFrontendCache('Blog', $language);
         }
     }
 }
Example #5
0
 /**
  * Update a certain category
  *
  * @param array $item
  */
 public static function updateCategory(array $item)
 {
     // update faq category
     BackendModel::getContainer()->get('database')->update('faq_categories', $item, 'id = ?', array($item['id']));
     // update extra
     BackendModel::updateExtra($item['extra_id'], 'data', array('id' => $item['id'], 'extra_label' => 'Category: ' . $item['title'], 'language' => $item['language'], 'edit_url' => BackendModel::createURLForAction('EditCategory') . '&id=' . $item['id']));
     // invalidate faq
     BackendModel::invalidateFrontendCache('Faq', BL::getWorkingLanguage());
 }