PersistentResource
class PersistentResource implements ResourceMetaDataInterface, CacheAwareInterface (View source)
Model representing a persistable resource
Properties
protected string | $collectionName | Name of a collection whose storage is used for storing this resource and whose target is used for publishing. |
|
protected string | $filename | Filename which is used when the data of this resource is downloaded as a file or acting as a label |
|
protected int | $fileSize | The size of this object's data |
|
protected string | $relativePublicationPath | An optional relative path which can be used by a publishing target for structuring resources into directories |
|
protected string | $mediaType | The IANA media type of this resource |
|
protected string | $sha1 | SHA1 hash identifying the content attached to this resource |
|
protected string | $md5 | MD5 hash identifying the content attached to this resource |
|
protected bool | $protected | As soon as the PersistentResource has been published, modifying this object is not allowed |
|
protected bool | $lifecycleEventsActive | ||
protected bool | $deleted | An internal flag which tells if this PersistentResource object has been deleted during the current request |
|
protected ResourceManager | $resourceManager | ||
protected Environment | $environment | ||
protected string | $temporaryLocalCopyPathAndFilename |
Methods
Protects this PersistentResource if it has been persisted already.
Returns a stream for use with read-only file operations such as reading or copying.
Sets the name of the collection this resource should be part of
Returns the name of the collection this resource is part of
Sets the filename which is used when this resource is downloaded or saved as a file
Gets the filename
Returns the file extension used for this resource
Sets a relative path which can be used by a publishing target for structuring resources into directories
Returns the relative publication path
Explicitly sets the Media Type for this resource
Returns the Media Type for this resource
Sets the size of the content of this resource
Returns the size of the content of this resource
Returns the SHA1 hash of the content of this resource
Sets the SHA1 hash of the content of this resource
Returns the path to a local file representing this resource for use with read-only file operations such as reading or copying.
Doctrine lifecycle event callback which is triggered on "postPersist" events.
Doctrine lifecycle event callback which is triggered on "preRemove" events.
A very internal function which disables the Doctrine lifecycle events for this PersistentResource.
An internal method which marks the PersistentResource object as deleted.
An internal method which tells if this PersistentResource object has been already deleted by the ResourceManager.
Returns a string which distinctly identifies this object and thus can be used as an identifier for cache entries related to this object. Introduced through the CacheAwareInterface.
Throws an exception if this PersistentResource object is protected against modifications.
Takes care of removing a possibly existing temporary local copy on destruction of this object.
Details
void
initializeObject(int $initializationCause)
Protects this PersistentResource if it has been persisted already.
resource|bool
getStream()
Returns a stream for use with read-only file operations such as reading or copying.
Note: The caller is responsible to close the returned resource by calling fclose($stream)
void
setCollectionName(string $collectionName)
Sets the name of the collection this resource should be part of
string
getCollectionName()
Returns the name of the collection this resource is part of
void
setFilename(string $filename)
Sets the filename which is used when this resource is downloaded or saved as a file
string
getFilename()
Gets the filename
string
getFileExtension()
Returns the file extension used for this resource
void
setRelativePublicationPath(string $path)
Sets a relative path which can be used by a publishing target for structuring resources into directories
string
getRelativePublicationPath()
Returns the relative publication path
void
setMediaType(string $mediaType)
Explicitly sets the Media Type for this resource
string
getMediaType()
Returns the Media Type for this resource
void
setFileSize(string $fileSize)
Sets the size of the content of this resource
string
getFileSize()
Returns the size of the content of this resource
string
getSha1()
Returns the SHA1 hash of the content of this resource
void
setSha1(string $sha1)
Sets the SHA1 hash of the content of this resource
string
getMd5()
deprecated
deprecated
Returns the MD5 hash of the content of this resource
void
setMd5(string $md5)
deprecated
deprecated
Sets the MD5 hash of the content of this resource
string
createTemporaryLocalCopy()
Returns the path to a local file representing this resource for use with read-only file operations such as reading or copying.
Note that you must not store or publish file paths returned from this method as they will change with every request.
void
postPersist()
Doctrine lifecycle event callback which is triggered on "postPersist" events.
This method triggers the publication of this resource.
void
preRemove()
Doctrine lifecycle event callback which is triggered on "preRemove" events.
This method triggers the deletion of data related to this resource.
void
disableLifecycleEvents()
A very internal function which disables the Doctrine lifecycle events for this PersistentResource.
This is needed when some low-level operations need to be done, for example deleting a PersistentResource from the ResourceRepository without unpublishing the (probably not existing) data from the storage.
void
setDeleted(bool $flag = true)
An internal method which marks the PersistentResource object as deleted.
This method is called by the ResourceManager in order to prevent other code parts, for example the Doctrine lifecycle events, to delete this resource again.
bool
isDeleted()
An internal method which tells if this PersistentResource object has been already deleted by the ResourceManager.
string
getCacheEntryIdentifier()
Returns a string which distinctly identifies this object and thus can be used as an identifier for cache entries related to this object. Introduced through the CacheAwareInterface.
protected void
throwExceptionIfProtected()
Throws an exception if this PersistentResource object is protected against modifications.
void
shutdownObject()
Takes care of removing a possibly existing temporary local copy on destruction of this object.
Note: we can't use destruct() here because this would lead Doctrine to create a proxy method destruct() which will run __load(), which in turn will trigger the SQL protection in Flow Security, which will then discover that a possibly previously existing session has been half-destroyed already (see FLOW-121).