/** * Clears the dynamic cached data for a particular data object * @param DataObject $object */ public function clearDynamicCacheFor(DataObject $object) { $dynamicCache = SimpleCache::get_cache('DynamicPublisherCache'); if ($dynamicCache) { $clearUrls = array($object->Link()); if ($object->hasMethod('pagesAffectedByChanges')) { $affectedUrls = $object->pagesAffectedByChanges(); if (count($affectedUrls)) { foreach ($affectedUrls as $afUrl) { $clearUrls[] = $afUrl; } } } $clearUrls = array_unique($clearUrls); $baseUrl = $object->SiteID ? $object->Site()->getUrl() : Director::absoluteBaseURL(); foreach ($clearUrls as $absolute) { if (strpos($absolute, '://') === false) { $absolute = $baseUrl . '/' . trim($absolute, '/'); } $parts = parse_url($absolute); $host = $parts['host']; $path = '/index'; $path = isset($parts['path']) && $parts['path'] != '/' ? $parts['path'] : $path; $key = trim($parts['host'] . $path, '/'); $dynamicCache->delete($key); } } }
/** * Given a DataObject, get an actual SS_HTTPResponse of rendered HTML * @param DataObject $record * @return string The rendered HTML */ protected function getSampleForObject(DataObject $record) { $response = Director::test($record->Link()); if ($response->getStatusCode() === 200) { return $response->getBody(); } return false; }
/** * Return the normal link directly to this page. Once you visit this link, a 30x redirection * will take you to your final destination. */ public function regularLink($action = null) { return parent::Link($action); }