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


PHP Color::info方法代码示例

本文整理汇总了PHP中Phalcon\Script\Color::info方法的典型用法代码示例。如果您正苦于以下问题:PHP Color::info方法的具体用法?PHP Color::info怎么用?PHP Color::info使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Phalcon\Script\Color的用法示例。


在下文中一共展示了Color::info方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: build


//.........这里部分代码省略.........
     if (isset($this->_options['genSettersGetters'])) {
         $genSettersGetters = $this->_options['genSettersGetters'];
     } else {
         $genSettersGetters = false;
     }
     $adapter = $config->database->adapter;
     $this->isSupportedAdapter($adapter);
     if (isset($config->database->adapter)) {
         $adapter = $config->database->adapter;
     } else {
         $adapter = 'Mysql';
     }
     if (is_object($config->database)) {
         $configArray = $config->database->toArray();
     } else {
         $configArray = $config->database;
     }
     $adapterName = 'Phalcon\\Db\\Adapter\\Pdo\\' . $adapter;
     unset($configArray['adapter']);
     /**
      * @var $db \Phalcon\Db\Adapter\Pdo
      */
     $db = new $adapterName($configArray);
     if (isset($this->_options['schema'])) {
         $schema = $this->_options['schema'];
     } elseif ($adapter == 'Postgresql') {
         $schema = 'public';
     } else {
         $schema = isset($config->database->schema) ? $config->database->schema : $config->database->dbname;
     }
     $hasMany = array();
     $belongsTo = array();
     $foreignKeys = array();
     if ($defineRelations || $defineForeignKeys) {
         foreach ($db->listTables($schema) as $name) {
             if ($defineRelations) {
                 if (!isset($hasMany[$name])) {
                     $hasMany[$name] = array();
                 }
                 if (!isset($belongsTo[$name])) {
                     $belongsTo[$name] = array();
                 }
             }
             if ($defineForeignKeys) {
                 $foreignKeys[$name] = array();
             }
             $camelCaseName = Utils::camelize($name);
             $refSchema = $adapter != 'Postgresql' ? $schema : $config->database->dbname;
             foreach ($db->describeReferences($name, $schema) as $reference) {
                 $columns = $reference->getColumns();
                 $referencedColumns = $reference->getReferencedColumns();
                 $referencedModel = Utils::camelize($reference->getReferencedTable());
                 if ($defineRelations) {
                     if ($reference->getReferencedSchema() == $refSchema) {
                         if (count($columns) == 1) {
                             $belongsTo[$name][] = array('referencedModel' => $referencedModel, 'fields' => $columns[0], 'relationFields' => $referencedColumns[0], 'options' => $defineForeignKeys ? array('foreignKey' => true) : NULL);
                             $hasMany[$reference->getReferencedTable()][] = array('camelizedName' => $camelCaseName, 'fields' => $referencedColumns[0], 'relationFields' => $columns[0]);
                         }
                     }
                 }
             }
         }
     } else {
         foreach ($db->listTables($schema) as $name) {
             if ($defineRelations) {
                 $hasMany[$name] = array();
                 $belongsTo[$name] = array();
                 $foreignKeys[$name] = array();
             }
         }
     }
     foreach ($db->listTables($schema) as $name) {
         $className = Utils::camelize($name);
         if (!file_exists($modelsDir . '/' . $className . '.php') || $forceProcess) {
             if (isset($hasMany[$name])) {
                 $hasManyModel = $hasMany[$name];
             } else {
                 $hasManyModel = array();
             }
             if (isset($belongsTo[$name])) {
                 $belongsToModel = $belongsTo[$name];
             } else {
                 $belongsToModel = array();
             }
             if (isset($foreignKeys[$name])) {
                 $foreignKeysModel = $foreignKeys[$name];
             } else {
                 $foreignKeysModel = array();
             }
             $modelBuilder = new \Phalcon\Builder\Model(array('name' => $name, 'schema' => $schema, 'extends' => isset($this->_options['extends']) ? $this->_options['extends'] : null, 'namespace' => $this->_options['namespace'], 'force' => $forceProcess, 'hasMany' => $hasManyModel, 'belongsTo' => $belongsToModel, 'foreignKeys' => $foreignKeysModel, 'genSettersGetters' => $genSettersGetters, 'directory' => $this->_options['directory']));
             $modelBuilder->build();
         } else {
             if ($this->isConsole()) {
                 print Color::info("Skipping model \"{$name}\" because it already exist");
             } else {
                 $this->exist[] = $name;
             }
         }
     }
 }
开发者ID:mhnegrao,项目名称:phalcon-devtools,代码行数:101,代码来源:AllModels.php

