Overview
  • Package
  • Class
  • Tree
  • Todo

Packages

  • AddonValue
    • Interfaces
  • ApiV2Controllers
  • Category
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • Customer
    • Address
    • Country
    • CountryZone
    • Interfaces
    • Validation
    • ValueObjects
  • Email
    • Collections
    • Entities
    • Exceptions
    • Interfaces
    • Repository
    • ValueObjects
  • Http
    • Collections
    • Exceptions
    • Factories
    • Interfaces
    • ValueObjects
  • Loaders
    • CrossCuttingLoader
    • GXCoreLoader
    • Interfaces
  • None
  • Order
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Repositories
    • Storages
    • ValueObjects
  • Product
    • Collections
    • Entities
    • Factories
    • Interfaces
    • Providers
    • Repositories
    • Storages
  • ProductModule
    • Collections
    • Deleter
    • Entities
    • Factories
    • Interface
    • Interfaces
    • Reader
    • Repositories
    • Writer
  • Shared
    • Exceptions
    • FileSystem
    • Interfaces
    • Storage
    • Types
  • Statistics
    • Interfaces
  • UserConfiguration
    • Interfaces
    • Repository

Classes

  • AttachmentsHandler
  • EmailFactory
  • EmailService
  • MailerAdapter

Class AttachmentsHandler

Class AttachmentsHandler

This class will handle the email attachments organization. Every email must have its own attachments directory so that we can avoid file issues between emails.

AttachmentsHandler implements AttachmentsHandlerInterface
Package: Email
Category: System
Located at SystemServices/Email/AttachmentsHandler.inc.php

Methods summary

public
# __construct( string $p_uploadsDirPath )

Class Constructor

Class Constructor

Parameters

$p_uploadsDirPath

Path to the server's "uploads" directory. The uploads directory must already contain a "tmp" and an "attachments" directory created by an FTP client (resolves permission problems).

Throws

InvalidArgumentException
If the provided argument is not valid.
public EmailAttachment
# uploadAttachment( EmailAttachmentInterface $attachment )

Upload an attachment to "uploads/tmp" directory.

Upload an attachment to "uploads/tmp" directory.

This method takes the uploaded file information and places it in the "uploads/tmp" directory as a temporary place, until the "uploadEmailCollection" moves it to the final destination.

Parameters

$attachment
Contains the file information (path is required).

Returns

EmailAttachment
Returns an EmailAttachment instance with the new attachment path.

Throws

Exception
If method cannot copy the file from the PHP temp dir to the destination path.

Implementation of

AttachmentsHandlerInterface::uploadAttachment()
public
# deleteAttachment( EmailAttachmentInterface $attachment )

Removes a single email attachment.

Removes a single email attachment.

Parameters

$attachment
E-Mail attachment.

Implementation of

AttachmentsHandlerInterface::deleteAttachment()
public
# uploadEmailCollection( EmailCollectionInterface $collection )

Process attachments for each email in collection.

Process attachments for each email in collection.

Important! Use this method after you save the emails into the database. The reason is that this property separates each attachment file by its email ID, a value that is only accessible after the email is already saved.

Deprecated

Since v2.3.3.0 this method is marked as deprecated and will be removed from the class.

Parameters

$collection

Passed by reference, contains emails of which the attachments must be processed.

Codecoverageignore

Implementation of

AttachmentsHandlerInterface::uploadEmailCollection()
public
# deleteEmailCollection( EmailCollectionInterface $collection )

Delete attachments for each email in collection.

Delete attachments for each email in collection.

Every email has its own attachments directory. When emails are deleted we need to remove their respective attachments.

Deprecated

Since v2.3.3.0 this method is marked as deprecated and will be removed from the class.

Parameters

$collection
Contains email records to be deleted.

Codecoverageignore

Implementation of

AttachmentsHandlerInterface::deleteEmailCollection()
public integer
# getAttachmentsSize( )

Get attachments directory file size in bytes.

Get attachments directory file size in bytes.

Returns

integer
Returns the size in bytes.

Link

http://stackoverflow.com/a/21409562

Implementation of

AttachmentsHandlerInterface::getAttachmentsSize()
public array
# deleteOldAttachments( DateTime $removalDate )

Delete old attachments prior to removal date.

Delete old attachments prior to removal date.

This method will remove all the files and directories that are prior to the given date. It will return removal information so that user can see how much disc spaces was set free.

Parameters

$removalDate
From this date and before the attachment files will be removed.

Returns

array
Returns an array which contains the "count" and "size" values or the operation.

Implementation of

AttachmentsHandlerInterface::deleteOldAttachments()
public
# backupEmailAttachments( EmailInterface & $email )

Process email attachments.

Process email attachments.

This method will move all the email attachments to the "uploads/attachments" directory and store them there for future reference and history navigation purposes. The email needs to be saved first because the email ID will be used to distinguish the emails.

Parameters

$email
Passed by reference, contains the email data.

Implementation of

AttachmentsHandlerInterface::backupEmailAttachments()
public
# deleteEmailAttachments( EmailInterface $email )

Deletes email attachments.

Deletes email attachments.

This method will remove all the email attachments from the server.

Parameters

$email
Contains the email information.

Implementation of

AttachmentsHandlerInterface::deleteEmailAttachments()
public
# emptyTempDirectory( )

Removes all files within the "uploads/tmp" directory.

Removes all files within the "uploads/tmp" directory.

There might be cases where old unused files are left within the "tmp" directory and they need to be deleted. This function will remove all these files.

Implementation of

AttachmentsHandlerInterface::emptyTempDirectory()

Properties summary

protected string $uploadsDirPath

Full server path to "uploads" directory.

Full server path to "uploads" directory.

#
API documentation generated by ApiGen