yiisoft / yiisoft/widget

`pipe()` method

Open
#116 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status:under discussion
Dominant language
PHP
Stars
25
Forks
5
Avg merge
46m
Merged PRs (30d)
1

Description

Proposed new feature or change

Based on https://github.com/yiisoft/yii-widgets/pull/147

Adds pipe(callable $callback) widgets via trait or directly to Widget class. Passes the widget through the callback and returns the result, keeping the fluent chain intact.

$tailwindNav = fn(Menu $m) => $m->class('flex space-x-4')->linkClass('px-3 py-2 rounded-md');

Menu::widget()
    ->items($items)
    ->pipe($tailwindNav)
    ->render();

Reusable configuration (themes, style presets) can be extracted into callables and composed without subclassing.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Widget class and its existing fluent methods, then review how widget configuration and rendering are tested. Implementing this feature is complete when a callable receives the widget, its result is returned, and the demonstrated fluent chain can still reach render().

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.