示例2: build


//.........这里部分代码省略.........
     $forceProcess = $this->options->get('force');
     $defineRelations = $this->options->get('defineRelations', false);
     $defineForeignKeys = $this->options->get('foreignKeys', false);
     $genSettersGetters = $this->options->get('genSettersGetters', false);
     $mapColumn = $this->options->get('mapColumn', null);
     $adapter = $config->database->adapter;
     $this->isSupportedAdapter($adapter);
     $adapter = 'Mysql';
     if (isset($config->database->adapter)) {
         $adapter = $config->database->adapter;
     }
     if (is_object($config->database)) {
         $configArray = $config->database->toArray();
     } else {
         $configArray = $config->database;
     }
     $adapterName = 'Phalcon\\Db\\Adapter\\Pdo\\' . $adapter;
     unset($configArray['adapter']);
     /**
      * @var $db \Phalcon\Db\Adapter\Pdo
      */
     $db = new $adapterName($configArray);
     if ($this->options->contains('schema')) {
         $schema = $this->options->get('schema');
     } elseif ($adapter == 'Postgresql') {
         $schema = 'public';
     } else {
         $schema = isset($config->database->schema) ? $config->database->schema : $config->database->dbname;
     }
     $hasMany = array();
     $belongsTo = array();
     $foreignKeys = array();
     if ($defineRelations || $defineForeignKeys) {
         foreach ($db->listTables($schema) as $name) {
             if ($defineRelations) {
                 if (!isset($hasMany[$name])) {
                     $hasMany[$name] = array();
                 }
                 if (!isset($belongsTo[$name])) {
                     $belongsTo[$name] = array();
                 }
             }
             if ($defineForeignKeys) {
                 $foreignKeys[$name] = array();
             }
             $camelCaseName = Utils::camelize($name);
             $refSchema = $adapter != 'Postgresql' ? $schema : $config->database->dbname;
             foreach ($db->describeReferences($name, $schema) as $reference) {
                 $columns = $reference->getColumns();
                 $referencedColumns = $reference->getReferencedColumns();
                 $referencedModel = Utils::camelize($reference->getReferencedTable());
                 if ($defineRelations) {
                     if ($reference->getReferencedSchema() == $refSchema) {
                         if (count($columns) == 1) {
                             $belongsTo[$name][] = array('referencedModel' => $referencedModel, 'fields' => $columns[0], 'relationFields' => $referencedColumns[0], 'options' => $defineForeignKeys ? array('foreignKey' => true) : null);
                             $hasMany[$reference->getReferencedTable()][] = array('camelizedName' => $camelCaseName, 'fields' => $referencedColumns[0], 'relationFields' => $columns[0]);
                         }
                     }
                 }
             }
         }
     } else {
         foreach ($db->listTables($schema) as $name) {
             if ($defineRelations) {
                 $hasMany[$name] = array();
                 $belongsTo[$name] = array();
                 $foreignKeys[$name] = array();
             }
         }
     }
     foreach ($db->listTables($schema) as $name) {
         $className = $this->options->contains('abstract') ? 'Abstract' : '';
         $className .= Utils::camelize($name);
         if (!file_exists($modelPath . $className . '.php') || $forceProcess) {
             if (isset($hasMany[$name])) {
                 $hasManyModel = $hasMany[$name];
             } else {
                 $hasManyModel = array();
             }
             if (isset($belongsTo[$name])) {
                 $belongsToModel = $belongsTo[$name];
             } else {
                 $belongsToModel = array();
             }
             if (isset($foreignKeys[$name])) {
                 $foreignKeysModel = $foreignKeys[$name];
             } else {
                 $foreignKeysModel = array();
             }
             $modelBuilder = new Model(array('name' => $name, 'schema' => $schema, 'extends' => $this->options->get('extends'), 'namespace' => $this->options->get('namespace'), 'force' => $forceProcess, 'hasMany' => $hasManyModel, 'belongsTo' => $belongsToModel, 'foreignKeys' => $foreignKeysModel, 'genSettersGetters' => $genSettersGetters, 'directory' => $this->options->get('directory'), 'modelsDir' => $this->options->get('modelsDir'), 'mapColumn' => $mapColumn, 'abstract' => $this->options->get('abstract')));
             $modelBuilder->build();
         } else {
             if ($this->isConsole()) {
                 print Color::info(sprintf('Skipping model "%s" because it already exist', Utils::camelize($name)));
             } else {
                 $this->exist[] = $name;
             }
         }
     }
 }
开发者ID:ntamvl,项目名称:phalcon-devtools,代码行数:101,代码来源:AllModels.php

