public function addUpload(EntityInterface $entity, $upload)
    {
        $tags = [];
        $path = $upload;
        if (is_array($upload)) {
            $tags = reset($upload);
            $path = reset(array_flip($upload));
        }
        $file = Configure::read('Attachments.tmpUploadsPath') . $path;
        $attachment = $this->createAttachmentEntity($entity, $file, $tags);
        $save = $this->save($attachment);
        if ($save) {
            return $attachment;
        }
        return $save;
    }
public function addUpload(EntityInterface $entity, $upload)
    {
        $tags = [];
        $path = $upload;
        if (is_array($upload)) {
            $tags = reset($upload);
            $path = reset(array_flip($upload));
        }
        $file = Configure::read('Attachments.tmpUploadsPath') . $path;
        $attachment = $this->createAttachmentEntity($entity, $file, $tags);
        $save = $this->save($attachment);
        if ($save) {
            return $attachment;
        }
        return $save;
    }
public function addUpload ( EntityInterface $ entity , $ upload ) { $ tags = [ ] ; $ path = $ upload ; if ( is_array ( $ upload ) ) { $ tags = reset ( $ upload ) ; $ path = reset ( array_flip ( $ upload ) ) ; } $ file = Configure :: read ( 'Attachments.tmpUploadsPath' ) . $ path ; $ attachment = $ this -> createAttachmentEntity ( $ entity , $ file , $ tags ) ; $ save = $ this -> save ( $ attachment ) ; if ( $ save ) { return $ attachment ; } return $ save ; }
Save one Attachemnt

@param EntityInterface $entity Entity
@param string $upload String to uploaded file or ['path_to_file' => [tag1, tag2, tag3, ...]]
@return entity
Save one Attachemnt