File src/Integration/DynamicAccess.php

class Phad\Integration\DynamicAccess

A base class for access controls that allows all READ operations, no WRITE (insert/update/delete) operations, and returns false for user_has_role().
See source code at /src/Integration/DynamicAccess.php

Constants

Properties

  • public $item_initialized; callable for item_initialized()
  • public $call; callable for call(). This is only called if call_handlers[] does not have a matching handler.
  • public $can_read_row; callable for can_read_row()
  • public $user_has_role; callable for can_read_row()
  • public array $call_handlers = []; Array of call handlers. Key is the what in call:what, and value is a callable with the same method signature as call()

Methods

  • public function item_initialized(object $ItemInfo): void Does nothing unless you set a custom handler

  • public function call(\Phad\Caller $caller, string $what, object $ItemInfo, ...$args): bool When call:something is added to the access attribute of a node, this method is called and must return true or false.

  • public function can_read_row(array $ItemRow, object $ItemInfo, string $ItemName): bool When a template's data is being loaded, either via a query (default) or a custom data_loader, every row is passed to this method. For each row that returns true, it will be included in the final resultset.

If data is passed to your template (rather than loaded by the template), then this method will not be called.

  • public function user_has_role(string $role): bool Check if the currently logged-in user has the given role. You may use this to check multiple roles, like role:a&b&c or you can use multiple separate role checks like role:a;role:b;role:c