protected function purgeFiles()
    {
        //get record
        //validate and extract input
        $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields']));
        //extract primary key value
        $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a');
        $record = $this->getByPrimaryKey($primaryKeyValue);
        $fields = array_keys($this->uploadFieldsDefinitions);
        //loop defined upload fields
        foreach($fields as $field) {
            //skip other subject field (in case this subject handles upload for other tables)
            if(!isset($record->$field)) {
                continue;
            }
            //get record field value
            $fieldValue = json_decode($record->$field);
            //skip empty field
            if(!$fieldValue) {
                continue;
            }
            //ERRORE "Cannot use object of type stdClass as array" ALLA RIGA 230
            continue;
            //get posted value
            if($this->action == 'update') {
                $a = $input[$field];
                $fieldObject = json_decode($a);
                //$a = get_object_vars($a);
                //$postedInputs = array_keys($a);
            }
            //loop inputs
            foreach((array) $fieldValue as $hash => $input) {
                //if($this->action == 'delete' || !in_array($hash, $postedInputs)) {
                if($this->action == 'delete' || !isset($fieldObject->$hash)) {
                    //loop outputs
                    foreach($input->outputs as $output) {
                        if(is_file($output->path)) {
                            unlink($output->path);
                        }
                    }
                }
            }
        }
    }
protected function purgeFiles()
    {
        //get record
        //validate and extract input
        $input = $this->processSaveInput(filter_input_array(INPUT_POST, $this->configuration['subjects'][$this->name]['CRUD']['inputFields']));
        //extract primary key value
        $primaryKeyValue = $this->extractPrimaryKeyValue($input, 'a');
        $record = $this->getByPrimaryKey($primaryKeyValue);
        $fields = array_keys($this->uploadFieldsDefinitions);
        //loop defined upload fields
        foreach($fields as $field) {
            //skip other subject field (in case this subject handles upload for other tables)
            if(!isset($record->$field)) {
                continue;
            }
            //get record field value
            $fieldValue = json_decode($record->$field);
            //skip empty field
            if(!$fieldValue) {
                continue;
            }
            //ERRORE "Cannot use object of type stdClass as array" ALLA RIGA 230
            continue;
            //get posted value
            if($this->action == 'update') {
                $a = $input[$field];
                $fieldObject = json_decode($a);
                //$a = get_object_vars($a);
                //$postedInputs = array_keys($a);
            }
            //loop inputs
            foreach((array) $fieldValue as $hash => $input) {
                //if($this->action == 'delete' || !in_array($hash, $postedInputs)) {
                if($this->action == 'delete' || !isset($fieldObject->$hash)) {
                    //loop outputs
                    foreach($input->outputs as $output) {
                        if(is_file($output->path)) {
                            unlink($output->path);
                        }
                    }
                }
            }
        }
    }
protected function purgeFiles ( ) { //get record //validate and extract input $ input = $ this -> processSaveInput ( filter_input_array ( INPUT_POST , $ this -> configuration [ 'subjects' ] [ $ this -> name ] [ 'CRUD' ] [ 'inputFields' ] ) ) ; //extract primary key value $ primaryKeyValue = $ this -> extractPrimaryKeyValue ( $ input , 'a' ) ; $ record = $ this -> getByPrimaryKey ( $ primaryKeyValue ) ; $ fields = array_keys ( $ this -> uploadFieldsDefinitions ) ; //loop defined upload fields foreach ( $ fields as $ field ) { //skip other subject field (in case this subject handles upload for other tables) if ( ! isset ( $ record -> $ field ) ) { continue ; } //get record field value $ fieldValue = json_decode ( $ record -> $ field ) ; //skip empty field if ( ! $ fieldValue ) { continue ; } //ERRORE "Cannot use object of type stdClass as array" ALLA RIGA 230 continue ; //get posted value if ( $ this -> action == 'update' ) { $ a = $ input [ $ field ] ; $ fieldObject = json_decode ( $ a ) ; //$a = get_object_vars($a); //$postedInputs = array_keys($a); } //loop inputs foreach ( ( array ) $ fieldValue as $ hash => $ input ) { //if($this->action == 'delete' || !in_array($hash, $postedInputs)) { if ( $ this -> action == 'delete' || ! isset ( $ fieldObject -> $ hash ) ) { //loop outputs foreach ( $ input -> outputs as $ output ) { if ( is_file ( $ output -> path ) ) { unlink ( $ output -> path ) ; } } } } } }
Checks in case of CRUD update or delete if any file is to be deleted
Checks in case of CRUD update or delete if any file is to be deleted