Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defining action hooks on tables not woking #2199

Closed
rainst opened this issue Sep 4, 2018 · 1 comment
Closed

Defining action hooks on tables not woking #2199

rainst opened this issue Sep 4, 2018 · 1 comment

Comments

@rainst
Copy link

rainst commented Sep 4, 2018

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!

@benhaynes benhaynes added the v6 label Oct 12, 2018
@benhaynes
Copy link
Sponsor Member

Kamino closed and cloned this issue to directus/directus-6-legacy

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants