Why is my plugin not getting called?
app/code/Company/Configurator/etc/module.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Company_Configurator" setup_version="0.1.0">
<sequence>
<module name="Magento_Quote"/>
<module name="Magento_Csp"/>
</sequence>
</module>
</config>
app/code/Company/Configurator/etc/di.xml:
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Csp\Model\Policy\FetchPolicy">
<plugin name="company_configurator_after_fetch_policy"
type="Company\Configurator\Plugin\FetchPolicyPlugin" />
</type>
</config>
app/code/Company/Configurator/Plugin/FetchPolicyPlugin.php:
<?php
namespace Company\Configurator\Plugin;
class FetchPolicyPlugin
{
/**
* @param \Magento\Csp\Model\Policy\FetchPolicy $subject
* @param string[] $result
* @return string[]
*/
public function afterGetHostSources(\Magento\Csp\Model\Policy\FetchPolicy $subject, array $result): array
{
// Modify the $result array here, if needed
// For example, add an additional host source
$result[] = 'example.com'; // I have set a xdebug breakpoint here, but it is never hit.
return $result;
}
}
The original method is getting called, but not my plugin.