public static function rpc_rebuild(Context $ctx) { // Обновление БД. foreach (os::find('lib/modules/*/*.yml') as $fileName) { $schema = Spyc::YAMLLoad($fileName); Logger::log('applying ' . $fileName, 'module'); if (!empty($schema['tables'])) { foreach ($schema['tables'] as $tableName => $tableInfo) { TableInfo::check($tableName, $tableInfo); } } } $ctx->registry->rebuild(); $ctx->registry->broadcast('ru.molinos.cms.install', array($ctx)); }
/** * Создание всех индексов, описанных в типе. */ private static function recreateIndexes(Context $ctx, Node $type) { $tran = $ctx->db->isTransactionRunning(); foreach ((array) $type->fields as $name => $info) { if (!Node::isBasicField($name) and !empty($info['indexed'])) { if ($sql = Control::getIndexType($info['type'])) { try { TableInfo::check('node__idx_' . $name, array('id' => array('type' => 'integer', 'required' => true, 'key' => 'pri'), 'value' => array('type' => $sql, 'required' => false, 'key' => 'mul'))); } catch (PDOException $e) { Logger::log("error reindexing {$info['type']}.{$name}: " . $e->getMessage()); } } } } if ($tran) { $ctx->db->beginTransaction(); } }