Concrete5 5.7: Using file objects in a Single Page Controller -
try attach file object mail object.
i have included following in form of view:
$f = new concrete\core\application\service\filemanager(); //... echo $f->file('file', 'test', 'pls choose');
then submit form controller. there (btw other form fields arrive in controller expected) do:
$files = $this->post('test'); $file = \file::getbyid($files);
which should return file object. when do
$file = \file::getrelativepathfromid($files);
it gives me correct path chosen file.
so far good. when try send mail file object attached:
$mail = loader::helper('mail'); $mail->settesting(false); $mail->setsubject('test-subject'); $mail->to($this->post('uemail')); //... $attach = $mail->addattachment($file); $attach->filename = 'tttt'; $mail->sendmail();
the following error occurs:
call_user_func_array() expects parameter 1 valid callback, class 'concrete\core\file\version' not have method 'getpath'
which apparently comes class method (api):
namespace concrete\core\mail; //... class service { //... /** * add attachment send email. * * sample code: * $attachment = $mailhelper->addattachment($fileobject); * $attachment->filename = "customfilename"; * $mailhelper->send(); * * @param file $fob file attach * @return stdclass pointer attachment */ public function addattachment(\concrete\core\file\file $fob) { // @todo make work file storage locations $fv = $fob->getversion(); $path = $fob->getpath(); $name = $fv->getfilename(); //... } //... }
which apparently wants file object param, think passed, weren't i? why file object becomes fileversion object, which, see myself, hasn't got method getpath().
my other trials far:
$fv = $f->getapprovedversion(); $fv->setfile($f); $fv->getfile(); $fv = $f->getrecentversion(); $fv->setfile($f); $fv->getfile();
how correct file object, have to, maybe (??) , take out of last/approved version of file?
this bug has been fixed in upstream, you'll have either patch or wait until version 7.4 lands.
Comments
Post a Comment