public function updateAction()
 {
     $this->logger->entering();
     $this->logger->info('Loading the item by id');
     $items = new Item();
     $item = $items->find($this->_getParam('id'))->current();
     $this->logger->info('Setting item from params');
     $item->setFromArray($this->_getParam('item'));
     if (isset($_FILES) && isset($_FILES['image']) && $_FILES['image']['error'] == UPLOAD_ERR_OK) {
         $this->logger->notice('Item image has changed');
         $this->logger->info("Reading image data from temporary storage '{$_FILES['image']['tmp_name']}'");
         $image_data = file_get_contents($_FILES['image']['tmp_name']);
         $this->logger->info('Building row data from image');
         $imageRow = array('name' => $_FILES['image']['name'], 'content_type' => $_FILES['image']['type'], 'data' => $image_data);
         $this->logger->info('Inserting Image');
         $images = new Image();
         $images->insert($imageRow);
         $this->logger->info('Getting the id of the image');
         $item->image_id = $this->db->lastInsertId();
     }
     switch ($_FILES['image']['error']) {
         case UPLOAD_ERR_OK:
             $this->logger->info('Image uploaded without complication');
             break;
         case UPLOAD_ERR_INI_SIZE:
             $this->logger->warn('Image too large');
             $this->flash->notice = "Image too large";
             break;
         case UPLOAD_ERR_FORM_SIZE:
             $this->logger->warn('Image too large');
             $this->flash->notice = "Image too large";
             break;
         case UPLOAD_ERR_PARTIAL:
             $this->logger->warn('Image failed to upload');
             $this->flash->notice = "Image failed to upload, could you try again please?";
             break;
         case UPLOAD_ERR_NO_FILE:
             $this->logger->info('No image uploaded');
             break;
         case UPLOAD_ERR_NO_TMP_DIR:
             $this->logger->err('File upload directory is missing');
             break;
         case UPLOAD_ERR_CANT_WRITE:
             $this->logger->err('File upload directory is not writable');
             break;
         case UPLOAD_ERR_EXTENSION:
             $this->logger->warn('Unacceptable file extension on uploaded file');
             $this->flash->notice = "Invalid file format. Upload an image please.";
             break;
         default:
             $this->logger->crit("Unknown image upload error '{$_FILES['image']['error']}'");
     }
     $this->logger->info('Saving item');
     $item->save();
     $this->logger->info('Inserting item tags');
     $tags = Tag::parseTags($this->_getParam('tags'));
     $items->updateTags($item->id, $tags);
     $this->logger->info('Adding items to search index');
     ItemIndex::update($item, $this->_getParam('tags'));
     $this->logger->info('Redirecting to show the item');
     $this->_redirect("items/show/{$item->id}");
     $this->logger->exiting();
 }