Example #1
0
 protected function getUuid(AttachmentInterface $attachment)
 {
     return $attachment->getInstance()->uuid;
 }
Example #2
0
 /**
  * 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 AttachmentInterface $attachedFile
  *
  * @return S3Client
  */
 public static function getS3ClientInstance(AttachmentInterface $attachedFile)
 {
     $modelName = $attachedFile->getInstanceClass();
     $attachmentName = $attachedFile->getConfig()->name;
     $key = "{$modelName}.{$attachmentName}";
     if (array_key_exists($key, static::$s3Clients)) {
         return static::$s3Clients[$key];
     }
     static::$s3Clients[$key] = static::buildS3Client($attachedFile);
     return static::$s3Clients[$key];
 }
Example #3
0
 /**
  * Generates the id partition of a record, e.g
  * return /000/001/234 for an id of 1234.
  *
  * @param AttachmentInterface $attachment
  * @param string              $styleName
  *
  * @return mixed
  */
 protected function idPartition(AttachmentInterface $attachment, $styleName = '')
 {
     $id = $this->ensurePrintable($attachment->getInstance()->getKey());
     if (is_numeric($id)) {
         return implode('/', str_split(sprintf('%09d', $id), 3));
     } elseif (is_string($id)) {
         return implode('/', array_slice(str_split($id, 3), 0, 3));
     } else {
         return;
     }
 }