本文整理汇总了PHP中ezpObject::purge方法的典型用法代码示例。如果您正苦于以下问题:PHP ezpObject::purge方法的具体用法?PHP ezpObject::purge怎么用?PHP ezpObject::purge使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezpObject
的用法示例。
在下文中一共展示了ezpObject::purge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIssue15155
/**
* Regression test for issue #15155
*
* @link http://issues.ez.no/15155
*/
public function testIssue15155()
{
// figure out the max versions for images
$contentINI = eZINI::instance('content.ini');
$versionlimit = $contentINI->variable('VersionManagement', 'DefaultVersionHistoryLimit');
$limitList = eZContentClass::classIDByIdentifier($contentINI->variable('VersionManagement', 'VersionHistoryClass'));
$classID = 5;
// image class, can remain hardcoded, I guess
foreach ($limitList as $key => $value) {
if ($classID == $key) {
$versionlimit = $value;
}
}
if ($versionlimit < 2) {
$versionlimit = 2;
}
$baseImagePath = dirname(__FILE__) . '/ezimagealiashandler_regression_issue15155.png';
$parts = pathinfo($baseImagePath);
$imagePattern = $parts['dirname'] . DIRECTORY_SEPARATOR . $parts['filename'] . '_%s_%d.' . $parts['extension'];
$toDelete = array();
// Create version 1
$imagePath = sprintf($imagePattern, md5(1), 1);
copy($baseImagePath, $imagePath);
$toDelete[] = $imagePath;
$image = new ezpObject('image', 43);
$image->name = __FUNCTION__;
$image->image = $imagePath;
$image->publish();
$image->refresh();
$contentObjectID = $image->object->attribute('id');
$dataMap = eZContentObject::fetch($contentObjectID)->dataMap();
$originalAliases[1] = $image->image->imageAlias('original');
for ($i = 2; $i <= 20; $i++) {
// Create a new image file
$imagePath = sprintf($imagePattern, md5($i), $i);
copy($baseImagePath, $imagePath);
$toDelete[] = $imagePath;
$newVersion = $image->createNewVersion();
$dataMap = $newVersion->dataMap();
$dataMap['image']->fromString($imagePath);
ezpObject::publishContentObject($image->object, $newVersion);
$image->refresh();
$originalAliases[$i] = $image->image->imageAlias('original');
if ($i > $versionlimit) {
$removeVersion = $i - $versionlimit;
$aliasPath = $originalAliases[$removeVersion]['url'];
$this->assertFalse(file_exists($aliasPath), "Alias {$aliasPath} for version {$removeVersion} should have been removed");
}
}
array_map('unlink', $toDelete);
$image->purge();
}