Skip to content

Commit

Permalink
dark: update laravel handler resolution (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
azuradara authored Sep 19, 2023
1 parent c05bd55 commit 5c12da7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Laravel/SerializationHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,22 @@
namespace YouCanShop\Cereal\Laravel;

use YouCanShop\Cereal\Contracts\SerializationHandler;
use YouCanShop\Cereal\DefaultSerializationHandler;
use YouCanShop\Cereal\SerializationHandlerFactory as BaseSerializationHandlerFactory;

class SerializationHandlerFactory extends BaseSerializationHandlerFactory
{
public function getHandler(string $type): SerializationHandler
{
$handler = parent::getHandler($type);
if (!$handler instanceof DefaultSerializationHandler) {
return $handler;
}

if (is_subclass_of($type, \Illuminate\Database\Eloquent\Model::class)) {
return new ModelSerializationHandler();
}

return parent::getHandler($type);
return $handler;
}
}

0 comments on commit 5c12da7

Please sign in to comment.