getInstance() public method

Accessor method for the underlying instance (model) object this attachment is defined on.
public getInstance ( ) : Codesleeve\Stapler\ORM\StaplerableInterface
return Codesleeve\Stapler\ORM\StaplerableInterface
Esempio n. 1
0
 /**
  * Generates the id partition of a record, e.g
  * return /000/001/234 for an id of 1234.
  *
  * @param Attachment $attachment
  * @param string $styleName
  * @return mixed
  */
 protected function idPartition(Attachment $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 null;
     }
 }