/**
  * Guess the action text.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $actions = $builder->getActions();
     $stream = $builder->getTableStream();
     if (!($module = $this->modules->active())) {
         return;
     }
     $section = $this->controlPanel->getControlPanelActiveSection();
     foreach ($actions as &$action) {
         /*
          * Nothing to do if set already.
          */
         if (isset($action['permission'])) {
             continue;
         }
         /*
          * Try and guess the permission.
          */
         if ($stream) {
             $action['permission'] = $module->getNamespace($stream->getSlug() . '.' . $action['slug']);
         } elseif ($section) {
             $action['permission'] = $module->getNamespace($section->getSlug() . '.' . $action['slug']);
         }
     }
     $builder->setActions($actions);
 }
 /**
  * Normalize action input.
  *
  * @param TableBuilder $builder
  */
 public function normalize(TableBuilder $builder)
 {
     $actions = $builder->getActions();
     $prefix = $builder->getTableOption('prefix');
     foreach ($actions as $slug => &$action) {
         $action = $this->process($prefix, $slug, $action);
     }
     $builder->setActions($actions);
 }
 /**
  * Guess the action handler.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $actions = $builder->getActions();
     foreach ($actions as &$action) {
         // Only if it's not already set.
         if (!isset($action['handler'])) {
             if (class_exists($class = $this->guessClass($builder, $action))) {
                 $action['handler'] = $class . '@handle';
             }
         }
     }
     $builder->setActions($actions);
 }
 /**
  * Guess the action text.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $actions = $builder->getActions();
     if (!($module = $this->modules->active())) {
         return;
     }
     foreach ($actions as &$action) {
         // Only if it's not already set.
         if (!isset($action['text'])) {
             $action['text'] = $module->getNamespace('button.' . $action['slug']);
         }
     }
     $builder->setActions($actions);
 }
 /**
  * Merge in registered parameters.
  *
  * @param TableBuilder $builder
  */
 public function merge(TableBuilder $builder)
 {
     $actions = $builder->getActions();
     foreach ($actions as &$parameters) {
         $action = $original = array_pull($parameters, 'action');
         if ($action && ($action = $this->actions->get($action))) {
             $parameters = array_replace_recursive($action, array_except($parameters, 'action'));
         }
         $button = array_get($parameters, 'button', $original);
         if ($button && ($button = $this->buttons->get($button))) {
             $parameters = array_replace_recursive($button, array_except($parameters, 'button'));
         }
     }
     $builder->setActions($actions);
 }
 /**
  * Build dropdown items.
  *
  * @param TableBuilder $builder
  */
 public function build(TableBuilder $builder)
 {
     $actions = $builder->getActions();
     foreach ($actions as $key => &$action) {
         if ($dropdown = array_get($action, 'parent')) {
             foreach ($actions as &$parent) {
                 if (array_get($parent, 'slug') == $dropdown) {
                     if (!isset($parent['dropdown'])) {
                         $parent['dropdown'] = [];
                     }
                     $parent['dropdown'][] = $action;
                 }
             }
         }
     }
     $builder->setActions($actions);
 }
 /**
  * Resolve table views.
  *
  * @param TableBuilder $builder
  */
 public function resolve(TableBuilder $builder)
 {
     $this->resolver->resolve($builder->getActions(), compact('builder'));
 }
 /**
  * Parse the table buttons.
  *
  * @param TableBuilder $builder
  */
 public function parse(TableBuilder $builder)
 {
     $builder->setActions($this->parser->parse($builder->getActions()));
 }
 /**
  * Evaluate the table actions.
  *
  * @param TableBuilder $builder
  */
 public function evaluate(TableBuilder $builder)
 {
     $builder->setActions($this->evaluator->evaluate($builder->getActions(), compact('builder')));
 }
 /**
  * Predict the presence of of the sortable action.
  *
  * @param TableBuilder $builder
  */
 public function predict(TableBuilder $builder)
 {
     if ($builder->getTableOption('sortable')) {
         $builder->setActions(array_merge(['reorder'], $builder->getActions()));
     }
 }