public function addUploads(EntityInterface $entity, array $uploads)
    {
        $attachments = [];
        foreach ($uploads as $path => $tags) {
            if (!(array_keys($uploads) !== range(0, count($uploads) - 1))) {
                // if only paths and no tags
                $path = $tags;
                $tags = [];
            }
            $file = Configure::read('Attachments.tmpUploadsPath') . $path;

            $attachment = $this->createAttachmentEntity($entity, $file, $tags);
            $this->save($attachment);
            $attachments[] = $attachment;
        }
        $entity->attachments = $attachments;
    }
public function addUploads(EntityInterface $entity, array $uploads)
    {
        $attachments = [];
        foreach ($uploads as $path => $tags) {
            if (!(array_keys($uploads) !== range(0, count($uploads) - 1))) {
                // if only paths and no tags
                $path = $tags;
                $tags = [];
            }
            $file = Configure::read('Attachments.tmpUploadsPath') . $path;

            $attachment = $this->createAttachmentEntity($entity, $file, $tags);
            $this->save($attachment);
            $attachments[] = $attachment;
        }
        $entity->attachments = $attachments;
    }
public function addUploads ( EntityInterface $ entity , array $ uploads ) { $ attachments = [ ] ; foreach ( $ uploads as $ path => $ tags ) { if ( ! ( array_keys ( $ uploads ) !== range ( 0 , count ( $ uploads ) - 1 ) ) ) { // if only paths and no tags $ path = $ tags ; $ tags = [ ] ; } $ file = Configure :: read ( 'Attachments.tmpUploadsPath' ) . $ path ; $ attachment = $ this -> createAttachmentEntity ( $ entity , $ file , $ tags ) ; $ this -> save ( $ attachment ) ; $ attachments [ ] = $ attachment ; } $ entity -> attachments = $ attachments ; }
Takes the array from the attachments area hidden form field and creates
attachment records for the given entity

@param EntityInterface $entity Entity to attach the files to
@param array $uploads List of paths relative to the Attachments.tmpUploadsPath
config value or ['path_to_file' => [tag1, tag2, tag3, ...]]
@return void
Takes the array from the attachments area hidden form field and creates attachment records for the given entity