From 7f13a739ef4cab63d1366ceaf14efdeb8ca139ce Mon Sep 17 00:00:00 2001 From: lucashedding <lucashedding@1463982.no-reply.drupal.org> Date: Mon, 25 Mar 2019 08:48:02 -0500 Subject: [PATCH] Issue #3041918 by heddn, qymanab: Add examples to file_blob plugin --- src/Plugin/migrate/process/FileBlob.php | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/src/Plugin/migrate/process/FileBlob.php b/src/Plugin/migrate/process/FileBlob.php index 1d4aa182..b04be892 100644 --- a/src/Plugin/migrate/process/FileBlob.php +++ b/src/Plugin/migrate/process/FileBlob.php @@ -13,6 +13,60 @@ use Symfony\Component\DependencyInjection\ContainerInterface; /** * Copy a file from a blob into a file. * + * The source value is an indexed array of two values: + * - The destination URI, e.g. 'public://example.txt'. + * - The binary blob data. + * + * Available configuration keys: + * - reuse: true + * + * Examples: + * + * @code + * uri: + * plugin: file_blob + * source: + * - 'public://example.txt' + * - blob + * @endcode + * + * A basic configuration. + * + * @code + * source: + * constants: + * destination: public://images + * process: + * destination_blob: + * plugin: callback + * callable: base64_decode + * source: + * - blob + * destination_basename: + * plugin: callback + * callable: basename + * source: file_name + * destination_path: + * plugin: concat + * source: + * - constants/destination + * - @destination_basename + * uri: + * plugin: file_blob + * source: + * - @destination_path + * - @destination_blob + * @endcode + * + * In some instances, it may be necessary to manipulate values before they can + * be processed by this plugin. This is because this plugin takes a binary blob + * and saves it as a file. In many cases, as in this example, the data is base64 + * encoded and should be decoded first. In destination_blob, the incoming data + * is decoded from base64 to binary. The destination_path element is + * concatenating the base filename with the destination directory set in the + * constants to create the final path. The resulting values are then referenced + * as the source of the file_blob plugin. + * * @MigrateProcessPlugin( * id = "file_blob" * ) -- GitLab