Skip to content

Commit

Permalink
Added filter codifier/callable-renderer/render/data
Browse files Browse the repository at this point in the history
  • Loading branch information
Timi-Artturi Mäkelä committed Feb 29, 2024
1 parent 0fd32b0 commit a6dcbe7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

[Unreleased]

## [add-filter-renderer-render-data]

### Added
- Added a filter `codifier/callable-renderer/render/data` for CallableRenderer->render() $data. For example this makes possible to identify fields inside commonly used custom renderer.

## [1.39.1]

### Fixed
Expand Down
6 changes: 5 additions & 1 deletion src/Renderer/CallableRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public function __construct( callable $method ) {
* @return string
*/
public function render( array $fields ) : string {
return \call_user_func( $this->method, $fields['data'] );

// Filter the Renderer data.
$data = \apply_filters( 'codifier/callable-renderer/render/data', $fields[ 'data' ], $fields );

return \call_user_func( $this->method, $data );
}
}

0 comments on commit a6dcbe7

Please sign in to comment.