public function getLogic($name) { $className = "Logics_" . ucfirst($name); if (Sabel::using($className)) { return Sabel_Container::load($className, new Logics_DI()); } $message = __METHOD__ . "() logic class not found."; throw new Sabel_Exception_ClassNotFound($message); }
public static function getTableList($connectionName = "default") { $className = "Schema_" . ucfirst($connectionName) . "TableList"; if (Sabel::using($className)) { $sc = new $className(); return $sc->get(); } else { return Sabel_Db::createMetadata($connectionName)->getTableList(); } }
protected function createController($destination) { list($module, $controller, ) = $destination->toArray(); $class = ucfirst($module) . "_Controllers_" . ucfirst($controller); if (Sabel::using($class)) { l("create controller '{$class}'"); return new $class(); } else { l("controller '{$class}' not found", SBL_LOG_WARN); return null; } }
/** * @param string $connectionName * * @throws Sabel_Exception_ClassNotFound * @return Sabel_Db_Abstract_Migration */ public static function createMigration($connectionName = "default") { $className = self::classPrefix($connectionName) . "Migration"; if (Sabel::using($className)) { return new $className(); } elseif ($baseClass = self::getBaseClassName($connectionName, "Migration")) { return new $baseClass(); } else { $message = __METHOD__ . "() Class '{$className}' not Found."; throw new Sabel_Exception_ClassNotFound($message); } }
protected function exists($className) { return Sabel::using($className) || interface_exists($className); }
/** * Load the connection adapter * * While this method is not called more than one for a client, it is * seperated from ->request() to preserve logic and readability * * @param Zend_Http_Client_Adapter_Interface|string $adapter * @return null * @throws Zend_Http_Client_Exception */ public function setAdapter($adapter) { if (is_string($adapter)) { if (!Sabel::using($adapter)) { throw new Sabel_Exception_ClassNotFound($adapter); } $adapter = new $adapter(); } if (!$adapter instanceof Sabel_Http_Client_Adapter_Interface) { $message = __METHOD__ . "() Passed adapter is not a HTTP connection adapter."; throw new Sabel_Exception_InvalidArgument($message); } $this->adapter = $adapter; $config = $this->config; unset($config["adapter"]); $this->adapter->setConfig($config); }
public function validate($ignores = array()) { $this->ignores = $ignores; $this->errors = array(); $messages = $this->messages; $model = $this->model; $columns = $this->getColumns(); foreach ($columns as $name => $column) { if (in_array($name, $ignores)) { continue; } $value = $column->value; if ($column->increment) { if ($value === self::OMITTED || $value === null || $this->isUpdate) { continue; } $message = __METHOD__ . "() don't set a value in '{$column->name}'(sequence column)."; throw new Sabel_Db_Exception($message); } if ($this->nullable($column)) { if ($value === self::OMITTED) { $column->value = $value = null; } } else { $this->errors[] = $this->errorMessage($name, $value, "nullable"); continue; } if (!$this->type($column)) { if ($column->isNumeric()) { $this->errors[] = $this->errorMessage($name, $value, "numeric"); } else { $this->errors[] = $this->errorMessage($name, $value, "type"); } continue; } if ($column->isString()) { if (!$this->length($column, "max")) { $message = $this->errorMessage($name, $value, "maxlength"); $this->errors[] = str_replace("%MAX%", $column->max, $message); continue; } elseif (!$this->length($column, "min")) { $message = $this->errorMessage($name, $value, "minlength"); $this->errors[] = str_replace("%MIN%", $column->min, $message); continue; } } if ($column->isNumeric() && $value !== null) { if (!$this->maximum($column)) { $message = $this->errorMessage($name, $value, "maximum"); $this->errors[] = str_replace("%MAX%", $column->max, $message); } elseif (!$this->minimum($column)) { $message = $this->errorMessage($name, $value, "minimum"); $this->errors[] = str_replace("%MIN%", $column->min, $message); } } } if ($uniques = $model->getMetadata()->getUniques()) { $this->unique($model, $uniques); } Sabel::using("Db_Validate_Config"); if ($this->validateConfig === null && !class_exists("Db_Validate_Config", false)) { return $this->errors; } if ($this->validateConfig !== null) { $config = $this->validateConfig; } else { $config = new Db_Validate_Config(); } $config->configure(); $this->doCustomValidate($config, $columns); return $this->errors; }