/**
  * Record a file to our temporary directory.
  * 
  * @param object Asset $asset
  * @param object FileRecord $fileRecord
  * @return void
  * @access protected
  */
 protected function recordFile(Asset $asset, FileRecord $fileRecord)
 {
     $idMgr = Services::getService('Id');
     $parts = $fileRecord->getPartsByPartStructure($idMgr->getId("FILE_NAME"));
     $part = $parts->next();
     $fileName = preg_replace('/[^a-z0-9._-]/i', '_', $part->getValue());
     if (!strlen(trim($fileName, '._'))) {
         $fileName = $recordIdString;
     }
     $fileParts = pathinfo($fileName);
     $base = $fileParts['filename'];
     $extension = $fileParts['extension'];
     $dataParts = $fileRecord->getPartsByPartStructure($idMgr->getId("FILE_DATA"));
     $dataPart = $dataParts->next();
     $i = 1;
     while (file_exists($this->filePath . '/' . $fileName)) {
         $fileName = $base . '-' . $i . '.' . $extension;
         $i++;
     }
     file_put_contents($this->filePath . "/" . $fileName, $dataPart->getValue());
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function getData()
 {
     $data = parent::getData();
     $data['type'] = 'directory';
     return $data;
 }