in pgo/cases/symfony_demo/TrainingCaseHandler.php [64:96]
public function setupUrls()
{
$this->nginx->up();
$url = "http://" . $this->getHttpHost() . ":" . $this->getHttpPort() . "/en/blog/";
$s = file_get_contents($url);
echo "Generating training urls.\n";
$lst = array();
if (preg_match_all(", href=\"([^\"]+)\",", $s, $m)) {
foreach ($m[1] as $u) {
if (strlen($u) >= 2 && "/" == $u[0] && "/" != $u[1] && !in_array(substr($u, -3), array("css", "xml", "ico"))) {
$ur = "http://" . $this->getHttpHost() . ":" . $this->getHttpPort() . $u;
if (!in_array($ur, $lst) && $this->probeUrl($ur)) {
$lst[] = $ur;
}
}
}
}
if (empty($lst)) {
printf("\033[31m WARNING: Training URL list is empty, check the regex and the possible previous error messages!\033[0m\n");
}
$this->nginx->down(true);
$fn = $this->getJobFilename();
$s = implode("\n", $lst);
if (strlen($s) !== file_put_contents($fn, $s)) {
throw new Exception("Couldn't write '$fn'.");
}
}