-
Notifications
You must be signed in to change notification settings - Fork 128
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
Add URL support to D.O. load task (#1807) #1808
Conversation
0064781
to
fbdc92c
Compare
fbdc92c
to
b6a7596
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good @mcantelon. I have a few minor suggestions but no blockers. 👌
EOF; | ||
$this->detailedDescription = "Load a CSV list of digital objects\n\n"; | ||
|
||
$this->detailedDescription .= "Valid CSV columns are '".self::PATH_COLUMN."' and one of: '".implode("', '", self::IO_SPECIFIER_COLUMNS)."'"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think using sprintf() here is easier to read than string concatenation:
$this->detailedDescription .= sprintf(
"Valid CSV columns are '%s' and one of: '%s'",
self::PATH_COLUMN,
implode("', '", self::IO_SPECIFIER_COLUMNS),
);
(line breaks optional)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call!
$valid = in_array(self::PATH_COLUMN, $columns); | ||
|
||
// Second check for existance of an information object specifier column | ||
if ($valid) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be shortened using array_intersect()
if ($valid) {
$valid = count(array_intersect(self::IO_SPECIFIER_COLUMNS, $columns)) > 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slick!
|
||
$filename = basename($path); | ||
// If it's not a file, assume it's a URL and dismiss if invalid | ||
if (!filter_var($url_or_path, FILTER_VALIDATE_URL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PHP you so fancy! 🤩
} | ||
|
||
// Check if URL exists | ||
$headers = @get_headers($url_or_path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy x 10! 🤯
Thanks @djjuhasz ! Good suggestions! |
622f3e9
to
76f3fec
Compare
Added functionality, to the digital object load task, to import URLs in addition to files. Did minor cleanup and improved CLI help to include a list of valid CSV columns.
76f3fec
to
c2bad00
Compare
Added functionality, to the digital object load task, to import URLs in addition to files.
Did minor cleanup and improved CLI help to include a list of valid CSV columns.