本文整理汇总了PHP中ClassInfo::getValidSubclasses方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassInfo::getValidSubclasses方法的具体用法?PHP ClassInfo::getValidSubclasses怎么用?PHP ClassInfo::getValidSubclasses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ClassInfo
的用法示例。
在下文中一共展示了ClassInfo::getValidSubclasses方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: build_fixtures
/**
* Builds out the SiteTree hierarchy as specified in _fixtures.txt
*
* @see "silversmith help"
* @param The parameters, e.g. from the command line
*/
public static function build_fixtures($params = array())
{
ClassInfo::reset_db_cache();
$fixtures_file = isset($params['file']) ? $params['file'] : self::$project_dir . "/_fixtures.txt";
if (!file_exists($fixtures_file)) {
fail("The file {$fixtures_file} doesn't exist.");
}
$code = file_get_contents($fixtures_file);
$architectureData = array();
$lines = explode("\n", $code);
if (empty($lines)) {
fail("The files {$fixtures_file} is empty.");
}
$sample = Folder::find_or_make("silversmith-samples");
if (!$sample->hasChildren()) {
$answer = ask("This project does not have sample assets installed, which can be useful for content seeding. Do you want to install them now? (y/n)");
if (strtolower(trim($answer)) == "y") {
SilverSmith::add_sample_assets();
}
}
$answer = ask("This process will completely empty and repopulate your site tree. Are you sure you want to continue? (y/n)");
if (strtolower($answer) != "y") {
die;
}
say("Parsing architecture file...");
foreach ($lines as $line) {
if (empty($line)) {
continue;
}
$level = 0;
$count = 1;
$class = "Page";
$title = $line;
preg_match('/^[ ]+[^ ]/', $line, $matches);
if ($matches) {
$level = strlen(substr(reset($matches), 0, -1));
}
if (stristr($line, ">")) {
list($title, $class) = explode(" > ", $line);
$class = SilverSmithUtil::proper_form($class);
}
preg_match('/\\*[0-9]+/', $title, $m);
if ($m) {
$match = reset($m);
$count = (int) trim(str_replace("*", "", $match));
$title = str_replace($match, "", $title);
}
$architectureData[] = array('title' => trim($title), 'level' => $level, 'class' => trim($class), 'count' => $count, 'new' => !class_exists($class) || !in_array($class, ClassInfo::getValidSubclasses("SiteTree")));
}
// Clean the slate
say("Deleting current site tree");
DB::query("DELETE FROM SiteTree");
DB::query("DELETE FROM SiteTree_Live");
DB::query("DELETE FROM SiteTree_versions");
say("Done.");
// Update the DB with any new page types
$new = array();
say("Checking architecture file for new page types...");
foreach ($architectureData as $arr) {
if ($arr['new']) {
$new[] = $arr['class'];
SilverSmithProject::get_configuration()->addNode($arr['class'], "PageTypes");
SilverSmithProject::get_node($arr['class'])->createFile();
say(success("Created " . $arr['class']));
}
}
if (!empty($new)) {
state("Rebuilding database to support " . sizeof($new) . " new page types...");
$result = self::rebuild_database();
self::rebuild_manifest();
state("Done\n");
}
$previousParentIDs = array('0' => '0');
$previousLevel = 0;
$seeding = isset($params['seeding-level']) ? $params['seeding-level'] : 1;
$total = 0;
foreach ($architectureData as $arr) {
$parentID = 0;
$currentLevel = $arr['level'];
$title = $arr['title'];
$class = $arr['class'];
$count = $arr['count'];
$indent = "";
while (strlen($indent) < $currentLevel * 2) {
$indent .= " ";
}
if ($currentLevel > 0) {
$parentID = $previousParentIDs[$currentLevel - 2];
}
for ($i = 0; $i < $count; $i++) {
$p = new $class();
if (strtolower($title) == "_auto_") {
$p->Title = SilverSmithUtil::get_lipsum_words(rand(2, 5));
} else {
//.........这里部分代码省略.........