The Move to Islandora Kit is an extensible PHP command-line tool for converting source content and metadata into packages suitable for importing into Islandora (or other digital repository and preservations systems).
Moves the custom Twig filter TwigTruncate code to a utility class so it can be shared across metadatamanipulators and metadataparsers that use Twig templates.
What's new?
Adds a new MIK utility class, src/utilities/MikTwigExtension.php, that is used within metadatamanipulators and metadataparsers like this:
$truncate_filter = new \Twig_SimpleFilter('TwigTruncate', 'mik\utilities\MikTwigExtension::TwigTruncate');
$twig->addFilter($truncate_filter);
The custom TwigTruncate filter is then available in metadatamanipulators and metadataparsers using logic like this:
Since this branch makes it possible to share code between a metadata parser and a metadata manipulator, we should test both.
Unzip the attached configuration and data files.
Check out the issue-379 branch and run composer dump-autoload or equivalent.
Test the Templated metadata parser first by running ./mik -c issue_379_parser.ini. Output files will be in /tmp/issue_379_output.
image01.xml, image05.xml, and image05.xml will have titles that have been truncated at the word boundary closest to 30 characters (refer to the input file issue_379_metadata.csv to confirm this is the case).
Delete the /tmp/issue_379_output and /tmp/issue_379_temp directories.
Test the InsertXmlFromTemplate metadata manipulator first by running ./mik -c issue_379_manipulator.ini. Output files will be in /tmp/issue_379_output.
image01.xml, image05.xml, and image05.xml will have titles that have been truncated at the word boundary closest to 30 characters (refer to the input file issue_379_metadata.csv to confirm this is the case).
Github issue: (#379)
What does this Pull Request do?
Moves the custom Twig filter TwigTruncate code to a utility class so it can be shared across metadatamanipulators and metadataparsers that use Twig templates.
What's new?
Adds a new MIK utility class, src/utilities/MikTwigExtension.php, that is used within metadatamanipulators and metadataparsers like this:
The custom TwigTruncate filter is then available in metadatamanipulators and metadataparsers using logic like this:
How should this be tested?
Since this branch makes it possible to share code between a metadata parser and a metadata manipulator, we should test both.
composer dump-autoload
or equivalent../mik -c issue_379_parser.ini
. Output files will be in /tmp/issue_379_output../mik -c issue_379_manipulator.ini
. Output files will be in /tmp/issue_379_output.issue_379.zip
Additional Notes
We should start a Cookbook entry that documents all of the MIK-specific Twig extenstions (currently there is only one).
Interested parties
@MarcusBarnes