ここに私の問題があります: 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
と、(予想どおり) ブラウザーウィンドウにこれが表示されますが、元に戻して更新した後、正確に 1 回実行され、実行すべきことを実行し、次の試行で同じことをもう一度実行します。まじで…どうしたの?私はこれについて 1 時間以上激怒しており、半径 75 マイル内にある破壊可能なすべてのものを破壊しようとしています。以前にこれを扱った人はいますか?