Changeset View
Changeset View
Standalone View
Standalone View
src/infrastructure/storage/patch/PhabricatorSQLPatchList.php
<?php | <?php | ||||
abstract class PhabricatorSQLPatchList { | abstract class PhabricatorSQLPatchList { | ||||
abstract function getNamespace(); | abstract function getNamespace(); | ||||
abstract function getPatches(); | abstract function getPatches(); | ||||
/** | |||||
* Examine a directory for `.php` and `.sql` files and build patch | |||||
* specifications for them. | |||||
*/ | |||||
protected function buildPatchesFromDirectory($directory) { | |||||
$patch_list = Filesystem::listDirectory( | |||||
$directory, | |||||
$include_hidden = false); | |||||
sort($patch_list); | |||||
$patches = array(); | |||||
foreach ($patch_list as $patch) { | |||||
$matches = null; | |||||
if (!preg_match('/\.(sql|php)$/', $patch, $matches)) { | |||||
throw new Exception( | |||||
pht( | |||||
'Unknown patch "%s" in "%s", expected ".php" or ".sql" suffix.', | |||||
$patch, | |||||
$directory)); | |||||
} | |||||
$patches[$patch] = array( | |||||
'type' => $matches[1], | |||||
'name' => rtrim($directory, '/').'/'.$patch, | |||||
); | |||||
} | |||||
return $patches; | |||||
} | |||||
final public static function buildAllPatches() { | final public static function buildAllPatches() { | ||||
$patch_lists = id(new PhutilSymbolLoader()) | $patch_lists = id(new PhutilSymbolLoader()) | ||||
->setAncestorClass('PhabricatorSQLPatchList') | ->setAncestorClass('PhabricatorSQLPatchList') | ||||
->setConcreteOnly(true) | ->setConcreteOnly(true) | ||||
->selectAndLoadSymbols(); | ->selectAndLoadSymbols(); | ||||
$specs = array(); | $specs = array(); | ||||
$seen_namespaces = array(); | $seen_namespaces = array(); | ||||
▲ Show 20 Lines • Show All 135 Lines • Show Last 20 Lines |