本文整理汇总了PHP中Widget::register方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::register方法的具体用法?PHP Widget::register怎么用?PHP Widget::register使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::register方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: register
public function register()
{
$this->app->singleton('tee.siteIdentifier', function () {
return new SiteIdentifier();
});
// registra os macros e helpers
require_once __DIR__ . '/macros/html.php';
require_once __DIR__ . '/macros/form.php';
App::register('YAAP\\Theme\\ThemeServiceProvider');
App::register('Lavary\\Menu\\ServiceProvider');
App::register('Creitive\\Breadcrumbs\\BreadcrumbsServiceProvider');
App::register('Roumen\\Asset\\AssetServiceProvider');
App::register('Pingpong\\Widget\\WidgetServiceProvider');
App::register('Greggilbert\\Recaptcha\\RecaptchaServiceProvider');
class_alias('Pingpong\\Widget\\Facades\\Widget', 'Tee\\System\\Widget');
class_alias('YAAP\\Theme\\Facades\\Theme', 'Tee\\System\\Theme');
class_alias('Lavary\\Menu\\Facade', 'Tee\\System\\Menu');
class_alias('Creitive\\Breadcrumbs\\Facades\\Breadcrumbs', 'Tee\\System\\Breadcrumbs');
class_alias('Roumen\\Asset\\Asset', 'Tee\\System\\Asset');
class_alias('Tee\\System\\Facades\\SiteIdentifier', 'SiteIdentifier');
// registra os widgets
Widget::register('errorList', __NAMESPACE__ . '\\Widgets\\ErrorList');
}
示例2: getModuleInfo
<?php
/**
* 自动引入每个模型的挂件文件
* tangbing <tangbing@social-touch.com>
* 2015/10/14 16:20
*/
if (getModuleInfo()) {
$widgets_dir = getModuleInfo()->getPath() . '/Widgets';
if (is_dir($widgets_dir)) {
$dir = dir($widgets_dir);
while ($file = $dir->read()) {
if (in_array($file, ['.', '..']) || substr($file, '-3', '3') != 'php' || !is_file($widgets_dir . '/' . $file)) {
continue;
}
include $widgets_dir . '/' . $file;
}
}
}
/*
* DEMO 部分
* 文档地址:http://sky.pingpong-labs.com/docs/2.0/widget
*/
Widget::register('demo', function ($contents) {
return "<h1>{$contents}</h1>";
});
示例3:
<?php
/*
|--------------------------------------------------------------------------
| Application Widget
|--------------------------------------------------------------------------
|
| Here you may also register your custom widget.
|
*/
Widget::register('app', 'AppWidget');
示例4: function
});
Widget::register('datalist', function ($model, $view, $filter = [], $skip = 0, $limit = 10, $fields = [], $with = '', $with_filter = []) {
$model = new $model();
if ($with) {
if (is_array($with_filter) && !empty($with_filter)) {
$data = $model->select($fields)->where(function ($query) use($filter) {
foreach ($filter as $v) {
$query->where($v[0], $v[1], $v[2]);
}
})->skip($skip)->take($limit)->with(array($with => function ($query) use($with_filter) {
foreach ($with_filter as $key => $val) {
$query->{$key}($val);
}
}))->get()->toArray();
} else {
$data = $model->select($fields)->where(function ($query) use($filter) {
foreach ($filter as $v) {
$query->where($v[0], $v[1], $v[2]);
}
})->skip($skip)->take($limit)->with($with)->get()->toArray();
}
} else {
$data = $model->select('id')->where(function ($query) use($filter) {
foreach ($filter as $v) {
$query->where($v[0], $v[1], $v[2]);
}
})->skip($skip)->take($limit)->get()->toArray();
}
//dd($data);
return View::make($view, compact('data'))->render();
});
示例5: function
use App\News;
use App\Article;
use App\Slider;
// Виджет слайдера
Widget::register('slider', function () {
// Получение данных
$data['slider'] = Slider::orderBy('order', 'ASC')->get();
// Отображение
return view('marketing.widgets.slider', $data);
});
// Виджет новостей в футере
Widget::register('footer_latest_news', function () {
// Получаем новости, которые должны быть на главной
$data['news'] = News::whereIsOnMain(TRUE)->orderBy('created_at', 'DESC')->limit(3)->get();
// Отображаем
return view('marketing.widgets.footer_latest_news', $data);
});
// Виджет "О Компании" в футере
Widget::register('footer_about', function () {
// Получаем данные
$data['text'] = Article::firstOrCreate(['type' => 'footer_about'])->full_text;
// Отображаем
return view('marketing.widgets.footer_about', $data);
});
// Виджет "Зв'яжіться з нами" в футере
Widget::register('footer_contacts', function () {
// Получаем данные
$data['text'] = Article::firstOrCreate(['type' => 'footer_contacts'])->full_text;
// Отображаем
return view('marketing.widgets.footer_contacts', $data);
});
示例6:
<?php
namespace cms\Modules\Users;
\Widget::register('count_users', 'cms\\Modules\\Users\\App\\Widgets\\CountUsers');
\Widget::register('export_users', 'cms\\Modules\\Users\\App\\Widgets\\ExportUsers');
\Widget::register('social_buttons', 'cms\\Modules\\Users\\App\\Widgets\\SocialButtons');
\Widget::register('profile_users', 'cms\\Modules\\Users\\App\\Widgets\\ProfileUsers');
示例7:
<?php
Widget::register('header', 'App\\Widgets\\HeaderWidget');