findMultipleByIds() public static method

Find multiple files by their IDs or UUIDs
public static findMultipleByIds ( array $arrIds, array $arrOptions = [] ) : Collection | FilesModel[] | FilesModel | null
$arrIds array An array of IDs or UUIDs
$arrOptions array An optional options array
return Contao\Model\Collection | FilesModel[] | FilesModel | null A collection of models or null if there are no files
 /**
  * Translate the file IDs to file paths
  */
 protected function convertValuesToPaths()
 {
     if (empty($this->varValue)) {
         return;
     }
     if (!is_array($this->varValue)) {
         $this->varValue = array($this->varValue);
     } elseif (empty($this->varValue[0])) {
         $this->varValue = array();
     }
     if (empty($this->varValue)) {
         return;
     }
     // TinyMCE will pass the path instead of the ID
     if (strncmp($this->varValue[0], \Config::get('uploadPath') . '/', strlen(\Config::get('uploadPath')) + 1) === 0) {
         return;
     }
     // Ignore the numeric IDs when in switch mode (TinyMCE)
     if (\Input::get('switch')) {
         return;
     }
     $objFiles = \FilesModel::findMultipleByIds($this->varValue);
     if ($objFiles !== null) {
         $this->varValue = array_values($objFiles->fetchEach('path'));
     }
 }
Beispiel #2
0
 /**
  * Translate the file IDs to file paths
  */
 protected function convertValuesToPaths()
 {
     if (empty($this->varValue)) {
         return;
     }
     if (!is_array($this->varValue)) {
         $this->varValue = array($this->varValue);
     } elseif (empty($this->varValue[0])) {
         $this->varValue = array();
     }
     if (empty($this->varValue)) {
         return;
     }
     // TinyMCE will pass the path instead of the ID
     if (strpos($this->varValue[0], \Config::get('uploadPath') . '/') === 0) {
         return;
     }
     // Ignore the numeric IDs when in switch mode (TinyMCE)
     if (\Input::get('switch')) {
         return;
     }
     // Return if the custom path is not within the upload path (see #8562)
     if ($this->path != '' && strpos($this->path, \Config::get('uploadPath') . '/') !== 0) {
         return;
     }
     $objFiles = \FilesModel::findMultipleByIds($this->varValue);
     if ($objFiles !== null) {
         $this->varValue = array_values($objFiles->fetchEach('path'));
     }
 }