/** * @param Entity $Entity * @return int */ public function save(Entity $Entity) { if (!$Entity->getId()) { $Entity->setId($this->getNextId()); } $this->getRepositoryDriver()->set($Entity->getId(), $Entity->serialize()); $this->getCache()->set($Entity->getId(), $Entity); return $Entity->getId(); }
/** * @param Entity $value * @return int */ public function serialize($value) { if (!$value instanceof Entity) { return []; } return ['id' => $value->getId(), 'type' => $value->getType()]; }