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

Defining action hooks on tables not woking #76

@benhaynes

Description

@benhaynes

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions