-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Permit altering the $twig_input #115
Comments
My initial idea is to expose a hook However, I see that there are a couple other cases where the twig data is prepared and rendered for preview, which do not have the $objectInfo or $preprocessorParameters. We could either ignore these (i.e. there would be no indication in the twig preview of the altered twig input), or we could invoke the alter hook in each of these places. In this case, the hook implementation would need to be written so as to handle case where context is not available. Here's an idea: /**
* This hook permits the input to a twig template to to modified at run time.
* The impetus for this was a desire to be able to include the PID of the object
* in an identifier field in the MODS datastream. The PID is provided in the $objectInfo,
* variable during the batch ingest operation, so we can use it then.
*
* @param $twig_input
* an associative array, with $twig_input['data'] providing the field data that will
* be available to the twig template in the `data` variable.
* @param $context
* NULL, or array that may contain one or both of...
* - 'objectInfo' => an array of data returned by IslandoraMultiBatch::getIngestInfo()
* - 'preprocessorParameters' => an array of data populated in IslandoraMultiBatch::getDatastreams
* prior to calling islandora_multi_importer_twig_process.
*/
function hook_imi_twig_input_alter(&$twig_input, $context = NULL) {
if(!empty($context['objectInfo']['pid'])) {
$twig_input['data']['new_pid'] = $context['objectInfo']['pid'];
}
else {
$twig_input['data']['new_pid'] = "[pid placeholder]";
}
} @DiegoPino thoughts? |
Hi! Sounds like a good approach. In case there (super edge really) would be
clashes with any column named new_pid or whatever you feel in the
spreadsheet maybe we can add some protected array that is not the data one
for computed by imi info? Also, i like the hook idea, still, feel free to
inject also the pid directly(or make that pid hook impl. Part of imi) since
your use case is quite global
Cheers
El El lun, 4 de may. de 2020 a la(s) 18:49, Pat Dunlavey <
notifications@github.com> escribió:
My initial idea is to expose a hook hook_imi_twig_input_alter() just
before the call to islandora_multi_importer_twig_process in
IslandoraMultiBatchObject::getDatastreams that takes as arguments the twig
input data, and, for context, $objectInfo and $preprocessorParameters.
However, I see that there are a couple other cases where the twig data is
prepared and rendered for preview, which do not have the $objectInfo or
$preprocessorParameters. We could either ignore these (i.e. there would be
no indication in the twig preview of the altered twig input), or we could
invoke the alter hook in each of these places. In this case, the hook
implementation would need to be written so as to handle case where context
is not available. Here's an idea:
/** * This hook permits the input to a twig template to to modified at run time. * The impetus for this was a desire to be able to include the PID of the object * in an identifier field in the MODS datastream. The PID is provided in the $objectInfo, * variable during the batch ingest operation, so we can use it then. * * @param $twig_input * an associative array, with $twig_input['data'] providing the field data that will * be available to the twig template in the `data` variable. * @param $context * NULL, or array that may contain one or both of... * - 'objectInfo' => an array of data returned by IslandoraMultiBatch::getIngestInfo() * - 'preprocessorParameters' => an array of data populated in IslandoraMultiBatch::getDatastreams * prior to calling islandora_multi_importer_twig_process. */function hook_imi_twig_input_alter(&$twig_input, $context = NULL) { if(!empty($context['objectInfo']['pid'])) { $twig_input['data']['new_pid'] = $context['objectInfo']['pid']; } else { $twig_input['data']['new_pid'] = "[pid placeholder]"; }}
@DiegoPino <https://github.com/DiegoPino> thoughts?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#115 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABU7ZZ76A2ORJNJFPPVPIFDRP5BAFANCNFSM4MZEQIBA>
.
--
Diego Pino Navarro
Digital Repositories Developer
Metropolitan New York Library Council (METRO)
|
Our use-case is needing to use the incoming object's PID as part of a MODS identifier string. The PID is not known in advance, but it is available in IslandoraMultiBatch::objectInfo. It seems like the simplest thing is to permit other modules to modify the $twig_input prior to rendering the template.
The text was updated successfully, but these errors were encountered: