|
384 | 384 | </cfif> |
385 | 385 | </cffunction> |
386 | 386 |
|
| 387 | + <cffunction name="onArchive" access="public" output="false" returntype="string" hint="Called from setData when an object is deleted"> |
| 388 | + <cfargument name="typename" required="true" type="string" hint="The name of the type that this field is part of."> |
| 389 | + <cfargument name="stObject" required="true" type="struct" hint="The object of the record that this field is part of."> |
| 390 | + <cfargument name="stMetadata" required="true" type="struct" hint="This is the metadata that is either setup as part of the type.cfc or overridden when calling ft:object by using the stMetadata argument."> |
| 391 | + <cfargument name="archiveID" type="uuid" required="true" hint="The ID of the new archive" /> |
| 392 | + |
| 393 | + <cfset var stInfo = application.fc.lib.cloudinary.getURLInformation(arguments.stObject[arguments.stMetadata.name]) /> |
| 394 | + <cfset var archiveFile = "" /> |
| 395 | + |
| 396 | + <cfif len(stInfo.source) and application.fc.lib.cdn.ioFileExists(location="images",file=stInfo.source)> |
| 397 | + <cfset archiveFile = "/#arguments.stObject.typename#/#arguments.archiveID#.#arguments.stMetadata.name#.#ListLast(stInfo.source,'.')#" /> |
| 398 | + |
| 399 | + <cfset application.fc.lib.cdn.ioCopyFile(source_location="images",source_file=stInfo.source,dest_location="archive",dest_file=archiveFile) /> |
| 400 | + </cfif> |
| 401 | + |
| 402 | + <cfreturn archiveFile /> |
| 403 | + </cffunction> |
| 404 | + |
| 405 | + <cffunction name="onRollback" access="public" output="false" returntype="string" hint="Called from setData when an object is deleted"> |
| 406 | + <cfargument name="typename" required="true" type="string" hint="The name of the type that this field is part of."> |
| 407 | + <cfargument name="stObject" required="true" type="struct" hint="The object of the record that this field is part of."> |
| 408 | + <cfargument name="stMetadata" required="true" type="struct" hint="This is the metadata that is either setup as part of the type.cfc or overridden when calling ft:object by using the stMetadata argument."> |
| 409 | + <cfargument name="archiveID" type="uuid" required="true" hint="The ID of the archive being rolled back" /> |
| 410 | + |
| 411 | + <cfset var stInfo = application.fc.lib.cloudinary.getURLInformation(arguments.stObject[arguments.stMetadata.name]) /> |
| 412 | + <cfset var archiveFile = "/#arguments.stObject.typename#/#arguments.archiveID#.#arguments.stMetadata.name#.#ListLast(arguments.stObject[arguments.stMetadata.name],'.')#" /> |
| 413 | + |
| 414 | + <cfif len(stInfo.source) and application.fc.lib.cdn.ioFileExists(location="archive", file=archiveFile) and not application.fc.lib.cdn.ioFileExists(location="images", file=stInfo.source)> |
| 415 | + <cfset application.fc.lib.cdn.ioMoveFile(source_location="archive",source_file=archiveFile,dest_location="images",dest_file=stInfo.source) /> |
| 416 | + </cfif> |
| 417 | + |
| 418 | + <cfreturn arguments.stObject[arguments.stMetadata.name] /> |
| 419 | + </cffunction> |
| 420 | + |
387 | 421 | <cffunction name="getFileLocation" access="public" output="false" returntype="struct" hint="Returns information used to access the file: type (stream | redirect), path (file system path | absolute URL), filename, mime type"> |
388 | 422 | <cfargument name="objectid" type="string" required="false" default="" hint="Object to retrieve" /> |
389 | 423 | <cfargument name="typename" type="string" required="false" default="" hint="Type of the object to retrieve" /> |
|
0 commit comments