phalcon-ext / widgets
Widgets component for Phalcon.
Installs: 16 748
Dependents: 1
Suggesters: 0
Security: 0
Stars: 7
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
This package is auto-updated.
Last update: 2024-10-29 04:41:54 UTC
README
Installing
Install composer in a common location or in your project:
curl -s http://getcomposer.org/installer | php
Create the composer.json file as follows:
{
"require": {
"phalcon-ext/widgets": "dev-master"
}
}
Run the composer installer:
php composer.phar install
Add in your the code
require_once('vendor/autoload.php');
Using
class SomeWidget extends Phalcon\Ext\Widgets\WidgetBase { public function init() { // optional some method } public function render($params = null) { return $params['a'] + $params['b'] * ($params['c'] ?: 1); } } // Register widgets manager in DI $di->setShared('widgets', function() use ($di) { $widgets = new Phalcon\Ext\Widgets\Manager(); // Register some widget (the syntax is similar in DI) $widgets->set('some', function($options) { $widget = SomeWidget($options); $widget->init(); return $widget; }); return $widgets; }); /** * Somewhere in view */ $options = []; // Optional parameter, It will be passed to the constructor of the widget before creating echo $this->getDI()->get('widgets')->render('some', ['a' => 5, 'b' => 5, 'c' => 2], $options); // 15