Quote from: Pixel at Nov 26, 2010, 04:38 AM
What is the OO API that needs to be used and if it was in the original prototype what caused it to be withheld from the first release?
The MODx Revolution API; the 2.0 release did not change the table structure to ease the pain of migrating custom code from Evolution releases. One of the primary reasons for the development of Revolution was to provide a foundation for being able to begin changing the underlying table structures to get from where MODx is to where we want it to be without breaking components every time we do it.
For example, many components in Evolution directly query columns of the modx_site_content table; here is Ditto getting TV content for instance:
<?php
$query = "SELECT stv.name,stc.tmplvarid,stc.contentid,stv.type,stv.display,stv.display_params,stc.value";
$query .= " FROM ".$tb1." stc LEFT JOIN ".$tb2." stv ON stv.id=stc.tmplvarid ";
$query .= " WHERE stv.name='".$tvname."' AND stc.contentid IN (".implode($docIDs,",").") ORDER BY stc.contentid ASC;";
$rs = $modx->db->query($query);
$tot = $modx->db->getRecordCount($rs);
?>
If we were to move the actual content out of the value column, and reference say, an external content table with versioning, and perhaps cultural specific copies for localization, this becomes invalid.
But, in Revolution this can handled much differently via the OO API it presents:
<?php
foreach ($collection as $resourceId => $resource) {
$tvs = array();
if (!empty($includeTVs)) {
$templateVars =& $resource->getMany('TemplateVars');
foreach ($templateVars as $tvId => $templateVar) {
$tvs[$tvPrefix . $templateVar->get('name')] = !empty($processTVs) ? $templateVar->renderOutput($resource->get('id')) : $templateVar->get('value');
}
}
// etc, etc, etc
}
?>
And though we may be referencing what appear to be columns in the table still, e.g. $templateVar->get(’value’), those are actually fields of an object now accessed by a function, which can be set from any source, not just directly from table columns. Thus the new way of working with MODx core data as objects, provides abstraction for providing better backwards compatibility. Not to mention it also provides abstraction from database engines, so we can port the application easily to other RDBMS’s than MySQL.