public static function getConfig($appName, $modelNames = null)
 {
     $mappingDriver = new Tinebase_Record_DoctrineMappingDriver();
     if (!$modelNames) {
         $modelNames = array();
         foreach ($mappingDriver->getAllClassNames() as $modelName) {
             $modelConfig = $modelName::getConfiguration();
             if ($modelConfig->getApplName() == $appName) {
                 $modelNames[] = $modelName;
             }
         }
     }
     $tableNames = array();
     foreach ($modelNames as $modelName) {
         $modelConfig = $modelName::getConfiguration();
         if (!$mappingDriver->isTransient($modelName)) {
             throw new Setup_Exception('Model not yet doctrine2 ready');
         }
         $tableNames[] = SQL_TABLE_PREFIX . Tinebase_Helper::array_value('name', $modelConfig->getTable());
     }
     $config = Setup::createConfiguration();
     $config->setMetadataDriverImpl($mappingDriver);
     $config->setFilterSchemaAssetsExpression('/' . implode('|', $tableNames) . '/');
     return $config;
 }
 /**
  * @return array
  *
  * @param bool $MCV2only filter for new modelconfig with doctrine schema tool
  */
 public function getModels($MCV2only = false)
 {
     if ($this->_models === null && !empty($this->_applicationName)) {
         $cache = Tinebase_Core::getCache();
         $cacheId = Tinebase_Helper::convertCacheId('getModels' . $this->_applicationName);
         $models = $cache->load($cacheId);
         if (!$models) {
             $models = $this->_getModelsFromAppDir();
             // cache for a long time only on prod
             $cache->save($models, $cacheId, array(), TINE20_BUILDTYPE === 'DEVELOPMENT' ? 1 : 3600);
         }
         $this->_models = $models;
     }
     if ($MCV2only) {
         if (!Setup_Core::isDoctrineAvailable()) {
             if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
                 Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Doctrine not available, could not get modelconfig v2 models for application (php version id: ' . PHP_VERSION_ID . ')');
             }
             return array();
         }
         $md = new Tinebase_Record_DoctrineMappingDriver();
         $MCv2Models = array();
         foreach ((array) $this->_models as $model) {
             if ($md->isTransient($model)) {
                 $MCv2Models[] = $model;
             }
         }
         return $MCv2Models;
     }
     return $this->_models;
 }