本文整理匯總了PHP中ParserFactory::CanParse方法的典型用法代碼示例。如果您正苦於以下問題:PHP ParserFactory::CanParse方法的具體用法?PHP ParserFactory::CanParse怎麽用?PHP ParserFactory::CanParse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ParserFactory
的用法示例。
在下文中一共展示了ParserFactory::CanParse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: try_mkdir
if (!$setting['enable']) {
return;
}
$cache_dir = CACHE_DIR . DIRECTORY_SEPARATOR . 'github_repo';
try_mkdir($cache_dir);
Hook::AddHook(Hook::FIND_POST_LIST, function (&$list) use($setting, $cache_dir) {
$files = array();
if (isset($setting['repos'])) {
foreach ($setting['repos'] as $repostring) {
$repo = new Repo($repostring);
$helper = new RepoHelper($repo);
$helper->setFileCacheDir($cache_dir);
try {
$tree = $helper->getTreeInPath();
$tree = array_filter($tree, function ($item) {
return $item['type'] === 'blob' && ParserFactory::CanParse($item['path']);
});
$files = array_merge($files, $helper->getAllLocalBlob($tree));
} catch (GitHubException $ex) {
throw $ex;
}
}
}
$list = array_merge($list, $files);
// 刪除其餘文件
$all = glob($cache_dir . DIRECTORY_SEPARATOR . '*');
$remove = array_diff($all, $files);
array_walk($remove, function ($fn) {
unlink($fn);
});
//var_dump($files,$all,$remove);