/** * Constructor * * @param string $className The class of the entity * @param DataMapperInterface $dataMapper The builder * @param UnitOfWorkInterface $unitOfWork The UnitOfWork */ public function __construct($className, DataMapperInterface $dataMapper, UnitOfWorkInterface $unitOfWork) { $this->className = $className; $this->dataMapper = $dataMapper; $this->unitOfWork = $unitOfWork; $this->unitOfWork->registerDataMapper($this->className, $this->dataMapper); }
/** * Registers a data mapper for a class * Registering a data mapper for a class will overwrite any previously-set data mapper for that class * * @param string $className The name of the class whose data mapper we're registering * @param DataMapperInterface $dataMapper The data mapper for the class */ public function registerDataMapper($className, DataMapperInterface $dataMapper) { $this->unitOfWork->registerDataMapper($className, $dataMapper); }