当前位置: 首页>>代码示例>>PHP>>正文


PHP Table\TableBuilder类代码示例

本文整理汇总了PHP中Anomaly\Streams\Platform\Ui\Table\TableBuilder的典型用法代码示例。如果您正苦于以下问题:PHP TableBuilder类的具体用法?PHP TableBuilder怎么用?PHP TableBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TableBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:35,代码来源:HrefGuesser.php

示例2: guess

 /**
  * Guess the HREF for the views.
  *
  * @param TableBuilder $builder
  */
 public function guess(TableBuilder $builder)
 {
     $views = $builder->getViews();
     foreach ($views as &$view) {
         // Only automate it if not set.
         if (!isset($view['attributes']['href'])) {
             $view['attributes']['href'] = $this->url->to($this->request->path() . '?' . array_get($view, 'prefix') . 'view=' . $view['slug']);
         }
     }
     $builder->setViews($views);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:16,代码来源:HrefGuesser.php

示例3: guess

 /**
  * 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);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:31,代码来源:PermissionGuesser.php

示例4: 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);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:31,代码来源:PermissionGuesser.php

示例5: handle

 /**
  * Handle the command.
  */
 public function handle()
 {
     $table = $this->builder->getTable();
     $model = $this->builder->getModel();
     /*
      * If the model is already instantiated
      * then use it as is.
      */
     if (is_object($model)) {
         $table->setModel($model);
         return;
     }
     /*
      * If no model is set, try guessing the
      * model based on best practices.
      */
     if ($model === null) {
         $parts = explode('\\', str_replace('TableBuilder', 'Model', get_class($this->builder)));
         unset($parts[count($parts) - 2]);
         $model = implode('\\', $parts);
         $this->builder->setModel($model);
     }
     /*
      * If the model does not exist or
      * is disabled then skip it.
      */
     if (!$model || !class_exists($model)) {
         return;
     }
     /*
      * Set the model on the table!
      */
     $table->setModel(app($model));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:37,代码来源:SetTableModel.php

示例6: defaults

 /**
  * Set defaults.
  *
  * @param TableBuilder $builder
  */
 public function defaults(TableBuilder $builder)
 {
     $stream = $builder->getTableStream();
     if ($builder->getColumns() == []) {
         $builder->setColumns([$stream->getTitleColumn()]);
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:12,代码来源:HeaderDefaults.php

示例7: handle

 /**
  * Handle the filter.
  *
  * @param Builder               $query
  * @param SearchFilterInterface $filter
  */
 public function handle(Builder $query, TableBuilder $builder, SearchFilterInterface $filter)
 {
     $stream = $filter->getStream();
     $model = $builder->getTableModel();
     /**
      * If the model is translatable then
      * join it's translations so they
      * are filterable too.
      *
      * @var EloquentQueryBuilder $query
      */
     if ($model->getTranslationModelName() && !$query->hasJoin($model->getTranslationTableName())) {
         $query->leftJoin($model->getTranslationTableName(), $model->getTableName() . '.id', '=', $model->getTranslationTableName() . '.' . $model->getRelationKey());
     }
     $query->where(function (Builder $query) use($filter, $stream) {
         foreach ($filter->getColumns() as $column) {
             $query->orWhere($column, 'LIKE', "%{$filter->getValue()}%");
         }
         foreach ($filter->getFields() as $field) {
             $filter->setField($field);
             $fieldType = $stream->getFieldType($field);
             $fieldTypeQuery = $fieldType->getQuery();
             $fieldTypeQuery->setConstraint('or');
             $this->container->call([$fieldTypeQuery, 'filter'], compact('query', 'filter', 'builder'));
         }
     });
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:33,代码来源:SearchFilterQuery.php

示例8: authorize

 /**
  * Authorize the table.
  *
  * @param TableBuilder $builder
  */
 public function authorize(TableBuilder $builder)
 {
     // Try the option first.
     $permission = $builder->getTableOption('permission');
     if ($permission && !$this->authorizer->authorize($permission)) {
         abort(403);
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:13,代码来源:TableAuthorizer.php

示例9: 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);
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:13,代码来源:ButtonNormalizer.php

示例10: defaults

 /**
  * Default table views.
  *
  * @param TableBuilder $builder
  */
 public function defaults(TableBuilder $builder)
 {
     if (!($stream = $builder->getTableStream())) {
         return;
     }
     if ($stream->isTrashable() && !$builder->getViews()) {
         $builder->setViews(['all', 'trash']);
     }
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:14,代码来源:ViewDefaults.php

示例11: handle

 /**
  * Save the order of the entries.
  *
  * @param SectionCollection $sections
  * @param TableBuilder      $builder
  * @param array             $selected
  */
 public function handle(SectionCollection $sections, Redirector $redirector, TableBuilder $builder, array $selected)
 {
     $prefix = $builder->getTableOption('prefix');
     $edit = array_shift($selected);
     $ids = implode(',', $selected);
     if ($section = $sections->active()) {
         $builder->setTableResponse($redirector->to($section->getHref('edit/' . $edit . '?' . $prefix . 'edit_next=' . $ids)));
     }
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:16,代码来源:Edit.php

示例12: normalize

 /**
  * 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);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:14,代码来源:ActionNormalizer.php

示例13: handle

 /**
  * Handle the command.
  *
  * @param ResponseFactory $response
  */
 public function handle(ResponseFactory $response)
 {
     $table = $this->builder->getTable();
     $options = $table->getOptions();
     $data = $table->getData();
     $table->setResponse($response->view($options->get('wrapper_view', $this->builder->isAjax() ? 'streams::ajax' : 'streams::blank'), $data));
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:12,代码来源:SetTableResponse.php

示例14: 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);
 }
开发者ID:huglester,项目名称:streams-platform,代码行数:38,代码来源:SetActiveView.php

示例15: handle

 /**
  * Handle the command.
  */
 public function handle()
 {
     $stream = $this->builder->getTableStream();
     if (!$stream instanceof StreamInterface) {
         return;
     }
     $eager = [];
     if ($stream->isTranslatable()) {
         $eager[] = 'translations';
     }
     $assignments = $stream->getRelationshipAssignments();
     foreach ($this->builder->getColumns() as $column) {
         /**
          * If the column value is a string and uses a dot
          * format then check if it's a relation.
          */
         if (isset($column['value']) && is_string($column['value']) && preg_match("/^entry.([a-zA-Z\\_]+)./", $column['value'], $match)) {
             if ($assignment = $assignments->findByFieldSlug($match[1])) {
                 if ($assignment->getFieldType()->getNamespace() == 'anomaly.field_type.polymorphic') {
                     continue;
                 }
                 $eager[] = camel_case($match[1]);
             }
         }
     }
     $this->builder->setTableOption('eager', array_unique($this->builder->getTableOption('eager', []) + $eager));
 }
开发者ID:jacksun101,项目名称:streams-platform,代码行数:30,代码来源:EagerLoadRelations.php


注:本文中的Anomaly\Streams\Platform\Ui\Table\TableBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。