Skip to content

Instantly share code, notes, and snippets.

@totten
Last active July 28, 2016 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save totten/4473975264fc2a788391d3c5ef5bf18b to your computer and use it in GitHub Desktop.
Save totten/4473975264fc2a788391d3c5ef5bf18b to your computer and use it in GitHub Desktop.
Dump all metadata from DAOs. (Note: Old DAOs have buggy caching in import()/export(). To get different cases, we use separate scripts to get exercise different cases even while the bug is present.)
#!/bin/bash
set -ex
echo "==Default=="
cv scr tmp/read-all-daos.php > dao/throwaway.data
colordiff -u dao/orig.data dao/throwaway.data
echo
echo "==Prefix=="
cv scr tmp/read-all-daos-prefix.php > dao/throwaway.data-prefix
colordiff -u dao/orig.data-prefix dao/throwaway.data-prefix
echo
<?php
$rows = array();
foreach (CRM_Core_DAO_AllCoreTables::get() as $class => $entityType) {
$row = array(
'fields()' => $class::fields(),
'fieldKeys()' => $class::fieldKeys(),
'getTableName()' => $class::getTableName(),
'import(1)' => $class::import(TRUE),
'export(1)' => $class::export(TRUE),
'getReferenceColumns()' => $class::getReferenceColumns(),
);
$rows[$class] = $row;
}
CRM_Utils_Array::flatten($rows, $flat, '', '::');
ksort($rows);
var_export($flat);
<?php
$rows = array();
foreach (CRM_Core_DAO_AllCoreTables::get() as $class => $entityType) {
$row = array(
'fields()' => $class::fields(),
'fieldKeys()' => $class::fieldKeys(),
'getTableName()' => $class::getTableName(),
'import()' => $class::import(),
'export()' => $class::export(),
'getReferenceColumns()' => $class::getReferenceColumns(),
);
$rows[$class] = $row;
}
CRM_Utils_Array::flatten($rows, $flat, '', '::');
ksort($rows);
var_export($flat);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment