How do I modify retrieved field from varbinary to formatted string in CakePHP 3? : I'm storing UUID data as varbinary(16) in MySQL tables. This is NOT a primary key. When I read this field, I'd like to have it converted to the standard 36-character string (binary to hex with hyphens inserted) in PHP. In CakePHP 2.x I would have used the afterFind() callback. The CakePHP 3.x documentation says to [use Map/Reduce][1], but that would mean locating every find() in the code. It seems like I should be able to accomplish this in the model, perhaps as a CakePHP 3 Behavior.

The table looks like this:

    create table `books` (
    `id` int(10) unsigned not null auto_increment,
    `my_uuid` varbinary(16) not null,
    `created` timestamp not null default current_timestamp on update current_timestamp,
    primary key (`id`),
    ) engine=InnoDB;

Note that I'm only asking about reading from the database. Insert and update are working fine. I'd like to convert from binary to string on read, and I think I should be doing that in the Model layer (table/entity).

  [1]: https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#map-reduce