Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Defining action hooks on tables not woking #76

Open
benhaynes opened this issue Oct 25, 2018 · 0 comments
Open

Defining action hooks on tables not woking #76

benhaynes opened this issue Oct 25, 2018 · 0 comments
Labels

Comments

@benhaynes
Copy link
Member

From directus created by rainst : directus/directus#2199

Version Info

  • 6.4.9 (ab5a935)
  • PHP version: 5.6.33
  • MySQL version: MariaDB 10.1.30
  • Web server: Apache
  • OS name and version: Windows (Xampp)

I'm trying to implement an action hook after updating or inserting a new row in a table called pages, this is the expected implementation following the reference:

    'hooks' => [
        'table.update.pages:after' => function ($table, $data) {
            file_put_contents('testing.txt', $table . ":\r\n" . json_encode($data) . "\r\n", FILE_APPEND);
        },
        'table.insert.pages:after' => function ($table, $data) {
            file_put_contents('testing.txt', $table . ":\r\n" . json_encode($data) . "\r\n", FILE_APPEND);
        }
    ]

but when I try to insert or edit something I get this response from the API, where line 81 is the one where the update hook is defined.

{
  "success":false,
  "error":{
    "message":"Missing argument 2 for Directus\\Bootstrap::{closure}()"
  },
  "code":2,
  "class":"ErrorException",
  "file":"C:\\xampp\\htdocs\\directus\\api\\configuration.php",
  "line":81
}

If I remove the pages filter it works as expected, it triggers for every table
'table.update:after' => function ($table, $data) { ... }

What am I doing wrong here?
thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant