PHP Class Codesleeve\Stapler\Attachment

Afficher le fichier Open project: codesleeve/stapler Class Usage Examples

Protected Properties

Свойство Type Description
$config Codesleeve\Stapler\AttachmentConfig An instance of the configuration class.
$instance Codesleeve\Stapler\ORM\StaplerableInterface The model instance that the attachment belongs to.
$interpolator Codesleeve\Stapler\Interfaces\Interpolator An instance of the interpolator class for processing interpolations.
$queuedForDeletion array The uploaded/resized files that have been queued up for deletion.
$queuedForWrite array The uploaded/resized files that have been queued up to be written to storage.
$resizer Codesleeve\Stapler\File\Image\Resizer An instance of the resizer library that's being used for image processing.
$storageDriver StorageInterface. An instance of the underlying storage driver that is being used.
$uploadedFile Codesleeve\Stapler\Interfaces\File The uploaded file object for the attachment.

Méthodes publiques

Méthode Description
__call ( string $method, array $parameters ) : mixed Handle dynamic method calls on the attachment.
__construct ( Codesleeve\Stapler\AttachmentConfig $config, Codesleeve\Stapler\Interfaces\Interpolator $interpolator, Codesleeve\Stapler\Interfaces\Resizer $resizer ) Constructor method.
__get ( string $optionName ) : mixed Handle the dynamic retrieval of attachment options.
__set ( string $name, mixed $value ) Handle the dynamic setting of attachment options.
afterDelete ( Codesleeve\Stapler\ORM\StaplerableInterface $instance ) Process the delete queue.
afterSave ( Codesleeve\Stapler\ORM\StaplerableInterface $instance ) Process the write queue.
beforeDelete ( Codesleeve\Stapler\ORM\StaplerableInterface $instance ) Queue up this attachments files for deletion.
clear ( array $stylesToClear = [] ) Queues up all or some of this attachments uploaded files/images for deletion.
clearAttributes ( ) Clear (set to null) all attachment related model attributes.
contentType ( ) : string Returns the content type of the file as originally assigned to this attachment's model.
createdAt ( ) : string Returns the creation time of the file as originally assigned to this attachment's model.
destroy ( array $stylesToClear = [] ) Removes all uploaded files (from storage) for this attachment.
getConfig ( ) : array Accessor method for the Config property.
getInstance ( ) : Codesleeve\Stapler\ORM\StaplerableInterface Accessor method for the underlying instance (model) object this attachment is defined on.
getInstanceClass ( ) : string Returns the class type of the attachment's underlying model instance.
getInterpolator ( ) : Codesleeve\Stapler\Interfaces\Interpolator Accessor method for the interpolator property.
getQueuedForDeletion ( ) : array Accessor method for the QueuedForDeletion property.
getResizer ( ) : Resizer Accessor method for the uploadedFile property.
getStorageDriver ( ) : Codesleeve\Stapler\Interfaces\Storage Accessor method for the storageDriver property.
getUploadedFile ( ) : Codesleeve\Stapler\Interfaces\File Accessor method for the uploadedFile property.
instanceWrite ( string $property, mixed $value ) Set an attachment attribute on the underlying model instance.
jsonSerialize ( ) : array Return a JSON representation of this class.
originalFilename ( ) : string Returns the name of the file as originally assigned to this attachment's model.
path ( string $styleName = '' ) : string Generates the file system path to an uploaded file (or a resized version of it).
reprocess ( ) Rebuilds the images for this attachment.
save ( ) Flushes the queuedForDeletion and queuedForWrite arrays.
setConfig ( Codesleeve\Stapler\AttachmentConfig $config ) Mutator method for the config property.
setInstance ( Codesleeve\Stapler\ORM\StaplerableInterface $instance ) Mutator method for the instance property.
setInterpolator ( Codesleeve\Stapler\Interfaces\Interpolator $interpolator ) Mutator method for the interpolator property.
setQueuedForDeletion ( array $array ) Mutator method for the QueuedForDeletion property.
setResizer ( Codesleeve\Stapler\Interfaces\Resizer $resizer ) Mutator method for the resizer property.
setStorageDriver ( Codesleeve\Stapler\Interfaces\Storage $storageDriver ) Mutator method for the storageDriver property.
setUploadedFile ( mixed $uploadedFile ) Mutator method for the uploadedFile property.
size ( ) : integer Returns the size of the file as originally assigned to this attachment's model.
updatedAt ( ) : string Returns the last modified time of the file as originally assigned to this attachment's model.
url ( string $styleName = '' ) : string Generates the url to an uploaded file (or a resized version of it).

Méthodes protégées

Méthode Description
defaultPath ( string $styleName = '' ) : string Generates the default path if no file attachment is present.
defaultUrl ( string $styleName = '' ) : string Generates the default url if no file attachment is present.
flushDeletes ( ) Process the queuedForDeletion que.
flushWrites ( ) Process the queuedForWrite que.
queueAllForDeletion ( ) Add all uploaded files (across all image styles) to the queuedForDeletion queue.
queueAllForWrite ( ) Fill the queuedForWrite que with all of this attachment's styles.
queueSomeForDeletion ( array $stylesToClear ) Add a subset (filtered via style) of the uploaded files for this attachment to the queuedForDeletion queue.

Method Details

__call() public méthode

This allows us to call methods on the underlying storage driver directly via the attachment.
public __call ( string $method, array $parameters ) : mixed
$method string
$parameters array
Résultat mixed

__construct() public méthode

Constructor method.
public __construct ( Codesleeve\Stapler\AttachmentConfig $config, Codesleeve\Stapler\Interfaces\Interpolator $interpolator, Codesleeve\Stapler\Interfaces\Resizer $resizer )
$config Codesleeve\Stapler\AttachmentConfig
$interpolator Codesleeve\Stapler\Interfaces\Interpolator
$resizer Codesleeve\Stapler\Interfaces\Resizer

__get() public méthode

Style options will be converted into a php stcClass.
public __get ( string $optionName ) : mixed
$optionName string
Résultat mixed

__set() public méthode

Handle the dynamic setting of attachment options.
public __set ( string $name, mixed $value )
$name string
$value mixed

afterDelete() public méthode

Process the delete queue.
public afterDelete ( Codesleeve\Stapler\ORM\StaplerableInterface $instance )
$instance Codesleeve\Stapler\ORM\StaplerableInterface

afterSave() public méthode

Process the write queue.
public afterSave ( Codesleeve\Stapler\ORM\StaplerableInterface $instance )
$instance Codesleeve\Stapler\ORM\StaplerableInterface

beforeDelete() public méthode

Queue up this attachments files for deletion.
public beforeDelete ( Codesleeve\Stapler\ORM\StaplerableInterface $instance )
$instance Codesleeve\Stapler\ORM\StaplerableInterface

clear() public méthode

Queues up all or some of this attachments uploaded files/images for deletion.
public clear ( array $stylesToClear = [] )
$stylesToClear array

clearAttributes() public méthode

Clear (set to null) all attachment related model attributes.
public clearAttributes ( )

contentType() public méthode

Lives in the _content_type attribute of the model.
public contentType ( ) : string
Résultat string

createdAt() public méthode

Lives in the _created_at attribute of the model. This attribute may conditionally exist on the model, it is not one of the four required fields.
public createdAt ( ) : string
Résultat string

defaultPath() protected méthode

Generates the default path if no file attachment is present.
protected defaultPath ( string $styleName = '' ) : string
$styleName string
Résultat string

defaultUrl() protected méthode

Generates the default url if no file attachment is present.
protected defaultUrl ( string $styleName = '' ) : string
$styleName string
Résultat string

destroy() public méthode

This method does not clear out attachment attributes on the model instance.
public destroy ( array $stylesToClear = [] )
$stylesToClear array

flushDeletes() protected méthode

Process the queuedForDeletion que.
protected flushDeletes ( )

flushWrites() protected méthode

Process the queuedForWrite que.
protected flushWrites ( )

getConfig() public méthode

Accessor method for the Config property.
public getConfig ( ) : array
Résultat array

getInstance() public méthode

Accessor method for the underlying instance (model) object this attachment is defined on.
public getInstance ( ) : Codesleeve\Stapler\ORM\StaplerableInterface
Résultat Codesleeve\Stapler\ORM\StaplerableInterface

getInstanceClass() public méthode

Returns the class type of the attachment's underlying model instance.
public getInstanceClass ( ) : string
Résultat string

getInterpolator() public méthode

Accessor method for the interpolator property.
public getInterpolator ( ) : Codesleeve\Stapler\Interfaces\Interpolator
Résultat Codesleeve\Stapler\Interfaces\Interpolator

getQueuedForDeletion() public méthode

Accessor method for the QueuedForDeletion property.
public getQueuedForDeletion ( ) : array
Résultat array

getResizer() public méthode

Accessor method for the uploadedFile property.
public getResizer ( ) : Resizer
Résultat Resizer

getStorageDriver() public méthode

Accessor method for the storageDriver property.
public getStorageDriver ( ) : Codesleeve\Stapler\Interfaces\Storage
Résultat Codesleeve\Stapler\Interfaces\Storage

getUploadedFile() public méthode

Accessor method for the uploadedFile property.
public getUploadedFile ( ) : Codesleeve\Stapler\Interfaces\File
Résultat Codesleeve\Stapler\Interfaces\File

instanceWrite() public méthode

Set an attachment attribute on the underlying model instance.
public instanceWrite ( string $property, mixed $value )
$property string
$value mixed

jsonSerialize() public méthode

Return a JSON representation of this class.
public jsonSerialize ( ) : array
Résultat array

originalFilename() public méthode

Lives in the _file_name attribute of the model.
public originalFilename ( ) : string
Résultat string

path() public méthode

This is used for saving files, etc.
public path ( string $styleName = '' ) : string
$styleName string
Résultat string

queueAllForDeletion() protected méthode

Add all uploaded files (across all image styles) to the queuedForDeletion queue.
protected queueAllForDeletion ( )

queueAllForWrite() protected méthode

Fill the queuedForWrite que with all of this attachment's styles.
protected queueAllForWrite ( )

queueSomeForDeletion() protected méthode

Add a subset (filtered via style) of the uploaded files for this attachment to the queuedForDeletion queue.
protected queueSomeForDeletion ( array $stylesToClear )
$stylesToClear array

reprocess() public méthode

Rebuilds the images for this attachment.
public reprocess ( )

save() public méthode

Flushes the queuedForDeletion and queuedForWrite arrays.
public save ( )

setConfig() public méthode

Mutator method for the config property.
public setConfig ( Codesleeve\Stapler\AttachmentConfig $config )
$config Codesleeve\Stapler\AttachmentConfig

setInstance() public méthode

This provides a mechanism for the attachment to access properties of the corresponding model instance it's attached to.
public setInstance ( Codesleeve\Stapler\ORM\StaplerableInterface $instance )
$instance Codesleeve\Stapler\ORM\StaplerableInterface

setInterpolator() public méthode

Mutator method for the interpolator property.
public setInterpolator ( Codesleeve\Stapler\Interfaces\Interpolator $interpolator )
$interpolator Codesleeve\Stapler\Interfaces\Interpolator

setQueuedForDeletion() public méthode

Mutator method for the QueuedForDeletion property.
public setQueuedForDeletion ( array $array )
$array array

setResizer() public méthode

Mutator method for the resizer property.
public setResizer ( Codesleeve\Stapler\Interfaces\Resizer $resizer )
$resizer Codesleeve\Stapler\Interfaces\Resizer

setStorageDriver() public méthode

Mutator method for the storageDriver property.
public setStorageDriver ( Codesleeve\Stapler\Interfaces\Storage $storageDriver )
$storageDriver Codesleeve\Stapler\Interfaces\Storage

setUploadedFile() public méthode

Accepts the following inputs: - An absolute string url (for fetching remote files). - An array (data parsed from the $_FILES array), - A Symfony uploaded file object.
public setUploadedFile ( mixed $uploadedFile )
$uploadedFile mixed

size() public méthode

Lives in the _file_size attribute of the model.
public size ( ) : integer
Résultat integer

updatedAt() public méthode

Lives in the _updated_at attribute of the model.
public updatedAt ( ) : string
Résultat string

url() public méthode

Generates the url to an uploaded file (or a resized version of it).
public url ( string $styleName = '' ) : string
$styleName string
Résultat string

Property Details

$config protected_oe property

An instance of the configuration class.
protected AttachmentConfig,Codesleeve\Stapler $config
Résultat Codesleeve\Stapler\AttachmentConfig

$instance protected_oe property

The model instance that the attachment belongs to.
protected StaplerableInterface,Codesleeve\Stapler\ORM $instance
Résultat Codesleeve\Stapler\ORM\StaplerableInterface

$interpolator protected_oe property

An instance of the interpolator class for processing interpolations.
protected Interpolator,Codesleeve\Stapler\Interfaces $interpolator
Résultat Codesleeve\Stapler\Interfaces\Interpolator

$queuedForDeletion protected_oe property

The uploaded/resized files that have been queued up for deletion.
protected array $queuedForDeletion
Résultat array

$queuedForWrite protected_oe property

The uploaded/resized files that have been queued up to be written to storage.
protected array $queuedForWrite
Résultat array

$resizer protected_oe property

An instance of the resizer library that's being used for image processing.
protected Resizer,Codesleeve\Stapler\File\Image $resizer
Résultat Codesleeve\Stapler\File\Image\Resizer

$storageDriver protected_oe property

An instance of the underlying storage driver that is being used.
protected StorageInterface. $storageDriver
Résultat StorageInterface.

$uploadedFile protected_oe property

The uploaded file object for the attachment.
protected File,Codesleeve\Stapler\Interfaces $uploadedFile
Résultat Codesleeve\Stapler\Interfaces\File