本文整理汇总了PHP中Anomaly\Streams\Platform\Ui\Table\TableBuilder::setButtons方法的典型用法代码示例。如果您正苦于以下问题:PHP TableBuilder::setButtons方法的具体用法?PHP TableBuilder::setButtons怎么用?PHP TableBuilder::setButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anomaly\Streams\Platform\Ui\Table\TableBuilder
的用法示例。
在下文中一共展示了TableBuilder::setButtons方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guess
/**
* Guess the HREF for a button.
*
* @param TableBuilder $builder
*/
public function guess(TableBuilder $builder)
{
$buttons = $builder->getButtons();
if (!($section = $this->sections->active())) {
return;
}
if (!($module = $this->modules->active())) {
return;
}
$stream = $builder->getTableStream();
foreach ($buttons as &$button) {
// If we already have an HREF then skip it.
if (isset($button['attributes']['href'])) {
continue;
}
switch (array_get($button, 'button')) {
case 'restore':
$button['attributes']['href'] = $this->url->to('entry/handle/restore/' . $module->getNamespace() . '/' . $stream->getNamespace() . '/' . $stream->getSlug() . '/{entry.id}');
break;
default:
// Determine the HREF based on the button type.
$type = array_get($button, 'segment', array_get($button, 'button'));
if ($type && !str_contains($type, '\\') && !class_exists($type)) {
$button['attributes']['href'] = $section->getHref($type . '/{entry.id}');
}
break;
}
}
$builder->setButtons($buttons);
}
示例2: handle
/**
* Handle the command.
*
* @param Request $request
* @param Container $container
*/
public function handle(Request $request, ViewHandler $handler)
{
$table = $this->builder->getTable();
$options = $table->getOptions();
$views = $table->getViews();
if ($views->active()) {
return;
}
if ($view = $views->findBySlug($request->get($options->get('prefix') . 'view'))) {
$view->setActive(true);
}
if (!$view && ($view = $views->first())) {
$view->setActive(true);
}
// Nothing to do.
if (!$view) {
return;
}
// Set columns from active view.
if (($columns = $view->getColumns()) !== null) {
$this->builder->setColumns($columns);
}
// Set buttons from active view.
if (($buttons = $view->getButtons()) !== null) {
$this->builder->setButtons($buttons);
}
// Set actions from active view.
if (($actions = $view->getActions()) !== null) {
$this->builder->setActions($actions);
}
$handler->handle($this->builder, $view);
}
示例3: guess
/**
* Guess the text for a button.
*
* @param TableBuilder $builder
*/
public function guess(TableBuilder $builder)
{
$buttons = $builder->getButtons();
if (!($module = $this->modules->active())) {
return;
}
if (!($stream = $builder->getTableStream())) {
return;
}
foreach ($buttons as &$button) {
if (isset($button['permission'])) {
continue;
}
/**
* Try and guess the permission value.
*/
switch (array_get($button, 'button')) {
case 'edit':
$button['permission'] = $module->getNamespace($stream->getSlug() . '.write');
break;
default:
break;
}
}
$builder->setButtons($buttons);
}
示例4: normalize
/**
* Normalize button input.
*
* @param TableBuilder $builder
*/
public function normalize(TableBuilder $builder)
{
$buttons = $builder->getButtons();
foreach ($buttons as $key => &$button) {
$button = $this->process($key, $button);
}
$builder->setButtons($buttons);
}
示例5: guess
/**
* Guess the HREF for a button.
*
* @param TableBuilder $builder
*/
public function guess(TableBuilder $builder)
{
$buttons = $builder->getButtons();
foreach ($buttons as &$button) {
if (isset($button['permission']) && !$this->authorizer->authorize($button['permission'])) {
$button['enabled'] = false;
}
}
$builder->setButtons($buttons);
}
示例6: merge
/**
* Merge in registered properties.
*
* @param TableBuilder $builder
*/
public function merge(TableBuilder $builder)
{
$buttons = $builder->getButtons();
foreach ($buttons as &$parameters) {
if ($button = $this->buttons->get(array_get($parameters, 'button'))) {
$parameters = array_replace_recursive($button, $parameters);
}
}
$builder->setButtons($buttons);
}
示例7: guess
/**
* Guess the text for a button.
*
* @param TableBuilder $builder
*/
public function guess(TableBuilder $builder)
{
$buttons = $builder->getButtons();
if (!($module = $this->modules->active())) {
return;
}
foreach ($buttons as &$button) {
// Skip if set already.
if (!isset($button['text']) && isset($button['slug'])) {
$button['text'] = $module->getNamespace('button.' . $button['slug']);
}
}
$builder->setButtons($buttons);
}
示例8: build
/**
* Build dropdown items.
*
* @param TableBuilder $builder
*/
public function build(TableBuilder $builder)
{
$buttons = $builder->getButtons();
foreach ($buttons as $key => &$button) {
if ($dropdown = array_get($button, 'parent')) {
foreach ($buttons as &$parent) {
if (array_get($parent, 'button') == $dropdown) {
if (!isset($parent['dropdown'])) {
$parent['dropdown'] = [];
}
$parent['dropdown'][] = $button;
}
}
}
}
$builder->setButtons($buttons);
}