public function save(Category $category) { $data = array('master_category' => $category->getMasterCategory(), 'singular_name' => $category->getSingularName(), 'plural_name' => $category->getPluralName(), 'image' => $category->getImage(), 'shipping_cost' => $category->getShippingCost(), 'additional_shipping' => $category->getAdditionalShipping(), 'description' => $category->getDescription()); $id = (int) $category->getId(); $params = array(); $params['table'] = $this->tableGateway->getTableName(); $params['operation'] = 1; $params['data'] = json_encode($data); if ($id == 0) { $this->tableGateway->insert($data); $id = $this->tableGateway->getLastInsertValue(); if ($id) { $params['id'] = $id; $this->featureSet->getEventManager()->trigger("log.save", $this, $params); return $id; } else { return false; } } else { if ($this->get($id)) { $params['id'] = $id; $params['operation'] = 2; $this->featureSet->getEventManager()->trigger("log.save", $this, $params); $this->tableGateway->update($data, array('id' => $id)); return $id; } else { return false; } } }