Question

Here's my problem: I'm trying to write a custom validator in symfony.

usage :

$this->setValidator('path', new sfValidatorFile(array(

    'required'   => false,
    'path'       => sfConfig::get('sf_upload_dir'),
    'mime_types' => 'web_images',
    'validated_file_class' => 'sfImageTransform')));
}

validator :

<?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;
  }
} ?>

I'm getting this error: Fatal error: Class 'sfImageTransform' not found in /http/htdocs/pizza_propel/lib/vendor/symfony/lib/validator/sfValidatorFile.class.php on line 167

Here's the part that's going to make me murder the first Sensio Lab employee I'll ever meet: Whenever I remove the <?php ?> brackets from validator file, i get this 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 in my browser window, (as expected), but after putting them back and refreshing, it executes exactly ONCE, does what it should do, and at the next attempt it does the same shthing again. Seriously... what the fhell? I'm raging over this for over an hour, and I'm about to smash everything smashable in 75 mile radius. Anyone dealt with this before?

Was it helpful?

Solution

And so once again I get to answer my own question. I should really stop bother asking.

It seems, that by a pangalactically idiotic coincidence, the named of the validator class file came into conflict with some other file, or something like that. Renaming the validator class file resolved the problem.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top