示例3: run

 /**
  * Run migrations
  *
  * @param array $options
  *
  * @throws Exception
  * @throws ModelException
  * @throws ScriptException
  *
  */
 public static function run(array $options)
 {
     // Define versioning type to be used
     if (true === $options['tsBased']) {
         VersionCollection::setType(VersionCollection::TYPE_TIMESTAMPED);
     } else {
         VersionCollection::setType(VersionCollection::TYPE_INCREMENTAL);
     }
     $migrationsDir = rtrim($options['migrationsDir'], '/');
     if (!file_exists($migrationsDir)) {
         throw new ModelException('Migrations directory was not found.');
     }
     /** @var Config $config */
     $config = $options['config'];
     if (!$config instanceof Config) {
         throw new ModelException('Internal error. Config should be an instance of \\Phalcon\\Config');
     }
     // Init ModelMigration
     if (!isset($config->database)) {
         throw new ScriptException('Cannot load database configuration');
     }
     $finalVersion = null;
     if (isset($options['version']) && $options['version'] !== null) {
         $finalVersion = VersionCollection::createItem($options['version']);
     }
     $tableName = 'all';
     if (isset($options['tableName'])) {
         $tableName = $options['tableName'];
     }
     $versionItems = ModelMigration::scanForVersions($migrationsDir);
     if (!isset($versionItems[0])) {
         throw new ModelException('Migrations were not found at ' . $migrationsDir);
     }
     // Set default final version
     if ($finalVersion === null) {
         $finalVersion = VersionCollection::maximum($versionItems);
     }
     ModelMigration::setup($config->database);
     ModelMigration::setMigrationPath($migrationsDir);
     self::connectionSetup($options);
     $initialVersion = self::getCurrentVersion($options);
     $completedVersions = self::getCompletedVersions($options);
     // Everything is up to date
     if ($initialVersion->getStamp() === $finalVersion->getStamp()) {
         print Color::info('Everything is up to date');
         exit(0);
     }
     $direction = ModelMigration::DIRECTION_FORWARD;
     if ($finalVersion->getStamp() < $initialVersion->getStamp()) {
         $direction = ModelMigration::DIRECTION_BACK;
     }
     if (ModelMigration::DIRECTION_FORWARD === $direction) {
         // If we migrate up, we should go from the beginning to run some migrations which may have been missed
         $versionItemsTmp = VersionCollection::sortAsc(array_merge($versionItems, [$initialVersion]));
         $initialVersion = $versionItemsTmp[0];
     } else {
         // If we migrate downs, we should go from the last migration to revert some migrations which may have been missed
         $versionItemsTmp = VersionCollection::sortDesc(array_merge($versionItems, [$initialVersion]));
         $initialVersion = $versionItemsTmp[0];
     }
     // Run migration
     $versionsBetween = VersionCollection::between($initialVersion, $finalVersion, $versionItems);
     foreach ($versionsBetween as $versionItem) {
         if (ModelMigration::DIRECTION_FORWARD === $direction && isset($completedVersions[(string) $versionItem])) {
             print Color::info('Version ' . (string) $versionItem . ' was already applied');
             continue;
         } elseif (ModelMigration::DIRECTION_BACK === $direction && !isset($completedVersions[(string) $versionItem])) {
             print Color::info('Version ' . (string) $versionItem . ' was already rolled back');
             continue;
         }
         if ($versionItem->getVersion() === $finalVersion->getVersion() && ModelMigration::DIRECTION_BACK === $direction) {
             break;
         }
         $migrationStartTime = date("'Y-m-d H:i:s'");
         if ($tableName === 'all') {
             $iterator = new DirectoryIterator($migrationsDir . DIRECTORY_SEPARATOR . $versionItem->getVersion());
             foreach ($iterator as $fileInfo) {
                 if (!$fileInfo->isFile() || 0 !== strcasecmp($fileInfo->getExtension(), 'php')) {
                     continue;
                 }
                 ModelMigration::migrate($initialVersion, $versionItem, $fileInfo->getBasename('.php'), $direction);
             }
         } else {
             ModelMigration::migrate($initialVersion, $versionItem, $tableName, $direction);
         }
         if (ModelMigration::DIRECTION_FORWARD == $direction) {
             self::addCurrentVersion($options, (string) $versionItem, $migrationStartTime);
             print Color::success('Version ' . $versionItem . ' was successfully migrated');
         } else {
             self::removeCurrentVersion($options, (string) $versionItem);
//.........这里部分代码省略.........
开发者ID:VyacheslavLynnyk,项目名称:scripts,代码行数:101,代码来源:Migrations.php


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