Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 17293 | Rev 17295 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 17293 Rev 17294
Línea 884... Línea 884...
884
 
884
 
Línea 885... Línea 885...
885
                $form->setData($data);
885
                $form->setData($data);
886
 
886
 
-
 
887
                // Validar los datos del formulario
Línea 887... Línea 888...
887
                // Validar los datos del formulario
888
                if ($form->isValid()) {
888
                if ($form->isValid()) {
-
 
889
 
889
                    $storage->setFiles($request->getFiles()->toArray());
890
                    // Verificar errores de carga de archivos
-
 
891
                    $files = $request->getFiles()->toArray();
890
 
892
                    if (!empty($files['image']['error'])) {
891
                    // Verificar y establecer el nombre de archivo actual
893
 
892
                    if (!$storage->setCurrentFilename('image')) {
894
                        return new JsonModel([
893
                        return new JsonModel([
895
                            'success'   => false,
894
                            'success'   => false,
Línea 896... Línea -...
896
                            'data'   =>  'ERROR_UPLOAD_FILE'
-
 
897
                        ]);
-
 
898
                    }
-
 
899
 
-
 
900
                    // Inicializar el procesamiento de imágenes
-
 
901
                    $storage = Storage::getInstance($this->config, $this->adapter);
895
                            'data'   => 'ERROR_UPLOAD_FILE'
902
                    $target_company_path = $storage->getPathCompany();
896
                        ]);
903
                    $target_user_path = $storage->getPathUser();
897
                    }
904
 
898
 
905
                    // Eliminar la imagen existente de la empresa si está presente
899
                    // Eliminar la imagen existente de la empresa si está presente
906
                    if ($company->image) {
900
                    if ($company->image) {
907
                        if (!$storage->deleteFile($target_company_path, $company->uuid, $company->image)) {
901
                        if (!$storage->deleteFile($target_company_path, $company->uuid, $company->image)) {
908
                            return new JsonModel([
902
                            return new JsonModel([
909
                                'success'   => false,
903
                                'success'   => false,
Línea 910... Línea -...
910
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
-
 
911
                            ]);
-
 
912
                        }
-
 
913
                    }
-
 
914
 
-
 
915
                    $storage->setFiles($request->getFiles()->toArray());
-
 
916
 
-
 
917
                    // Verificar y establecer el nombre de archivo actual
-
 
918
                    if (!$storage->setCurrentFilename('image')) {
-
 
919
                        return new JsonModel([
-
 
920
                            'success'   => false,
-
 
921
                            'data'   => 'ERROR_UPLOAD_FILE'
904
                                'data'   =>  'ERROR_THERE_WAS_AN_ERROR'
922
                        ]);
905
                            ]);
923
                    }
906
                        }
924
 
907
                    }
Línea 943... Línea 926...
943
                        if (!$storage->deleteFile($target_company_path, $company->uuid, $company->image)) {
926
                        if (!$storage->deleteFile($target_company_path, $company->uuid, $company->image)) {
944
                            return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
927
                            return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
945
                        }
928
                        }
946
                    }
929
                    }
Línea 947... Línea -...
947
 
-
 
948
 
930
 
949
                    // Actualizar el perfil con la nueva imagen
931
                    // Actualizar el perfil con la nueva imagen
950
                    $company->image = $target_filename;
932
                    $company->image = $filename;
951
                    if (!$companyMapper->updateImage($company)) {
933
                    if (!$companyMapper->updateImage($company)) {
952
                        return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
934
                        return $this->_createSimpleErrorResponse('ERROR_THERE_WAS_AN_ERROR');
Línea 953... Línea 935...
953
                    }
935
                    }
Línea 1012... Línea 994...
1012
                        'data'   => $messages
994
                        'data'   => $messages
1013
                    ]);
995
                    ]);
1014
                }
996
                }
1015
            }
997
            }
Línea 1016... Línea -...
1016
 
-
 
1017
            $storage = Storage::getInstance($this->config, $this->adapter);
-
 
1018
 
998
 
1019
            return new JsonModel([
999
            return new JsonModel([
1020
                'success'   => true,
1000
                'success'   => true,
Línea 1021... Línea 1001...
1021
                'data' => $storage->getCompanyImage($company)
1001
                'data' => $company->image
1022
 
1002
 
Línea 1023... Línea 1003...
1023
            ]);
1003
            ]);