CodeIgniter Forums
FileCollection and addDirectory - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=11)
+--- Thread: FileCollection and addDirectory (/showthread.php?tid=81090)



FileCollection and addDirectory - skeyby - 01-23-2022

Hello,
I was trying to use the FileCollection class that is documented at https://codeigniter.com/user_guide/libraries/files.html?highlight=glob#file-collections but I can't get it to work and I don't know if the problem is me or the documentation Big Grin
I just did something stupid like this in a class that extends a BaseCommand.

PHP Code:
$Scripts = new \CodeIgniter\HTTP\Files\FileCollection([]);
 
$Scripts->addDirectory(APPPATH.'Database/sqlUpdates');
$Scripts->retainPattern('*.sql');
CLI::write(count($Scripts)." found in the App/Database/sqlUpdates folder"); 


Nothing too fancy. and pretty similar to the example given.
Running this I get:

Code:
Call to undefined method CodeIgniter\HTTP\Files\FileCollection::addDirectory()

which frankly seems reasonable since I have nothing called "addDirectory" (neither retainPattern) in my entire source tree.

I feel like I'm missing something obvious, can someone give me an hint?

Thanks.


RE: FileCollection and addDirectory - iRedds - 01-23-2022

\CodeIgniter\HTTP\Files\FileCollection
and
\CodeIgniter\Files\FileCollection

These are different classes. You need a second one.


RE: FileCollection and addDirectory - skeyby - 01-23-2022

That gives me Class "CodeIgniter\Files\FileCollection" not found....

This is a grep for "FileCollection" in my project's home:


Code:
system/HTTP/IncomingRequest.php:use CodeIgniter\HTTP\Files\FileCollection;
system/HTTP/IncomingRequest.php:    * @var FileCollection|null
system/HTTP/IncomingRequest.php:            $this->files = new FileCollection();
system/HTTP/IncomingRequest.php:            $this->files = new FileCollection();
system/HTTP/IncomingRequest.php:            $this->files = new FileCollection();
system/HTTP/Files/FileCollection.php: * Class FileCollection
system/HTTP/Files/FileCollection.php:class FileCollection


I don't see any system/Files/FileCollection.php..... ?


RE: FileCollection and addDirectory - skeyby - 01-23-2022

Ok, I think I understood:
https://github.com/codeigniter4/CodeIgniter4/commits/develop/system/Files/FileCollection.php
This is rather new stuff I suppose...
I'll update CI and try again.


RE: FileCollection and addDirectory - luckmoshy - 01-23-2022

Hi Guys I have mult-input form data and i want to do like:

PHP Code:
$email = \Config\Services::email();

$email->setFrom('[email protected]''Your Name');
$email->setTo('[email protected]');
$email->setCC('[email protected]');
$email->setBCC('[email protected]');

$email->setSubject('Email Test');
$email->setMessage('

          $this->request->getVar('
one'); ==/*<input name="one">*/
          $this->request->getVar('
two');/*<input name="two">*/
          $this->request->getVar('
three');/*<input name="three">  and so on.....*/


'
);

$email->send(); 

How do I organize this in Html or text mail?