/** * Return an S3Client object for a specific attachment type. * If no instance has been defined yet we'll buld one and then * cache it on the s3Clients property (for the current request only). * * @param Expstudio\LaraClip\Attachment $attachedFile * @return SS3Client */ public function getS3Client($attachedFile) { $modelName = $attachedFile->getInstanceClass(); $attachmentName = $attachedFile->getConfig()->attachmentName; $key = "{$modelName}.{$attachmentName}"; if (array_key_exists($key, $this->s3Clients)) { return $this->s3Clients[$key]; } $this->s3Clients[$key] = $this->buildS3Client($attachedFile); return $this->s3Clients[$key]; }