src/Model/Behavior/ProfferBehavior.php
protected function process($field, array $settings, EntityInterface $entity, ProfferPathInterface $path = null)
    {
        $path = $this->createPath($entity, $field, $settings, $path);

        if (is_array($entity->get($field)) && count(array_filter(array_keys($entity->get($field)), 'is_string')) > 0) {
            $uploadList = [$entity->get($field)];
        } else {
            $uploadList = [
                [
                    'name' => $entity->get('name'),
                    'type' => $entity->get('type'),
                    'tmp_name' => $entity->get('tmp_name'),
                    'error' => $entity->get('error'),
                    'size' => $entity->get('size'),
                ]
            ];
        }

        foreach ($uploadList as $upload) {
            if ($this->moveUploadedFile($upload['tmp_name'], $path->fullPath())) {
                $entity->set($field, $path->getFilename());
                $entity->set($settings['dir'], $path->getSeed());

                $this->createThumbnails($entity, $settings, $path);
            } else {
                throw new CannotUploadFileException("File `{$upload['name']}` could not be copied.");
            }
        }

        unset($path);
    }
protected function process($field, array $settings, EntityInterface $entity, ProfferPathInterface $path = null)
    {
        $path = $this->createPath($entity, $field, $settings, $path);

        if (is_array($entity->get($field)) && count(array_filter(array_keys($entity->get($field)), 'is_string')) > 0) {
            $uploadList = [$entity->get($field)];
        } else {
            $uploadList = [
                [
                    'name' => $entity->get('name'),
                    'type' => $entity->get('type'),
                    'tmp_name' => $entity->get('tmp_name'),
                    'error' => $entity->get('error'),
                    'size' => $entity->get('size'),
                ]
            ];
        }

        foreach ($uploadList as $upload) {
            if ($this->moveUploadedFile($upload['tmp_name'], $path->fullPath())) {
                $entity->set($field, $path->getFilename());
                $entity->set($settings['dir'], $path->getSeed());

                $this->createThumbnails($entity, $settings, $path);
            } else {
                throw new CannotUploadFileException("File `{$upload['name']}` could not be copied.");
            }
        }

        unset($path);
    }
protected function process ( $ field , array $ settings , EntityInterface $ entity , ProfferPathInterface $ path = null ) { $ path = $ this -> createPath ( $ entity , $ field , $ settings , $ path ) ; if ( is_array ( $ entity -> get ( $ field ) ) && count ( array_filter ( array_keys ( $ entity -> get ( $ field ) ) , 'is_string' ) ) > 0 ) { $ uploadList = [ $ entity -> get ( $ field ) ] ; } else { $ uploadList = [ [ 'name' => $ entity -> get ( 'name' ) , 'type' => $ entity -> get ( 'type' ) , 'tmp_name' => $ entity -> get ( 'tmp_name' ) , 'error' => $ entity -> get ( 'error' ) , 'size' => $ entity -> get ( 'size' ) , ] ] ; } foreach ( $ uploadList as $ upload ) { if ( $ this -> moveUploadedFile ( $ upload [ 'tmp_name' ] , $ path -> fullPath ( ) ) ) { $ entity -> set ( $ field , $ path -> getFilename ( ) ) ; $ entity -> set ( $ settings [ 'dir' ] , $ path -> getSeed ( ) ) ; $ this -> createThumbnails ( $ entity , $ settings , $ path ) ; } else { throw new CannotUploadFileException ( "File `{$upload['name']}` could not be copied." ) ; } } unset ( $ path ) ; }
Process any uploaded files, generate paths, move the files and kick off thumbnail generation if it's an image

@param string $field The upload field name
@param array $settings Array of upload settings for the field
@param \Cake\Datasource\EntityInterface $entity The current entity to process
@param \Proffer\Lib\ProfferPathInterface|null $path Inject an instance of ProfferPath

@throws \Exception If the file cannot be renamed / moved to the correct path

@return void
Process any uploaded files generate paths move the files and kick off thumbnail generation if it s an image