getInstance() публичный статический Метод

Returns a instance of the cache, if the instance isn't available it creates a new one
public static getInstance ( ) : Zend_Cache_Core | Zend_Cache_Frontend
Результат Zend_Cache_Core | Zend_Cache_Frontend
Пример #1
0
 public function portletFeedAction()
 {
     $dashboard = $this->getCurrentConfiguration();
     $id = $this->getParam("id");
     $cache = \Pimcore\Cache::getInstance();
     if ($cache) {
         $cache->setLifetime(10);
         \Zend_Feed_Reader::setCache($cache);
     }
     $portlet = [];
     foreach ($dashboard["positions"] as $col) {
         foreach ($col as $row) {
             if ($row['id'] == $id) {
                 $portlet = $row;
             }
         }
     }
     $feedUrl = $portlet['config'];
     $feed = null;
     if (!empty($feedUrl)) {
         try {
             $feed = \Zend_Feed_Reader::import($feedUrl);
         } catch (\Exception $e) {
             \Logger::error($e);
         }
     }
     $count = 0;
     $entries = [];
     if ($feed) {
         foreach ($feed as $entry) {
             // display only the latest 11 entries
             $count++;
             if ($count > 10) {
                 break;
             }
             $entry = ["title" => $entry->getTitle(), "description" => $entry->getDescription(), 'authors' => $entry->getAuthors(), 'link' => $entry->getLink(), 'content' => $entry->getContent()];
             foreach ($entry as &$content) {
                 $content = strip_tags($content, "<h1><h2><h3><h4><h5><p><br><a><img><div><b><strong><i>");
                 $content = preg_replace('/on([a-z]+)([ ]+)?=/i', "data-on\$1=", $content);
             }
             $entries[] = $entry;
         }
     }
     $this->_helper->json(["entries" => $entries]);
 }