Cockpit-HQ / Cockpit

Cockpit Core - Content Platform
https://getcockpit.com
Other
388 stars 47 forks source link

Event handlers not working in Spaces (some event is not registered on spaces) #198

Closed Mikearaya closed 4 months ago

Mikearaya commented 4 months ago

for example i have content.item.save.before handler to auto-generate slug for content. $app->on('content.item.save.before', function($modelName, &$data, $isUpdate) {

})

while this works on the main site it is not triggered in spaces

aheinze commented 4 months ago

where is the code located?

Mikearaya commented 4 months ago

config/bootstrap.php also after investigating further i noticed the events are not registered completely in spaces. specifically content. events so they are never triggered with `$this->app->trigger('content.)`

aheinze commented 4 months ago

right, because spaces are "stand-alone" cockpit instances. you need to create .spaces/{spacename}/config/bootstrap.php with the event binding code

Mikearaya commented 4 months ago

That was the issue. thank you so much for your awesome support.

Mikearaya commented 4 months ago

@aheinze is there a way i can automatically generate the default bootstrap.php config i have whenever a new space is created? maybe using $this->app->on('spaces.config.create')