本文整理汇总了PHP中opToolkit::unifyEOLCharacter方法的典型用法代码示例。如果您正苦于以下问题:PHP opToolkit::unifyEOLCharacter方法的具体用法?PHP opToolkit::unifyEOLCharacter怎么用?PHP opToolkit::unifyEOLCharacter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类opToolkit
的用法示例。
在下文中一共展示了opToolkit::unifyEOLCharacter方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
public function run()
{
$path = $this->options['dir'] . DIRECTORY_SEPARATOR . 'sql' . DIRECTORY_SEPARATOR . $this->options['name'] . '.sql';
if (!file_exists($path)) {
throw new RuntimeException('The specified sql doesn\'t exist.');
}
$db = $this->getDatabaseManager()->getDatabase('doctrine');
$this->conn = $db->getDoctrineConnection();
$this->conn->beginTransaction();
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
$sql = opToolkit::unifyEOLCharacter($this->parseSql($path));
$queries = explode("\n", $sql);
try {
$this->executeQueries($queries);
$this->conn->commit();
} catch (Exception $e) {
$this->conn->rollback();
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
throw $e;
}
$this->conn->execute('SET FOREIGN_KEY_CHECKS = 0');
// for mysql
}
示例2: validate
public function validate($validator, $value, $arguments = array())
{
$value = opToolkit::unifyEOLCharacter($value);
$list = array_map('trim', explode("\n", $value));
$list = array_unique($list);
foreach ($list as $item) {
if (!preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/', $item)) {
throw new sfValidatorError($validator, 'invalid');
}
}
return implode("\n", $list);
}
示例3: validate
public function validate($validator, $values, $arguments = array())
{
$values = $values + array('pc' => array(), 'mobile' => array(), 'invalid' => array());
$inputList = explode("\n", opToolkit::unifyEOLCharacter($values['mail_address']));
$inputList = array_unique(array_map('trim', $inputList));
foreach ($inputList as $value) {
try {
$result = parent::validate($validator, array('mail_address' => $value));
if (!empty($result['pc_address'])) {
$values['pc'][] = $result['pc_address'];
} elseif (!empty($result['mobile_address'])) {
$values['mobile'][] = $result['mobile_address'];
}
} catch (sfValidatorError $e) {
$values['invalid'][] = $value;
}
}
if (empty($values['pc']) && empty($values['mobile'])) {
throw new sfValidatorError($validator, 'All of the inputted E-mail addresses are invalid.');
}
return $values;
}