public function initialize() { $numberType = new NumberType(); $numberType->class = 'TimeOfDayNumber'; $numberType->module_id = 0; $numberType->save(); }
public function initialize() { $numberType = new NumberType(); $numberType->class = 'AutoAttendantNumber'; $numberType->module_id = 0; $numberType->save(); }
protected static function integrateNumberType($models, $datastore_id) { foreach ($models as $model) { if (!class_exists($model) || !is_subclass_of($model, 'Number')) { continue; } Package_Message::log('debug', 'Adding ' . $model . ' to NumberType'); try { $numberType = Doctrine::getTable('NumberType')->findOneByClass($model); if (!$numberType) { Package_Message::log('debug', 'Could not find ' . $model . ' in NumberType, adding as new number type'); $numberType = new NumberType(); $numberType['class'] = $model; } $numberType['package_id'] = $datastore_id; $numberType->save(); $numberType->free(TRUE); } catch (Exception $e) { throw new Package_Catalog_Exception($e->getMessage() . print_r($models, true)); return FALSE; } } return TRUE; }
/** * This function will attemp to integrate a number type if a model extends * Number * * @return bool * @param array $models */ private static function _integrateNumberType($models, $dbModule, $name = '') { foreach ($models as $model) { if (!class_exists($model) || !is_subclass_of($model, 'Number')) { continue; } Kohana::log('debug', 'Adding ' . $model . ' to NumberType'); try { $q = Doctrine::getTable('NumberType')->createQuery('n')->where('n.class = ?', $model); $numberType = $q->fetchOne(); // If we coulnt get the current row then we will make a new one if (!$numberType) { Kohana::log('debug', 'Failed to find ' . $model . ' in NumberType, adding new number type'); $numberType = new NumberType(); $numberType->class = $model; } $numberType->Package = $dbModule; $numberType->save(); $numberType->free(TRUE); } catch (Exception $e) { self::_setError('Unable to integrate ' . $model . ' into NumberType! <br /><small>' . $e->getMessage() . '</small>', $name); return FALSE; } } return TRUE; }