public function push(EntityInterface $entity) { $mapper = $entity->getMapper(); $primary = $entity->get($mapper->primary()); $this->{$primary} = $entity; return; }
public function parse(EntityInterface $entity, $param = null, $type = null) { if (!empty($param) && !empty($type)) { $value = $entity->get($param); switch ($type) { case self::INTEGER: case self::FLOAT: case self::STRING: $value = (string) $value; break; case self::BOOL: $value = (int) $value; break; case self::SERIALIZE: $value = is_array($value) ? serialize($value) : $value; break; case self::JSON: $value = is_array($value) ? json_encode($data) : $value; break; case self::DATE: $value = is_object($value) && get_class($value) === "DateTime" ? $value->format('Y-m-d') : $value; break; case self::DATETIME: $value = is_object($value) && get_class($value) === "DateTime" ? $value->format('Y-m-d H:i:s') : $value; break; } $entity->set($param, $value); } return $entity; }