本文整理汇总了PHP中TextHelper::serializeMediaId方法的典型用法代码示例。如果您正苦于以下问题:PHP TextHelper::serializeMediaId方法的具体用法?PHP TextHelper::serializeMediaId怎么用?PHP TextHelper::serializeMediaId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextHelper
的用法示例。
在下文中一共展示了TextHelper::serializeMediaId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: AnimeProcessor
<?php
require_once __DIR__ . '/../src/core.php';
$mediaProcessors = [Media::Anime => new AnimeProcessor(), Media::Manga => new MangaProcessor()];
$mediaIds = [];
foreach (Database::getAllDbNames() as $dbName) {
Database::attachDatabase($dbName);
$query = 'SELECT um.mal_id, um.media FROM usermedia um' . ' GROUP BY um.media, um.mal_id' . ' HAVING NOT EXISTS(' . 'SELECT null FROM media m' . ' WHERE m.mal_id = um.mal_id AND m.media = um.media' . ') ORDER BY um.mal_id';
$localMediaIds = array_map(function ($row) {
$row = ReflectionHelper::arrayToClass($row);
return TextHelper::serializeMediaId($row);
}, R::getAll($query));
$mediaIds = array_merge($mediaIds, $localMediaIds);
}
$mediaIds = array_unique($mediaIds);
$pad = strlen(count($mediaIds));
$done = 0;
$exitCode = 0;
foreach ($mediaIds as $mediaId) {
try {
++$done;
list($media, $malId) = TextHelper::deserializeMediaId($mediaId);
printf("(%0{$pad}d/%d) Processing %s #%d" . PHP_EOL, $done, count($mediaIds), Media::toString($media), $malId);
$mediaProcessors[$media]->process($malId);
} catch (Exception $e) {
echo $e->getMessage() . PHP_EOL;
$exitCode = 1;
}
}
exit($exitCode);
示例2: QueueItem
$mediaIds[] = TextHelper::serializeMediaId($entry);
}
}
}
$mediaQueue->enqueueMultiple(array_map(function ($mediaId) {
return new QueueItem($mediaId);
}, $mediaIds));
$logger->log('ok');
});
$mediaIds = [];
foreach (Media::getConstList() as $media) {
$entries = Model_Media::getOldest($media, 100);
foreach ($entries as $entry) {
$mediaAge = time() - strtotime($entry->processed);
if ($mediaAge > Config::$mediaQueueMinWait) {
$mediaIds[] = TextHelper::serializeMediaId($entry);
}
}
}
$mediaQueue->enqueueMultiple(array_map(function ($mediaId) {
return new QueueItem($mediaId);
}, $mediaIds));
#process media
processQueue($mediaQueue, Config::$mediaPerCronRun, Config::$mediaQueueMaxAttempts, $logger, function ($key) use($mediaProcessors, $logger) {
list($media, $malId) = TextHelper::deserializeMediaId($key);
$logger->log('Processing %s #%d... ', Media::toString($media), $malId);
#process the media
$mediaProcessors[$media]->process($malId);
$logger->log('ok');
});
});