1. Go to this page and download the library: Download nettrine/hydrator library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
$hydrator->toFields($obj, [
'assoc' => 42, // Item with the value of 42 will be found
]);
/**
* @ORM\Column(type="image")
*/
class CustomFieldAdapter implements IFieldAdapter {
public function __construct(IImageStorage $storage) { ... }
public function isWorkable(FieldArgs $args): bool {
// Apply only when the type is `image` and it is not an assocation
return !$args->metadata->isAssociation($field) && $args->metadata->getFieldMapping($field)['type'] === 'image';
}
public function work(FieldArgs $args): void {
$image = new Image($value);
if ($args->hasSettingsSection('images')) {
$image->setName($args->getSettingsSection('images'));
}
$this->storage->save($image);
$args->value = $image;
}
}