/** * Get object title */ public function getTitle() { $title = $this->_config->getLinkTitle(); if (strpos($title, '{') !== false) { $fields = $this->_config->getFieldsConfig(true); foreach ($fields as $name => $cfg) { $title = str_replace('{' . $name . '}', (string) $this->get($name), $title); } } else { if ($this->fieldExists($title)) { $title = $this->get($title); } } return $title; }
/** * Tells whether object can be converted to new engine type * * @param string $newEngineType * @throws Exception * @return mixed - true for success or array with restricted indexes and * fields */ public function checkEngineCompatibility($newEngineType) { $restrictedIndexes = array(); $restrictedFields = array(); $indexes = $this->_objectConfig->getIndexesConfig(); $fields = $this->_objectConfig->getFieldsConfig(); switch (strtolower($newEngineType)) { case 'myisam': break; case 'memory': foreach ($fields as $k => $v) { $type = $v['db_type']; if (in_array($type, self::$textTypes, true) || in_array($type, self::$blobTypes, true)) { $restrictedFields[] = $k; } } foreach ($indexes as $k => $v) { if (isset($v['fulltext']) && $v['fulltext']) { $restrictedIndexes[] = $k; } } break; case 'innodb': foreach ($indexes as $k => $v) { if (isset($v['fulltext']) && $v['fulltext']) { $restrictedIndexes[] = $k; } } break; default: throw new Exception('Unknown db engine type'); break; } if (!empty($restrictedFields) || !empty($restrictedIndexes)) { return array('indexes' => $restrictedIndexes, 'fields' => $restrictedFields); } else { return true; } }