当前位置: 首页>>代码示例>>PHP>>正文


PHP inflector::lcfirst方法代码示例

本文整理汇总了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);
             }
         }
//.........这里部分代码省略.........
开发者ID:swk,项目名称:bluebox,代码行数:101,代码来源:Bluebox_Configure.php


注:本文中的inflector::lcfirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。