本文整理汇总了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);
}
}
//.........这里部分代码省略.........