这是我的问题:我正在尝试在symfony中编写自定义验证器。
用法:
$this->setValidator('path', new sfValidatorFile(array(
'required' => false,
'path' => sfConfig::get('sf_upload_dir'),
'mime_types' => 'web_images',
'validated_file_class' => 'sfImageTransform')));
}
验证者:
<?php class sfImageTransform extends sfValidatedFile{
public function save($file = null, $fileMode = 0666, $create = true, $dirMode = 0777) {
$saved = parent::save($file, $fileMode, $create, $dirMode);
$img = new sfImage(sfConfig::get('sf_upload_dir').'/'.$saved, 'image/jpeg');
$img->resize(500,400);
$img->save();
return $saved;
}
} ?>
我收到此错误:Fatal error: Class 'sfImageTransform' not found in /http/htdocs/pizza_propel/lib/vendor/symfony/lib/validator/sfValidatorFile.class.php on line 167
这部分将让我谋杀成为我见过的第一位Sensio Lab员工:
每当我从验证器文件中删除<?php ?>
括号时,我在浏览器窗口中得到class sfImageTransform extends sfValidatedFile{ public function save($file = null, $fileMode = 0666, $create = true, $dirMode = 0777) { // let the parent class save the file and do what it normally does $saved = parent::save($file, $fileMode, $create, $dirMode); //echo $saved;die; $img = new sfImage(sfConfig::get('sf_upload_dir').'/'.$saved, 'image/jpeg'); $img->resize(500,400); $img->save(); //$saved->resize(1000,null); // //$saved->resize(1000,null)->overlay(new sfImage('logo.png'), 'bottom-right'); return $saved; } } Fatal error: Class 'sfImageTransform' not found in /http/htdocs/pizza_propel/lib/vendor/symfony/lib/validator/sfValidatorFile.class.php on line 167
(如预期的那样),但在将它们放回并刷新后,它会执行完全ONCE,它应该做什么,并在下一次尝试时,它再次做同样的事情。说真的......什么是傻瓜?我ra ra for for for for for,,,,,and and and and and and and and and and and and and and and and有人之前处理过这个吗?
答案 0 :(得分:0)
所以我再次回答我自己的问题。我真的应该停止打扰。
看起来,通过一个palaalactically idiotic巧合,验证器类文件的命名与其他文件或类似的东西发生冲突。重命名验证程序类文件解决了该问题。