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


PHP Kwf_Model_Abstract::findAllInstances方法代码示例

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


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

示例1: getAllMaintenanceJobs

 public static function getAllMaintenanceJobs()
 {
     static $ret;
     if (isset($ret)) {
         return $ret;
     }
     foreach (Kwc_Abstract::getComponentClasses() as $c) {
         if (is_instance_of($c, 'Kwf_Util_Maintenance_JobProviderInterface')) {
             $providerClasses[] = $c;
         }
     }
     foreach (Kwf_Model_Abstract::findAllInstances() as $model) {
         if ($model instanceof Kwf_Util_Maintenance_JobProviderInterface) {
             $providerClasses[] = get_class($model);
         }
     }
     $jobClasses = array();
     foreach ($providerClasses as $c) {
         $jobClasses = array_merge($jobClasses, call_user_func(array($c, 'getMaintenanceJobs')));
     }
     $jobClasses = array_unique($jobClasses);
     $ret = array();
     foreach ($jobClasses as $i) {
         $ret[] = new $i();
     }
     usort($ret, array('Kwf_Util_Maintenance_Dispatcher', '_compareJobsPriority'));
     return $ret;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:28,代码来源:Dispatcher.php

示例2: getProgressSteps

 public function getProgressSteps()
 {
     $ret = count(Kwf_Model_Abstract::findAllInstances());
     if ($this->countUploads() < 5000) {
         $ret += $this->countUploads();
     }
     return $ret;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:8,代码来源:20151012UploadsDimensions.php

示例3: getUpdates

 public static function getUpdates()
 {
     $ret = self::getKwcUpdates();
     $u = self::getUpdatesForDir('Kwf_Update');
     $ret = array_merge($ret, $u);
     if (defined('VKWF_PATH')) {
         //HACK
         $u = self::getUpdatesForDir('Vkwf_Update');
         $ret = array_merge($ret, $u);
     }
     $u = self::getUpdatesForDir('Update');
     $ret = array_merge($ret, $u);
     foreach (Kwf_Model_Abstract::findAllInstances() as $m) {
         $ret = array_merge($ret, $m->getUpdates());
     }
     $ret = self::_sortUpdates($ret);
     return $ret;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:18,代码来源:Helper.php

示例4: _getAllListeners

 private static function _getAllListeners()
 {
     Kwf_Events_ModelObserver::getInstance()->disable();
     $models = array();
     $subscribers = array();
     $hasFulltext = false;
     foreach (Kwc_Abstract::getComponentClasses() as $componentClass) {
         $subscribers = array_merge($subscribers, self::_getSubscribersFromComponent($componentClass));
         if (Kwc_Abstract::getFlag($componentClass, 'usesFulltext')) {
             $hasFulltext = true;
         }
     }
     if (Kwf_Component_Data_Root::getComponentClass()) {
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_ViewCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_UrlCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_ProcessInputCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_RequestHttpsCache');
     }
     if ($hasFulltext) {
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_Fulltext');
     }
     foreach (Kwf_Model_Abstract::findAllInstances() as $m) {
         $subscribers = array_merge($subscribers, self::_getSubscribersFromModel($m));
     }
     $ret = array();
     self::_addListenersFromSubscribers($ret, $subscribers);
     Kwf_Events_ModelObserver::getInstance()->enable();
     return $ret;
 }
开发者ID:nsams,项目名称:koala-framework,代码行数:29,代码来源:Dispatcher.php

示例5: update

 public function update()
 {
     $db = Kwf_Registry::get('db');
     $db->query("SET FOREIGN_KEY_CHECKS = 0");
     $field = $db->fetchRow("SHOW FIELDS FROM `kwf_uploads` WHERE `Field` = 'id'");
     if ($field['Type'] != 'varbinary(36)') {
         $indexes = $db->fetchAll("SELECT\n                TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME\n                FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE\n                WHERE TABLE_SCHEMA = DATABASE() AND REFERENCED_TABLE_NAME='kwf_uploads' AND REFERENCED_COLUMN_NAME='id'");
         foreach ($indexes as $index) {
             $sql = "ALTER TABLE {$index['TABLE_NAME']} DROP FOREIGN KEY `{$index['CONSTRAINT_NAME']}`";
             $db->query($sql);
         }
         $indexes = $db->fetchAll("SELECT\n                TABLE_NAME,COLUMN_NAME,CONSTRAINT_NAME, REFERENCED_TABLE_NAME,REFERENCED_COLUMN_NAME\n                FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE\n                WHERE TABLE_SCHEMA = DATABASE() AND REFERENCED_TABLE_NAME='kwf_uploads' AND REFERENCED_COLUMN_NAME='id'");
         foreach ($indexes as $index) {
             $sql = "ALTER TABLE {$index['TABLE_NAME']} DROP FOREIGN KEY `{$index['CONSTRAINT_NAME']}`";
             $db->query($sql);
         }
         $db->query("ALTER TABLE `kwf_uploads` CHANGE  `id`  `id_old` INT( 11 ) NULL");
         $db->query("ALTER TABLE `kwf_uploads` DROP PRIMARY KEY");
         $db->query("ALTER TABLE `kwf_uploads` ADD  `id` VARBINARY( 36 ) NOT NULL FIRST");
         $db->query("UPDATE `kwf_uploads` SET `id` = UUID()");
         $db->query("ALTER TABLE `kwf_uploads` ADD PRIMARY KEY(`id`)");
     }
     $uploadIds = $db->fetchPairs('SELECT id_old, id FROM kwf_uploads');
     foreach (Kwf_Model_Abstract::findAllInstances() as $model) {
         $this->_progressBar->next(1, 'updating uploads ' . get_class($model));
         foreach ($model->getReferences() as $rule) {
             $reference = $model->getReference($rule);
             $refModel = '';
             if (isset($reference['refModel'])) {
                 $refModel = $reference['refModel'];
             } else {
                 if (isset($reference['refModelClass'])) {
                     $refModel = $reference['refModelClass'];
                 }
             }
             if (!is_instance_of($refModel, 'Kwf_Uploads_Model')) {
                 continue;
             }
             $tableName = '';
             if (is_instance_of($model, 'Kwf_Model_Proxy')) {
                 $tableName = $model->getProxyModel()->getTableName();
             } else {
                 $tableName = $model->getTableName();
             }
             $tableExists = $db->fetchOne("SHOW TABLES LIKE '{$tableName}'");
             if (!$tableExists) {
                 continue;
             }
             $oldColumnName = $reference['column'] . '_old';
             $columnName = $reference['column'];
             $columnExists = $db->fetchOne("SHOW COLUMNS FROM `{$tableName}` LIKE '{$columnName}'");
             if (!$columnExists) {
                 continue;
             }
             $field = $db->fetchRow("SHOW FIELDS FROM `{$tableName}` WHERE `Field` = '{$columnName}'");
             if ($field['Type'] != 'varbinary(36)') {
                 $db->beginTransaction();
                 try {
                     $db->query("ALTER TABLE `{$tableName}` CHANGE  `{$columnName}`  `{$oldColumnName}` INT( 11 ) NULL;");
                     $db->query("ALTER TABLE  `{$tableName}` ADD  `{$columnName}` VARBINARY( 36 ) NULL AFTER  `{$oldColumnName}`");
                     $existingIds = $db->fetchCol("SELECT {$oldColumnName} FROM `{$tableName}` WHERE {$oldColumnName}!=''");
                     $ids = array_intersect_key($uploadIds, array_flip($existingIds));
                     foreach (array_chunk($ids, 1000, true) as $chunkedIds) {
                         $values = array();
                         foreach ($chunkedIds as $key => $val) {
                             $values[] = "WHEN '{$key}' THEN '{$val}'";
                         }
                         $sql = "UPDATE {$tableName} SET {$columnName}=CASE {$oldColumnName} " . implode(' ', $values) . " END WHERE {$oldColumnName} IN (" . implode(', ', array_keys($chunkedIds)) . ")";
                         $db->query($sql);
                     }
                     $db->query("ALTER TABLE `{$tableName}` DROP `{$oldColumnName}`");
                     $db->query("ALTER TABLE `{$tableName}` ADD INDEX (`{$columnName}`)");
                     $db->query("ALTER TABLE `{$tableName}` ADD FOREIGN KEY (`{$columnName}`) REFERENCES `kwf_uploads` (`id`) ON DELETE RESTRICT ON UPDATE CASCADE");
                     $db->commit();
                 } catch (Zend_Db_Exception $e) {
                     $db->rollBack();
                 }
             }
         }
     }
     $db->query("SET FOREIGN_KEY_CHECKS = 1\n");
     $this->_progressBar->next(1, 'updating Image filenames');
     if (in_array('kwc_basic_image', $db->listTables())) {
         $m = Kwf_Model_Abstract::getInstance('Kwc_Abstract_Image_Model');
         $s = new Kwf_Model_Select();
         $s->whereEquals('filename', '');
         $it = new Kwf_Model_Iterator_Packages(new Kwf_Model_Iterator_Rows(Kwf_Model_Abstract::getInstance('Kwf_Uploads_Model'), $s));
         foreach ($it as $row) {
             $pr = $m->getRow($m->select()->whereEquals('kwf_upload_id', $row->id));
             if ($pr) {
                 $row->filename = $pr->filename;
                 $row->save();
             }
         }
     }
     $field = $db->fetchRow("SHOW FIELDS FROM `kwf_uploads` WHERE `Field` = 'md5_hash'");
     if (!$field) {
         $db->query("ALTER TABLE  `kwf_uploads` ADD  `md5_hash` VARCHAR( 32 ) NOT NULL");
         $db->query("ALTER TABLE  `kwf_uploads` ADD INDEX  `md5_hash` (  `md5_hash` )");
     }
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:koala-framework,代码行数:101,代码来源:20150309Legacy39000.php

示例6: _getAllListeners

 private static function _getAllListeners()
 {
     Kwf_Events_ModelObserver::getInstance()->disable();
     $models = array();
     $subscribers = array();
     foreach (Kwc_Abstract::getComponentClasses() as $componentClass) {
         $subscribers = array_merge($subscribers, self::_getSubscribersFromComponent($componentClass));
     }
     if (Kwf_Component_Data_Root::getComponentClass()) {
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_ViewCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_UrlCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_ProcessInputCache');
         $subscribers[] = Kwf_Events_Subscriber::getInstance('Kwf_Component_Events_PagesMeta');
     }
     foreach (Kwf_Model_Abstract::findAllInstances() as $m) {
         $subscribers = array_merge($subscribers, self::_getSubscribersFromModel($m));
     }
     foreach (Kwf_Config::getValueArray('eventSubscribers') as $subscriber) {
         if ($subscriber) {
             $subscriber = Kwf_Events_Subscriber::getInstance($subscriber);
             $subscribers[] = $subscriber;
         }
     }
     $ret = array();
     self::_addListenersFromSubscribers($ret, $subscribers);
     Kwf_Events_ModelObserver::getInstance()->enable();
     return $ret;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:28,代码来源:Dispatcher.php


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