PHPackages                             petrgrishin/yii-widget-factory - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. petrgrishin/yii-widget-factory

ActiveLibrary

petrgrishin/yii-widget-factory
==============================

Yii widget factory

1.0.0(11y ago)012MITPHPPHP &gt;=5.3.0

Since May 23Pushed 11y ago1 watchersCompare

[ Source](https://github.com/petrgrishin/yii-widget-factory)[ Packagist](https://packagist.org/packages/petrgrishin/yii-widget-factory)[ RSS](/packages/petrgrishin-yii-widget-factory/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

yii-widget-factory
==================

[](#yii-widget-factory)

[![Travis CI](https://camo.githubusercontent.com/b0f6c6aa40228a4dc2e5ea3704061ad28a1e2ed60faa1f6382435697211a2795/68747470733a2f2f7472617669732d63692e6f72672f706574726772697368696e2f7969692d7769646765742d666163746f72792e706e67 "Travis CI")](https://travis-ci.org/petrgrishin/yii-widget-factory)[![Coverage Status](https://camo.githubusercontent.com/3f9c3c92767d2613f014bfd2fd432ade13792220819329d11e76ef19be6de257/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f706574726772697368696e2f7969692d7769646765742d666163746f72792f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/petrgrishin/yii-widget-factory?branch=master)

Фабрика виджетов Yiiframework

Установка
---------

[](#установка)

Добавите зависимость для вашего проекта в composer.json:

```
{
    "require": {
        "petrgrishin/yii-widget-factory": "dev-master"
    }
}
```

Постановка проблемы
-------------------

[](#постановка-проблемы)

Необходимо использовать виджеты реализованные в модуле, которые имеют зависимости от модуля, например знание о контроллере модуля.

Решение
-------

[](#решение)

Реализовать в модуле создание фабрики виджетов и проинициализировать его знаниями расположеными в нем. Для использования виджета в приложении, использовать созданную фабрику.

Пример решения
--------------

[](#пример-решения)

\####Модуль Класс модуля. Инициализируем фабрику виджета комментариев знанием (параметр виджета `listUrl`) о контроллере `comments/list`, расположеном в текущем модуле.

```
use \PetrGrishin\WidgetFactory\WidgetFactory;

class CommentsModule extends CWebModule {
    public function getCommentsWidgetFactory() {
        if (empty($this->_commentsWidgetFactory)) {
            $this->_commentsWidgetFactory = new WidgetFactory();
            $this->_commentsWidgetFactory
                ->setClassName(Widgets\CommentsWidget::className())
                ->setParams(array(
                    'listUrl' => $this->createModuleUrlBuilder('comments/list'),
                ));
        }
        return $this->_commentsWidgetFactory;
    }
}
```

\####Основное приложение Класс контроллера

```
class SiteController extends CController {
    public function actionDetail() {
        $this->render('detail', array(
            'commentsWidgetFactory' => $this->getCommentsWidgetFactory(),
        ));
    }

    /**
     * @return \PetrGrishin\WidgetFactory\WidgetFactory
     */
    protected function getCommentsWidgetFactory() {
        return $this->getCommentsModule()->getCommentsWidgetFactory()
            ->setView($this);
    }

    /**
     * @return CommentsModule
     */
    protected function getCommentsModule() {
        return Yii::app()->getModule('comments');
    }
}
```

Представление контроллера и создание виджета в нем

```
    $commentsWidget = $commentsWidgetFactory->createInstance(array('param' => 'value'));
    $commentsWidget->run();
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

4372d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/fcef45dd6d44dfcbfeb841a627bbc886b2f9d41f90d8826fb46cd4aca19264d5?d=identicon)[petrgrishin](/maintainers/petrgrishin)

---

Top Contributors

[![petrgrishin](https://avatars.githubusercontent.com/u/580229?v=4)](https://github.com/petrgrishin "petrgrishin (13 commits)")

### Embed Badge

![Health badge](/badges/petrgrishin-yii-widget-factory/health.svg)

```
[![Health](https://phpackages.com/badges/petrgrishin-yii-widget-factory/health.svg)](https://phpackages.com/packages/petrgrishin-yii-widget-factory)
```

###  Alternatives

[zhuravljov/yii2-debug

Yii debug toolbar

144501.1k4](/packages/zhuravljov-yii2-debug)[yiiext/migrate-command

This is an enhanced version of the Yii Database Migration Tool that adds module support and many more usefull features.

34173.8k4](/packages/yiiext-migrate-command)[koriym/dii

Dependency Injection Plugin for Yii 1

17195.8k](/packages/koriym-dii)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
