本文整理汇总了PHP中Pimcore\Model\Cache::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Cache::getInstance方法的具体用法?PHP Cache::getInstance怎么用?PHP Cache::getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Model\Cache
的用法示例。
在下文中一共展示了Cache::getInstance方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: portletFeedAction
public function portletFeedAction()
{
$dashboard = $this->getCurrentConfiguration();
$id = $this->getParam("id");
$cache = \Pimcore\Model\Cache::getInstance();
if ($cache) {
$cache->setLifetime(10);
\Zend_Feed_Reader::setCache($cache);
}
$portlet = array();
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 = array();
if ($feed) {
foreach ($feed as $entry) {
// display only the latest 11 entries
$count++;
if ($count > 10) {
break;
}
$entry = array("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(array("entries" => $entries));
}