return false;
}
+ /**
+ * Retrieve the reason for implementing the null provider interface.
+ *
+ * @param string $component Frankenstyle component name.
+ * @return string The key to retrieve the language string for the null provider reason.
+ */
+ public function get_null_provider_reason(string $component) : string {
+ if ($this->component_implements($component, \core_privacy\local\metadata\null_provider::class)) {
+ return $this->get_provider_classname($component)::get_reason();
+ } else {
+ throw new \coding_exception('Call to undefined method', 'Please only call this method on a null provider.');
+ }
+ }
+
/**
* Get the privacy metadata for all components.
*
$metadata = $manager->get_metadata_for_components();
$this->assertNotEmpty($metadata);
}
+
+ /**
+ * Test that the reason for the null provider is returned.
+ */
+ public function test_get_null_provider_reason() {
+ $manager = new \core_privacy\manager();
+ // Null providers return the reason string.
+ $this->assertEquals('testcomponent2 null provider reason', $manager->get_null_provider_reason('mod_testcomponent2'));
+ // Throw an exception if the wrong type of provider is given.
+ $this->expectException(\coding_exception::class);
+ $string = $manager->get_null_provider_reason('mod_testcomponent');
+ }
}