本文整理汇总了PHP中Anomaly\Streams\Platform\Ui\Form\FormBuilder::getButtons方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::getButtons方法的具体用法?PHP FormBuilder::getButtons怎么用?PHP FormBuilder::getButtons使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Anomaly\Streams\Platform\Ui\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::getButtons方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: guess
/**
* Guess the button from the hint.
*
* @param FormBuilder $builder
*/
public function guess(FormBuilder $builder)
{
$buttons = $builder->getButtons();
$module = $this->modules->active();
/*
* This will break if we can't figure
* out what the active module is.
*/
if (!$module instanceof Module) {
return;
}
foreach ($buttons as &$button) {
if (isset($button['text'])) {
continue;
}
if (!isset($button['button'])) {
continue;
}
$text = $module->getNamespace('button.' . $button['button']);
if (!isset($button['text']) && $this->translator->has($text)) {
$button['text'] = $text;
}
if ((!isset($button['text']) || !$this->translator->has($button['text'])) && $this->config->get('streams::system.lazy_translations')) {
$button['text'] = ucwords($this->string->humanize($button['button']));
}
if (!isset($button['text'])) {
$button['text'] = $text;
}
}
$builder->setButtons($buttons);
}
示例2: guess
/**
* Guess the HREF for a button.
*
* @param FormBuilder $builder
*/
public function guess(FormBuilder $builder)
{
$buttons = $builder->getButtons();
$entry = $builder->getFormEntry();
// Nothing to do if empty.
if (!($section = $this->sections->active())) {
return;
}
foreach ($buttons as &$button) {
if (isset($button['attributes']['href'])) {
continue;
}
switch (array_get($button, 'button')) {
case 'cancel':
$button['attributes']['href'] = $section->getHref();
break;
case 'delete':
$button['attributes']['href'] = $section->getHref('delete/' . $entry->getId());
break;
default:
// Determine the HREF based on the button type.
$type = array_get($button, 'button');
if ($type && !str_contains($type, '\\') && !class_exists($type)) {
$button['attributes']['href'] = $section->getHref($type . '/{entry.id}');
}
break;
}
}
$builder->setButtons($buttons);
}
示例3: normalize
/**
* Normalize button input.
*
* @param FormBuilder $builder
*/
public function normalize(FormBuilder $builder)
{
$buttons = $builder->getButtons();
foreach ($buttons as $key => &$button) {
$button = $this->process($key, $button);
}
$builder->setButtons($buttons);
}
示例4: merge
/**
* Merge in registered properties.
*
* @param FormBuilder $builder
*/
public function merge(FormBuilder $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);
}
示例5: guess
/**
* Guess the HREF for a button.
*
* @param FormBuilder $builder
*/
public function guess(FormBuilder $builder)
{
$buttons = $builder->getButtons();
$mode = $builder->getFormMode();
foreach ($buttons as &$button) {
if (!isset($button['enabled'])) {
continue;
}
if (is_bool($button['enabled'])) {
continue;
}
$button['enabled'] = $mode === $button['enabled'];
}
$builder->setButtons($buttons);
}
示例6: guess
/**
* Guess the HREF for a button.
*
* @param FormBuilder $builder
*/
public function guess(FormBuilder $builder)
{
$buttons = $builder->getButtons();
$mode = $builder->getFormMode();
foreach ($buttons as &$button) {
if (isset($button['enabled']) && is_bool($button['enabled'])) {
return;
}
switch (array_get($button, 'button')) {
case 'delete':
$button['enabled'] = $mode === 'edit';
break;
}
}
$builder->setButtons($buttons);
}
示例7: build
/**
* Build dropdown items.
*
* @param FormBuilder $builder
*/
public function build(FormBuilder $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);
}
示例8: resolve
/**
* Resolve form buttons.
*
* @param FormBuilder $builder
*/
public function resolve(FormBuilder $builder)
{
$this->resolver->resolve($builder->getButtons(), compact('builder'));
}
示例9: defaults
/**
* Default the form buttons when none are defined.
*
* @param FormBuilder $builder
*/
public function defaults(FormBuilder $builder)
{
if ($builder->getButtons() === []) {
$builder->setButtons(['cancel']);
}
}
示例10: evaluate
/**
* Evaluate the form buttons.
*
* @param FormBuilder $builder
*/
public function evaluate(FormBuilder $builder)
{
$entry = $builder->getFormEntry();
$builder->setButtons($this->evaluator->evaluate($builder->getButtons(), compact('builder', 'entry')));
}
示例11: parse
/**
* Parse the form buttons.
*
* @param FormBuilder $builder
*/
public function parse(FormBuilder $builder)
{
$entry = $builder->getFormEntry();
$builder->setButtons($this->parser->parse($builder->getButtons(), compact('entry')));
}