/** * @param string $filename in this case it is a class name * @return ezdbiSchemaChecks * @throws Exception */ public function parseFile($filename) { if (!class_exists($filename)) { throw new Exception("Can not not analyze ezpo class definition for '{$filename}': class not found"); } if (!is_subclass_of($filename, 'eZPersistentObject')) { throw new Exception("Can not not analyze class definition for '{$filename}': not an ezpo"); } $def = call_user_func(array($filename, 'definition')); $checks = new ezdbiSchemaChecks(); ksort($def['fields']); foreach ($def['fields'] as $col => $value) { if (!isset($value['foreign_class'])) { continue; } $checks->addForeignKey($def['name'], $col, $this->resolveClassToTable($value['foreign_class']), $value['foreign_attribute']); } return $checks; }
/** * @param string $filename * @return ezdbiSchemaChecks * * @todo manage better ini reading to allow inis outside of standard locations */ public function parseFile($filename) { $ini = eZINI::instance($filename); $checks = new ezdbiSchemaChecks(); foreach ($ini->group('ForeignKeys') as $table => $value) { if (!is_array($value)) { eZDebug::writeWarning("Error in ini file {$filename}, var. {$table} is not an array", __METHOD__); continue; } foreach ($value as $def) { $def = explode($this->token, $def); if (count($def) >= 3) { $checks->addForeignKey($table, $def[0], $def[1], $def[2], isset($def[3]) ? $def[3] : null); } else { eZDebug::writeWarning("Error in ini file {$filename}, line in var. {$table} is not correct", __METHOD__); } } } foreach ($ini->group('CustomQueries') as $name => $def) { $checks->addQuery($def['sql'], str_replace('_', ' ', $name), @$def['description']); } return $checks; }