soflyy / breakdance-bugs

Bug reports from Breakdance users.
38 stars 6 forks source link

Hook to disable Elements #1041

Open flowww-dev opened 5 months ago

flowww-dev commented 5 months ago

It would be nice if Breakdance has a hook to disable some Elements. So Breakdance could be fine grained controlled for every customer. Like in Europe, GDPR is such a great topic. Videos hosted by YouTube or Vimeo are a thorn in the eye, so I need to implement my own Video Element... but what if my customer uses the "standard" Video Element. Customers are sometimes the dumbest user to assume ;-) .

I think this would be no a problem like in "loadData".

At the moment I deregister the ajax endpoint and reinit it... but that is not a good solution.

function loadData() {

$saveLocationsForElementStudio = array_filter(
    \Breakdance\ElementStudio\ElementStudioController::getInstance()->saveLocations,
    fn($saveLocation) => !($saveLocation['excludeFromElementStudio'] ?? false)
);

$macros = array_map(
    function($macro) {
        return [
            'slug' => $macro['slug'],
            'directoryPath' => $macro['directoryPath'] ?? ''
        ];
    },
    \Breakdance\Elements\getTwigMacrosData(true)
);

return
    [
        'elements' => \Breakdance\ElementStudio\ElementStudioController::getInstance()->elements,
        'presets' => requirePresetsAndGetData(),
        'macros' => $macros,
        'saveLocations' => array_values($saveLocationsForElementStudio),
        'presetSections' => \Breakdance\Elements\PresetSections\PresetSectionsController::getInstance()->getAvailableInElementStudio(),
    ];

}