本文整理匯總了PHP中inflector::lcfirst方法的典型用法代碼示例。如果您正苦於以下問題:PHP inflector::lcfirst方法的具體用法?PHP inflector::lcfirst怎麽用?PHP inflector::lcfirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類inflector
的用法示例。
在下文中一共展示了inflector::lcfirst方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: migrate
/**
* Perform a migration of this module.
*
* Make sure you rollback any changes if your migration fails!
*
* By default, the migrate routine just runs the migrations in Doctrine for your models, based on the version of
* this module and the version registered in the database.
* If that's all you need for your migrations, you don't need to override this function.
* All models in the directory of your module will be migrated.
*
* You do not need to override this class if you are not adding additional functionality to it.
*
* @return array | NULL Array of failures, or NULL if everything is OK
*/
public function migrate($identifier)
{
$package = Package_Catalog::getPackageByIdentifier($identifier);
if (!empty($package['models'])) {
$loadedModels = Doctrine::loadModels($package['directory'] . '/models', Doctrine::MODEL_LOADING_CONSERVATIVE);
}
if (empty($loadedModels)) {
return;
}
$installed = Package_Catalog::getInstalledPackage($package['packageName']);
if (Package_Dependency::compareVersion($package['version'], $installed['version'])) {
kohana::log('debug', 'Attempting to upgrade package ' . $installed['packageName'] . ' version ' . $installed['version'] . ' to ' . $package['version']);
foreach ($loadedModels as $modelName) {
if (get_parent_class($modelName) != 'Bluebox_Record' and get_parent_class($modelName) != 'Doctrine_Record') {
continue;
}
$migrationDirectory = $package['directory'] . '/migrations/' . $modelName;
kohana::log('debug', 'Looking for migrations in `' . $migrationDirectory . '`');
if (is_dir($migrationDirectory)) {
try {
$migration = new Bluebox_Migration($migrationDirectory, NULL, strtolower($modelName));
kohana::log('debug', 'Running migration on ' . $modelName . ' from model version ' . $migration->getCurrentVersion() . ' to ' . $migration->getLatestVersion());
$migration->migrate();
$msg = inflector::humanizeModelName($modelName);
$msg .= ' database table upgraded to model version # ' . $migration->getCurrentVersion();
Package_Message::set($msg, 'info', $identifier);
} catch (Exception $e) {
kohana::log('alert', 'Alerts during migration, this can USUALLY be ignored: ' . $e->getMessage());
// TODO: This isnt a great idea, but migrations are so noisy with needless failures... PITA
$migration->setCurrentVersion($migration->getLatestVersion());
foreach ($migration->getErrors() as $error) {
if (strstr($error->getMessage(), 'Already at version')) {
$msg = inflector::humanizeModelName($modelName);
$msg .= ' database table ' . inflector::lcfirst($error->getMessage());
Package_Message::set($msg, 'info', $identifier);
} else {
Package_Message::set($error->getMessage(), 'alert', $identifier);
}
}
}
} else {
$migration = new Bluebox_Migration(NULL, NULL, strtolower($modelName));
$migration->setCurrentVersion(0);
}
}
} else {
kohana::log('debug', 'Attempting to downgrade package ' . $installed['packageName'] . ' version ' . $installed['version'] . ' to ' . $package['version']);
foreach ($loadedModels as $modelName) {
if (get_parent_class($modelName) != 'Bluebox_Record' and get_parent_class($modelName) != 'Doctrine_Record') {
continue;
}
$migrationDirectory = $installed['directory'] . '/migrations/' . $modelName;
kohana::log('debug', 'Looking for migrations in `' . $migrationDirectory . '`');
if (is_dir($migrationDirectory)) {
try {
$modelVersion = 0;
if (is_dir($package['directory'] . '/migrations/' . $modelName)) {
$previousMigration = new Doctrine_Migration($package['directory'] . '/migrations/' . $modelName);
$modelVersion = $previousMigration->getLatestVersion();
}
kohana::log('debug', 'Determined that ' . $package['packageName'] . ' version ' . $package['version'] . ' works against ' . $modelName . ' version ' . $modelVersion);
$migration = new Bluebox_Migration($migrationDirectory, NULL, strtolower($modelName));
kohana::log('debug', 'Running migration on ' . $modelName . ' from model version ' . $migration->getCurrentVersion() . ' to ' . $modelVersion);
$migration->migrate($modelVersion);
$msg = inflector::humanizeModelName($modelName);
$msg .= ' database table downgraded to model version # ' . $migration->getCurrentVersion();
Package_Message::set($msg, 'info', $identifier);
} catch (Exception $e) {
kohana::log('alert', 'Alerts during migration, this can USUALLY be ignored: ' . $e->getMessage());
// TODO: This isnt a great idea, but migrations are so noisy with needless failures... PITA
$migration->setCurrentVersion($migration->getLatestVersion());
foreach ($migration->getErrors() as $error) {
if (strstr($error->getMessage(), 'Already at version')) {
$msg = inflector::humanizeModelName($modelName);
$msg .= ' database table ' . inflector::lcfirst($error->getMessage());
Package_Message::set($msg, 'info', $identifier);
} else {
Package_Message::set($error->getMessage(), 'alert', $identifier);
}
}
}
} else {
$migration = new Bluebox_Migration(NULL, NULL, strtolower($modelName));
$migration->setCurrentVersion(0);
}
}
//.........這裏部分代碼省略.........