本文整理汇总了PHP中Variable::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP Variable::factory方法的具体用法?PHP Variable::factory怎么用?PHP Variable::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Variable
的用法示例。
在下文中一共展示了Variable::factory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construction of object initializes a connection resource to the link
* variable
* @param string $dsn
*/
public function __construct($database_type, $username, $password = null, $database_name = null, $host = null, $port = null)
{
$this->database_type = \Variable::factory('string', $database_type, 'database_type');
$this->database_type->setLimit(12);
$this->database_type->setLabel(t('Database type'));
$this->database_type->wordCharactersOnly();
$this->database_name = \Variable::factory('string', $database_name, 'database_name');
$this->database_name->setLimit(58);
$this->database_name->setLabel(t('Database name'));
$this->database_name->wordCharactersOnly();
$this->username = \Variable::factory('string', $username, 'username');
$this->username->setLimit(255);
$this->username->setLabel(t('Database user name'));
$this->username->wordCharactersOnly();
$this->password = \Variable::factory('string', $password, 'password');
$this->password->setLimit(255);
$this->password->setLabel(t('Database password'));
$this->password->setInputType('password');
$this->table_prefix = \Variable::factory('string', null, 'table_prefix');
$this->table_prefix->allowNull(true);
$this->table_prefix->setLimit(5);
$this->table_prefix->setLabel(t('Table prefix'));
$this->table_prefix->wordCharactersOnly();
$this->host = \Variable::factory('string', null, 'host');
$this->host->setLimit(255);
$this->host->setLabel('Database host');
$this->host->allowNull(true);
$this->host->set($host);
$this->port = \Variable::factory('integer', null, 'port');
$this->port->setLabel('Database port');
$this->port->setRange('1', '65535');
$this->port->allowNull(true);
if (!empty($port)) {
$this->port->set($port);
}
}
示例2: setName
public function setName($name)
{
$this->name = \Variable::factory('alphanumeric', $name);
}