Contao3: $this->User->filemounts from serialized 2 full path
The field filemounts in tl_users, tl_users_group has entry in DB like
Code:
a:3:{i:0;i:22;i:1;i:62;i:2;i:41;}
But if you print out $this->User->filemounts you get an array
Code:
Array ( [62] => files/doc [22] => files/content [41] => files/framework )
In which class and in which function is this conversion done?
OK I found out
Its in Class BackendUser->setUserFromDb()
Re: Contao3: $this->User->filemounts from serialized 2 full
A method to find that if you don't know is to print_r($this->User). The method prints a lot of info and starts with the classname. If the printed info doesn't help you can use the classname and search for "class classname" in all files. This way you can easily find the function that does this.
Re: Contao3: $this->User->filemounts from serialized 2 full
Looks like you have two questions.
You have to serialize() and deserialize() data if you are going to directly write to the Database. Normally the Models/Database classes will handle this for you. You just assign the array to the value and it will be serialised before writing to the database. When you read it in though, you have to perform the deserialize() to get out into an array.
In version 3, the ID is the new DBFS filesystem ID number must be converted by the FilesModel (you can inspect Controller, there are examples in there):
Code:
$objFile = \FilesModel::findByPk(62);
if ($objFile !== null)
echo $objFile->path
To convert items from IDs to paths.
Re: Contao3: $this->User->filemounts from serialized 2 full
Thanks for answers: As I found out in Class BackendUser->setUserFromDb()
Code:
$objFiles = \FilesModel::findMultipleByIds(deserialize('a:3:{i:0;i:22;i:1;i:62;i:2;i:41;}'));
$this->filemounts = $objFiles->fetchEach('path');
did the job.
Re: Contao3: $this->User->filemounts from serialized 2 full
thanks for posting the content. someone else might want that too.