/**
  * Add method
  *
  * @return void Redirects on successful add, renders view otherwise.
  */
 public function add()
 {
     $minute = $this->Minutes->newEntity();
     if ($this->request->is('post')) {
         //perform content extraction
         $f = $this->request->data['uploaded_file'];
         $extractor = new \ContentExtractor($f['type']);
         if ($extractor->supported()) {
             try {
                 $minute['content'] = $extractor->extract($f['tmp_name']);
             } catch (Exception $e) {
                 $minute['content'] = '';
             }
         }
         //set meeting date
         $date = new \DateTime($this->request->data['meeting_date']);
         $minute['meeting_date'] = $date;
         //process upload data. Always set to private
         $ret = $this->Upload->attachToEntity($minute, $f);
         if ($ret['success'] && $this->Minutes->save($minute)) {
             $this->Flash->success(__('The minutes have been saved.'));
             return $this->redirect(['action' => 'index']);
         }
         //if we haven't been re-directed yet, we've failed
         $msg = $ret['message'];
         $this->Flash->error(__("The uploaded file could not be saved. Error message was: '{$msg}'"));
     }
     $this->set(compact('minute'));
     $this->set('_serialize', ['minute']);
 }