orisai/nextras-object-mapper

orisai/object-mapper extension for nextras/orm

v1.x-dev 2025-01-21 22:16 UTC

This package is auto-updated.

Last update: 2025-01-21 22:16:18 UTC


README

Orisai
Nextras Object Mapper

orisai/object-mapper extension for nextras/orm

📄 Check out our documentation.

💸 If you like Orisai, please make a donation. Thank you!

Attributes definition
use App\User\DB\User;
use OriNextras\ObjectMapper\Rules\EntityFromId;
use Orisai\ObjectMapper\MappedObject;
use Orisai\ObjectMapper\Modifiers\FieldName;
use Orisai\ObjectMapper\Rules\IntValue;

final class EntityFetchingInput implements MappedObject
{

	#[FieldName('userId')]
	#[EntityFromId(
		name: 'userId',
		entity: User::class,
		idDefinition: new IntValue(unsigned: true, castNumericString: true)),
	]
	public User $user;

}
Annotations definition
use App\User\DB\User;
use OriNextras\ObjectMapper\Rules\EntityFromId;
use Orisai\ObjectMapper\MappedObject;
use Orisai\ObjectMapper\Modifiers\FieldName;
use Orisai\ObjectMapper\Rules\IntValue;

final class EntityFetchingInput implements MappedObject
{

	/**
	 * @FieldName("userId")
	 * @EntityFromId(
	 *     name="userId"
	 *     entity=User::class
	 *     idDefinition=@IntValue(unsigned=true, castNumericString=true)
	 * )
	 */
	public User $user;

}
$data = [
	'userId' => 666,
];
$input = $processor->process($data, EntityFetchingInput::class);
// $input == EntityFetchingInput(user: User(id: 666, /* ... */))