本文整理汇总了PHP中eZContentCacheManager::nodeListForObject方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentCacheManager::nodeListForObject方法的具体用法?PHP eZContentCacheManager::nodeListForObject怎么用?PHP eZContentCacheManager::nodeListForObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentCacheManager
的用法示例。
在下文中一共展示了eZContentCacheManager::nodeListForObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
function execute($process, $event)
{
// get object being published
$parameters = $process->attribute('parameter_list');
$objectId = $parameters['object_id'];
eZDebug::writeDebug('Expire remote cache event begins execution for object ' . $objectId);
$ini = eZINI::instance('ezworkflowcollection.ini');
$object = eZContentObject::fetch($objectId);
if ($object != null) {
if ($ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireOnlyObjectNodes') == 'enabled') {
// basic version
// get list of nodes this object is published with
$assigned_nodes = $object->attribute('assigned_nodes');
} else {
// smart-cache enabled version
// get list of nodes whose view-cache is expired
$assigned_nodes = array();
eZContentCacheManager::nodeListForObject($object, true, eZContentCacheManager::CLEAR_DEFAULT, $assigned_nodes, $handledObjectList);
foreach ($assigned_nodes as $i => $nodeID) {
$assigned_nodes[$i] = eZContentObjectTreeNode::fetch($nodeID);
}
}
$domains = $ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireDomains');
foreach ($assigned_nodes as $assigned_node) {
// for every node, call eZHTTPCacheManager to clean the remote cache
$url = $assigned_node->urlAlias();
if (is_array($domains) && (count($domains) > 1 || count($domains) > 0 && $domains[0] != '')) {
eZURI::transformURI($url);
foreach ($domains as $domain) {
eZHTTPCacheManager::execute($domain . $url);
}
} else {
eZURI::transformURI($url, false, 'full');
eZHTTPCacheManager::execute($url);
}
}
} else {
eZDebug::writeError('Expire remote cache event triggered for inexisting object: ' . $objectId);
return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
}
return eZWorkflowType::STATUS_ACCEPTED;
}
示例2: generateObjectViewCache
static function generateObjectViewCache($objectID)
{
// Generate the view cache
$ini = eZINI::instance();
$object = eZContentObject::fetch($objectID);
$user = eZUser::currentUser();
eZDebug::accumulatorStart('generate_cache', '', 'Generating view cache');
if ($ini->variable('ContentSettings', 'PreViewCache') == 'enabled') {
$preCacheSiteaccessArray = $ini->variable('ContentSettings', 'PreCacheSiteaccessArray');
$currentSiteAccess = $GLOBALS['eZCurrentAccess'];
// This is the default view parameters for content/view
$viewParameters = array('offset' => false, 'year' => false, 'month' => false, 'day' => false, 'namefilter' => false);
if (is_array($preCacheSiteaccessArray) && count($preCacheSiteaccessArray) > 0) {
foreach ($preCacheSiteaccessArray as $changeToSiteAccess) {
$newSiteAccess = $currentSiteAccess;
$newSiteAccess['name'] = $changeToSiteAccess;
unset($newSiteAccess['uri_part']);
//eZSiteAccess::load() will take care of setting correct one
eZSiteAccess::load($newSiteAccess);
$tpl = eZTemplate::factory();
// Get the sitedesign and cached view preferences for this siteaccess
$siteini = eZINI::instance('site.ini');
$cachedViewPreferences = $siteini->variable('ContentSettings', 'CachedViewPreferences');
$language = false;
// Needs to be specified if you want to generate the cache for a specific language
$viewMode = 'full';
$assignedNodes = $object->assignedNodes();
foreach ($assignedNodes as $node) {
// We want to generate the cache for the specified user
$previewCacheUsers = $ini->variable('ContentSettings', 'PreviewCacheUsers');
foreach ($previewCacheUsers as $previewCacheUserID) {
// If the text is 'anon' we need to fetch the Anonymous user ID.
if ($previewCacheUserID === 'anonymous') {
$previewCacheUserID = $siteini->variable("UserSettings", "AnonymousUserID");
$previewCacheUser = eZUser::fetch($previewCacheUserID);
} else {
if ($previewCacheUserID === 'current') {
$previewCacheUser = $user;
} else {
$previewCacheUser = eZUser::fetch($previewCacheUserID);
}
}
if (!$previewCacheUser) {
continue;
}
// Before we generate the view cache we must change the currently logged in user to $previewCacheUser
// If not the templates might read in wrong personalized data (preferences etc.)
eZUser::setCurrentlyLoggedInUser($previewCacheUser, $previewCacheUser->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
// Cache the current node
$cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $node->attribute('node_id'), false, false, $language, $viewMode, $viewParameters, $cachedViewPreferences);
$tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $node, $node->attribute('object'), $language, $viewMode, false, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters);
// Cache the parent node
$parentNode = $node->attribute('parent');
$objectID = $parentNode->attribute('contentobject_id');
// if parent objectID is null or is 0 we should not create cache.
if ($objectID) {
$cacheFileArray = eZNodeviewfunctions::generateViewCacheFile($previewCacheUser, $parentNode->attribute('node_id'), 0, false, $language, $viewMode, $viewParameters, $cachedViewPreferences);
$tmpRes = eZNodeviewfunctions::generateNodeView($tpl, $parentNode, $parentNode->attribute('object'), $language, $viewMode, 0, $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], true, $viewParameters);
}
}
}
}
// Restore the old user as the current one
eZUser::setCurrentlyLoggedInUser($user, $user->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
// restore siteaccess
eZSiteAccess::load($currentSiteAccess);
}
}
if ($ini->variable('ContentSettings', 'StaticCache') == 'enabled') {
$nodes = array();
$ini = eZINI::instance();
$useURLAlias =& $GLOBALS['eZContentObjectTreeNodeUseURLAlias'];
$pathPrefix = $ini->variable('SiteAccessSettings', 'PathPrefix');
// get staticCacheHandler instance
$optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
$options = new ezpExtensionOptions($optionArray);
$staticCacheHandler = eZExtension::getHandlerClass($options);
if (!isset($useURLAlias)) {
$useURLAlias = $ini->variable('URLTranslator', 'Translation') == 'enabled';
}
eZContentCacheManager::nodeListForObject($object, true, self::CLEAR_DEFAULT, $nodes, $handledObjectList);
// If no nodes returns it means that ClearCacheMethod = self::CLEAR_NO_CACHE
if (count($nodes)) {
foreach ($nodes as $nodeID) {
if ($useURLAlias) {
$oNode = eZContentObjectTreeNode::fetch($nodeID, false, true);
if (!isset($oNode)) {
continue;
}
$urlAlias = $oNode->urlAlias();
if ($pathPrefix != '') {
$tempAlias = substr($pathPrefix, strlen($pathPrefix) - 1) == '/' ? $urlAlias . '/' : $urlAlias;
if (strncmp($tempAlias, $pathPrefix, strlen($tempAlias)) == 0) {
$urlAlias = substr($tempAlias, strlen($pathPrefix));
}
}
} else {
$urlAlias = 'content/view/full/' . $nodeID;
}
$staticCacheHandler->cacheURL('/' . $urlAlias, $nodeID);
//.........这里部分代码省略.........