public static function calculateId($widget) { $dc = kDataCenterMgr::getCurrentDc(); for ($i = 0; $i < 10; ++$i) { $id = $dc["id"] . '_' . kString::generateStringId(); $existing_widget = widgetPeer::retrieveByPKNoFilter($id); if (!$existing_widget) { return $id; } } die; }