public function saveTags($attachmentId = null)
    {
        $this->request->allowMethod('post');
        $attachment = $this->Attachments->get($attachmentId);
        $this->_checkAuthorization($attachment);

        if (!TableRegistry::get($attachment->model)) {
            throw new \Cake\ORM\Exception\MissingTableClassException('Could not find Table ' . $attachment->model);
        }
        $inputArray = explode('&', $this->request->input('urldecode'));
        $tags = explode('$', explode('=', $inputArray[0])[1]);
        unset($inputArray[0]);

        // parse the attachments area options from the post data (comes in as a string)
        $options = [];
        foreach ($inputArray as $option) {
            $option = substr($option, 8);
            $optionParts = explode(']=', $option);
            $options[$optionParts[0]] = $optionParts[1];
        }
        // set so the first div of the attachments area element is skipped in the view, as it
        // serves as target for the Json Action
        $options['isAjax'] = true;

        $Model = TableRegistry::get($attachment->model);
        $Model->saveTags($attachment, $tags);

        $entity = $Model->get($attachment->foreign_key, ['contain' => 'Attachments']);
        $this->set(compact('entity', 'options'));
    }
public function saveTags($attachmentId = null)
    {
        $this->request->allowMethod('post');
        $attachment = $this->Attachments->get($attachmentId);
        $this->_checkAuthorization($attachment);

        if (!TableRegistry::get($attachment->model)) {
            throw new \Cake\ORM\Exception\MissingTableClassException('Could not find Table ' . $attachment->model);
        }
        $inputArray = explode('&', $this->request->input('urldecode'));
        $tags = explode('$', explode('=', $inputArray[0])[1]);
        unset($inputArray[0]);

        // parse the attachments area options from the post data (comes in as a string)
        $options = [];
        foreach ($inputArray as $option) {
            $option = substr($option, 8);
            $optionParts = explode(']=', $option);
            $options[$optionParts[0]] = $optionParts[1];
        }
        // set so the first div of the attachments area element is skipped in the view, as it
        // serves as target for the Json Action
        $options['isAjax'] = true;

        $Model = TableRegistry::get($attachment->model);
        $Model->saveTags($attachment, $tags);

        $entity = $Model->get($attachment->foreign_key, ['contain' => 'Attachments']);
        $this->set(compact('entity', 'options'));
    }
public function saveTags ( $ attachmentId = null ) { $ this -> request -> allowMethod ( 'post' ) ; $ attachment = $ this -> Attachments -> get ( $ attachmentId ) ; $ this -> _checkAuthorization ( $ attachment ) ; if ( ! TableRegistry :: get ( $ attachment -> model ) ) { throw new \ Cake \ ORM \ Exception \ MissingTableClassException ( 'Could not find Table ' . $ attachment -> model ) ; } $ inputArray = explode ( '&' , $ this -> request -> input ( 'urldecode' ) ) ; $ tags = explode ( '$' , explode ( '=' , $ inputArray [ 0 ] ) [ 1 ] ) ; unset ( $ inputArray [ 0 ] ) ; // parse the attachments area options from the post data (comes in as a string) $ options = [ ] ; foreach ( $ inputArray as $ option ) { $ option = substr ( $ option , 8 ) ; $ optionParts = explode ( ']=' , $ option ) ; $ options [ $ optionParts [ 0 ] ] = $ optionParts [ 1 ] ; } // set so the first div of the attachments area element is skipped in the view, as it // serves as target for the Json Action $ options [ 'isAjax' ] = true ; $ Model = TableRegistry :: get ( $ attachment -> model ) ; $ Model -> saveTags ( $ attachment , $ tags ) ; $ entity = $ Model -> get ( $ attachment -> foreign_key , [ 'contain' => 'Attachments' ] ) ; $ this -> set ( compact ( 'entity' , 'options' ) ) ; }
endpoint for Json action to save tags of an attachment

@param  uuid $attachmentId the attachment identifier
@return void
endpoint for Json action to save tags of an attachment