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 |
/** * Build an attachment object. * * @param \Codesleeve\Stapler\Interpolator * @return \Codesleeve\Stapler\Attachment */ protected function build_attachment() { Stapler::boot(); $instance = $this->build_mock_instance(); $interpolator = new Interpolator(); $attachmentConfig = new \Codesleeve\Stapler\AttachmentConfig('photo', ['styles' => [], 'placeholder_style' => 'original', 'url' => '/system/:attachment/:id_partition/:style/:filename', 'path' => ':app_root/public:url']); $imagine = m::mock('Imagine\\Image\\ImagineInterface'); $resizer = new \Codesleeve\Stapler\File\Image\Resizer($imagine); $attachment = new \Codesleeve\Stapler\Attachment($attachmentConfig, $interpolator, $resizer); $attachment->setInstance($instance); $storageDriver = new \Codesleeve\Stapler\Storage\Filesystem($attachment); $attachment->setStorageDriver($storageDriver); return $attachment; }