本文整理匯總了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));
}