/** * @param \TYPO3\CMS\Core\Resource\File $file * @return $this */ public function extractMetadata(File $file) { $extractionServices = $this->getExtractorRegistry()->getExtractorsWithDriverSupport($this->storage->getDriverType()); $newMetaData = array(0 => $file->_getMetaData()); foreach ($extractionServices as $service) { if ($service->canProcess($file)) { $newMetaData[$service->getPriority()] = $service->extractMetaData($file, $newMetaData); } } ksort($newMetaData); $metaData = array(); foreach ($newMetaData as $data) { $metaData = array_merge($metaData, $data); } $file->_updateMetaDataProperties($metaData); $this->getMetaDataRepository()->update($file->getUid(), $metaData); $this->getFileIndexRepository()->updateIndexingTime($file->getUid()); return $this; }
/** * Since the core desperately needs image sizes in metadata table put them there * This should be called after every "content" update and "record" creation * * @param File $fileObject */ protected function extractRequiredMetaData(File $fileObject) { // since the core desperately needs image sizes in metadata table do this manually // prevent doing this for remote storages, remote storages must provide the data with extractors if ($fileObject->getType() == File::FILETYPE_IMAGE && $this->storage->getDriverType() === 'Local') { $rawFileLocation = $fileObject->getForLocalProcessing(FALSE); $imageInfo = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Type\\File\\ImageInfo', $rawFileLocation); $metaData = array('width' => $imageInfo->getWidth(), 'height' => $imageInfo->getHeight()); $this->getMetaDataRepository()->update($fileObject->getUid(), $metaData); $fileObject->_updateMetaDataProperties($metaData); } }
/** * Since the core desperately needs image sizes in metadata table put them there * This should be called after every "content" update and "record" creation * * @param File $fileObject */ protected function extractRequiredMetaData(File $fileObject) { // since the core desperately needs image sizes in metadata table do this manually // prevent doing this for remote storages, remote storages must provide the data with extractors if ($fileObject->getType() == File::FILETYPE_IMAGE && $this->storage->getDriverType() === 'Local') { $rawFileLocation = $fileObject->getForLocalProcessing(FALSE); $metaData = array(); list($metaData['width'], $metaData['height']) = getimagesize($rawFileLocation); $this->getMetaDataRepository()->update($fileObject->getUid(), $metaData); $fileObject->_updateMetaDataProperties($metaData); } }
/** * Determines whether the passed storage object and record (sys_file_storage) can be * seen as equivalent during import. * * @param ResourceStorage $storageObject The storage object which should get compared * @param array $storageRecord The storage record which should get compared * @return bool Returns TRUE when both object storages can be seen as equivalent */ protected function isEquivalentObjectStorage(ResourceStorage $storageObject, array $storageRecord) { // compare the properties: driver, writable and online if ($storageObject->getDriverType() === $storageRecord['driver'] && (bool) $storageObject->isWritable() === (bool) $storageRecord['is_writable'] && (bool) $storageObject->isOnline() === (bool) $storageRecord['is_online']) { $storageRecordConfiguration = ResourceFactory::getInstance()->convertFlexFormDataToConfigurationArray($storageRecord['configuration']); $storageObjectConfiguration = $storageObject->getConfiguration(); // compare the properties: pathType and basePath if ($storageRecordConfiguration['pathType'] === $storageObjectConfiguration['pathType'] && $storageRecordConfiguration['basePath'] === $storageObjectConfiguration['basePath']) { return true; } } return false; }