/** * Returns the current class name, exclusively taking into account namespaces, e.g * 'Swingline\Stapler' will become Swingline. * * @param Attachment $attachment * @param string $styleName * @return string */ protected function getNamespace(Attachment $attachment, $styleName = '') { $classComponents = explode('\\', $attachment->getInstanceClass()); return implode('/', array_slice($classComponents, 0, count($classComponents) - 1)); }
/** * 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 Attachment $attachedFile * @return S3Client */ public static function getS3ClientInstance(Attachment $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]; }
/** * Returns the current class name, taking into account namespaces, e.g * 'Swingline\Stapler' will become Swingline/Stapler. * * @param Attachment $attachment * @param string $styleName * @return string */ protected function getClass(Attachment $attachment, $styleName = '') { return $this->handleBackslashes($attachment->getInstanceClass()); }