getAttributesFromDca
The getAttributesFromDca hook is triggered when attributes of a widget are
extracted from a Data Container array. It passes the attributes and the DCA object
as arguments and expects the (modified) widget attributes as return value.
Note that the DCA object can be optional (null).
Parameters
array
$attributesAn array of attributes.
$contextA
\Contao\DataContaineror\Contao\Moduleobject. It can benullif no object was passed to the\Contao\Widget::getAttributesFromDcamethod.
Return Values
Return the attributes for the widget as an associative array.
Example
// src/EventListener/GetAttributesFromDcaListener.php
namespace App\EventListener;
use Contao\CoreBundle\DependencyInjection\Attribute\AsHook;
#[AsHook('getAttributesFromDca')]
class GetAttributesFromDcaListener
{
public function __invoke(array $attributes, $context = null): array
{
// Modify $attributes here …
return $attributes;
}
}