本文整理汇总了PHP中StringHelper::isNullOrEmpty方法的典型用法代码示例。如果您正苦于以下问题:PHP StringHelper::isNullOrEmpty方法的具体用法?PHP StringHelper::isNullOrEmpty怎么用?PHP StringHelper::isNullOrEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringHelper
的用法示例。
在下文中一共展示了StringHelper::isNullOrEmpty方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: afterFind
protected function afterFind()
{
if (StringHelper::isNullOrEmpty($this->icon_src)) {
$this->icon_src = Group::DEFAULT_IMG_PATH;
}
return parent::afterFind();
}
示例2: _validateDbConfigFile
/**
* Make sure the basics are in place in the db connection file before we actually try to connect later on.
*
* @throws DbConnectException
*/
private function _validateDbConfigFile()
{
$messages = array();
$databaseServerName = craft()->config->getDbItem('server');
$databaseAuthName = craft()->config->getDbItem('user');
$databaseName = craft()->config->getDbItem('database');
$databasePort = craft()->config->getDbItem('port');
$databaseCharset = craft()->config->getDbItem('charset');
$databaseCollation = craft()->config->getDbItem('collation');
if (StringHelper::isNullOrEmpty($databaseServerName)) {
$messages[] = Craft::t('The database server name isn’t set in your db config file.');
}
if (StringHelper::isNullOrEmpty($databaseAuthName)) {
$messages[] = Craft::t('The database user name isn’t set in your db config file.');
}
if (StringHelper::isNullOrEmpty($databaseName)) {
$messages[] = Craft::t('The database name isn’t set in your db config file.');
}
if (StringHelper::isNullOrEmpty($databasePort)) {
$messages[] = Craft::t('The database port isn’t set in your db config file.');
}
if (StringHelper::isNullOrEmpty($databaseCharset)) {
$messages[] = Craft::t('The database charset isn’t set in your db config file.');
}
if (StringHelper::isNullOrEmpty($databaseCollation)) {
$messages[] = Craft::t('The database collation isn’t set in your db config file.');
}
if (!empty($messages)) {
throw new DbConnectException(Craft::t('Database configuration errors: {errors}', array('errors' => implode(PHP_EOL, $messages))));
}
$this->_isDbConfigValid = true;
}
示例3: _setSmtpSettings
/**
* Sets SMTP settings on a given email.
*
* @param $email
* @param $emailSettings
*
* @throws Exception
* @return null
*/
private function _setSmtpSettings(&$email, $emailSettings)
{
$email->isSMTP();
if (isset($emailSettings['smtpAuth']) && $emailSettings['smtpAuth'] == 1) {
$email->SMTPAuth = true;
if (!isset($emailSettings['username']) && StringHelper::isNullOrEmpty($emailSettings['username']) || !isset($emailSettings['password']) && StringHelper::isNullOrEmpty($emailSettings['password'])) {
throw new Exception(Craft::t('Username and password are required. Check your email settings.'));
}
$email->Username = $emailSettings['username'];
$email->Password = $emailSettings['password'];
}
if (isset($emailSettings['smtpKeepAlive']) && $emailSettings['smtpKeepAlive'] == 1) {
$email->SMTPKeepAlive = true;
}
$email->SMTPSecure = $emailSettings['smtpSecureTransportType'] != 'none' ? $emailSettings['smtpSecureTransportType'] : null;
if (!isset($emailSettings['host'])) {
throw new Exception(Craft::t('You must specify a host name in your email settings.'));
}
if (!isset($emailSettings['port'])) {
throw new Exception(Craft::t('You must specify a port in your email settings.'));
}
if (!isset($emailSettings['timeout'])) {
$emailSettings['timeout'] = $this->_defaultEmailTimeout;
}
$email->Host = $emailSettings['host'];
$email->Port = $emailSettings['port'];
$email->Timeout = $emailSettings['timeout'];
}