"Call to a member function on array" when using hooks in Plugin

I’m using the kirby-color plugin for a site i’m working on. It is generating hex values, but I need to use RGBA at a point on my site, so I want to call a function to generate an RGBA value whenever the field is changed. I’m getting the error “Call to a member function backgroundColor() on array” in the panel. My plugin looks like this:

Kirby::plugin('bruno/hex2rgba', [
    'hooks' => [
      'site.update:before' => function ($site, $oldSite) {
        $oldHex = $oldSite->backgroundColor()->value();
        $newHex = $site->backgroundColor()->value();
            if($oldHex !== $newHex) {
                    'backgroundColorRGBA' => hex2rgba($site->backgroundColor()->value()),

Does it not work to access site & oldsite the same way that you can use page and oldpage in the hook?

… The error was my use of a :before hook instead of :after.