本文整理匯總了PHP中factory::isCreable方法的典型用法代碼示例。如果您正苦於以下問題:PHP factory::isCreable方法的具體用法?PHP factory::isCreable怎麽用?PHP factory::isCreable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類factory
的用法示例。
在下文中一共展示了factory::isCreable方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: afterInit
protected function afterInit()
{
$this->dir = $this->cfg->dir;
if ($this->cfg->subdir) {
$this->subdir = $this->cfg->subdir . DS;
$this->dir .= $this->subdir;
}
file::createDir($this->dir);
$uploaded = false;
if (strpos($this->cfg->name, '[')) {
$tmp = explode('[', str_replace(']', '', $this->cfg->name));
$tmpfile = utils::getValInArray($_FILES, $tmp);
if (!empty($tmpfile) && is_array($tmpfile)) {
$this->file = $tmpfile;
$this->file['saved'] = false;
$uploaded = $this->file['error'] == UPLOAD_ERR_OK;
}
} else {
if (array_key_exists($this->cfg->name, $_FILES)) {
$this->file = $_FILES[$this->cfg->name];
$this->file['saved'] = false;
$uploaded = $this->file['error'] == UPLOAD_ERR_OK;
}
}
if ($this->cfg->current && !$uploaded) {
$name = basename($this->cfg->current);
$savePath = $this->dir . $name;
$webPath = str_replace(DS, '/', $this->subdir . $name);
$this->file = array('name' => $name, 'type' => file::getType($savePath), 'tmp_name' => '', 'error' => UPLOAD_ERR_OK, 'size' => file::size($savePath), 'saved' => array('name' => $name, 'savePath' => $savePath, 'webPath' => $webPath), 'savedFromValue' => true);
$this->saved = $webPath;
}
$this->helper = factory::isCreable('helper_' . $this->cfg->helper) ? factory::getHelper($this->cfg->helper, $this->getHelperPrm('factory')) : null;
if ($this->cfg->autoSave && !empty($this->file) && $this->isValid() === true) {
$this->save();
}
}
示例2: get
/**
* Get a db object
*
* @param string $type Element type (table, rowset or row)
* @param db_table|string $table
* @param array $prm Array parameter for the factory
* @return db_table|db_rowset|db_row
*/
public static function get($type, $table, array $prm = array())
{
if ($type == 'table' && array_key_exists($table, self::$tables)) {
return self::$tables[$table];
}
self::init();
if ($table instanceof db_table) {
$tableName = $table->getName();
if (!array_key_exists('table', $prm)) {
$prm['table'] = $table;
}
} else {
$tableName = $table;
if ($type == 'table' && !array_key_exists('name', $prm)) {
$prm['name'] = $table;
} else {
if ($type == 'row' && !array_key_exists('table', $prm)) {
$db = array_key_exists('db', $prm) ? $prm['db'] : self::getInstance();
$prm['table'] = self::get('table', $tableName, array('db' => $db));
}
}
}
if (!($className = self::$cfg->getInArray($type, $tableName)) && !factory::isCreable($className = 'db_' . $type . '_' . $tableName)) {
$className = self::$cfg->get($type . 'Class');
}
if ($type == 'table') {
self::$tables[$table] = factory::get($className, $prm);
return self::$tables[$table];
}
return factory::get($className, $prm);
}