Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
API page: https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Plugin!Disco...
> bool $exception_on_invalid: (optional) If TRUE, an invalid plugin ID will throw an exception. Defaults to FALSE.
Looking at the code, this parameter is not optional:
protected function doGetDefinition(array $definitions, $plugin_id, $exception_on_invalid) {
Comment | File | Size | Author |
---|---|---|---|
#18 | 2740499-15.patch | 807 bytes | jhodgdon |
Comments
Comment #2
er.pushpinderrana CreditAttribution: er.pushpinderrana as a volunteer and at Publicis Sapient for Publicis Sapient commentedRemoved the optional word but still doubt about "Defaults to False" because there is no default value set for this variable.
Comment #3
joachim CreditAttribution: joachim commentedThanks for the patch!
'Defaults to False' should be removed too. That only makes sense for an optional variable.
Comment #4
lluvigneHi!
Acording to @joachim on #3, remove 'Defaults to False' text.
Comment #5
jhodgdonThis seems slightly incomplete, and leaves me wondering about what happens if it is FALSE.
What if we said something like:
TRUE to throw an exception if the plugin ID is invalid; FALSE to return NULL in this case.
I guess that somewhat overlaps with the @return, but at least it doesn't leave you wondering what happens if it's FALSE. Thoughts?
Comment #6
joachim CreditAttribution: joachim commentedHow about:
If TRUE, an invalid plugin ID will cause an exception to be thrown, instead of returning NULL.
Comment #7
jhodgdonThe grammar in that suggestion in #6 is a bit questionable -- the two clauses don't have parallel verb tenses: "will cause" vs. "returning". It's also kind of passive voice.
Here are some alternatives, which all at least have parallel grammatical constructions:
- TRUE to throw an exception if the plugin ID is invalid; FALSE to return NULL in this case.
- If TRUE, an invalid plugin ID will cause an exception to be thrown; if FALSE, NULL will be returned.
- Determines what happens if the plugin ID is invalid. TRUE will cause an exception to be thrown; FALSE will cause NULL to be returned.
- Determines what happens if the plugin ID is invalid. If TRUE, an exception will be thrown; if FALSE, NULL will be returned.
Looking at these, I think "cause" is kind of awkward, so let's avoid those alternatives? Other than that, pick one of the above, or come up with another alternative that also has parallel verb grammar. OK?
Comment #8
nesta_ CreditAttribution: nesta_ at La Drupalera by Emergya commentedfix #4 to #7 :)
Comment #10
nesta_ CreditAttribution: nesta_ at La Drupalera by Emergya commentedSorry. attach valid patch and interdiff
Comment #11
nesta_ CreditAttribution: nesta_ at La Drupalera by Emergya commentedSorry, bad files Ew!
Comment #13
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commentedApplying Patch.
Thanks!!
Comment #15
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commentedSorry for wrong patch applied.
Comment #16
nesta_ CreditAttribution: nesta_ at La Drupalera by Emergya commented:) #4 with #7
Comment #17
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Blisstering Solutions commented#15 is write patch and # 13 is wrong patch.
Thanks!!
Comment #18
jhodgdon#16 is the wrong patch, because it has a line that is too long.
#15 looks fine to me.
To avoid the wrong patch being tested/committed, I am uploading the #15 patch again and hiding all the other patches.
Thanks!
Comment #19
alexpottCommitted 68cc3af and pushed to 8.1.x and 8.2.x. Thanks!