/** * Removes $aliasFile and references to it for the attribute. * * The eZImageFile entry as well as the file are only removed if this attribute was the last reference. * * @param string $aliasFile * * @return array bool true if something was actually done, false otherwise */ public function removeAliasFile($aliasFile) { if ($aliasFile == '') { throw new InvalidArgumentException("Expecting image file path"); } // We only delete the eZImageFile if it isn't referenced by attributes of the same id but different version/language if (eZImageFile::isReferencedByOtherAttributes($aliasFile, $this->ContentObjectAttributeData['id'], $this->ContentObjectAttributeData['version'], $this->ContentObjectAttributeData['language_code'])) { return; } eZImageFile::removeObject(eZImageFile::definition(), array('contentobject_attribute_id' => $this->ContentObjectAttributeData['id'], 'filepath' => $aliasFile)); // We only remove the image file if other eZImageFile of the same attribute use it (other versions) if (eZImageFile::isReferencedByOtherImageFiles($aliasFile, $this->ContentObjectAttributeData['id'])) { return; } // finally, remove file if applicable $file = eZClusterFileHandler::instance($aliasFile); if (!$file->exists()) { eZDebug::writeError("Image file {$aliasFile} does not exist, could not remove from disk", __METHOD__); return; } $file->delete(); eZDir::cleanupEmptyDirectories(dirname($aliasFile)); }