我怎么知道什么选项可用作SonataAdminBundle中ListMapper-> add()的第三个参数

用户名

我怎么知道ListMapper->add()SonataAdminBundle中的第3个参数可以使用哪些选项(与DatagridMapper->add()相同FormMapper->add())。

您说有一个带有选项的链接http://symfony.com/doc/current/bundles/SonataAdminBundle/reference/action_list.html#options

但这里也有一些http://symfony.com/doc/current/bundles/SonataAdminBundle/reference/action_list.html#visual-configuration

我怎么知道是否还有更多选择?完美的是,如果有人指出如何从Sonata代码中发现它(也许是ListMapper类)。

因为fe我想减小单元格中文本的大小(如果太大),而且我不知道是否可以使用某些第3个参数选项,或者是否需要覆盖模板。

朱尔斯·拉穆尔

问题在于选项存储在本地PHP数组中并由模板,DoctrineORM包等“即时”使用。因此,没有简单的方法来找到所有选项的详尽列表。

但是,我找到了一种解决方案,可以列出ListMapper的几乎所有选项(其中一些来自DatagridMapper,但是很难区分它们)。

他们来了:

_sort_order
admin_code
ajax_hidden
association_mapping
code
editable
field_mapping
field_name
field_options
field_type
format
global_search
header_class
header_style
identifier
label
mapping_type
name
operator_options
operator_type
options
parameters
parent_association_mappings
route
route.name
route.parameters
row_align
sort_field_mapping
sort_parent_association_mappings
sortable
timezone
translation_domain
virtual_field

为了获得此列表,我想到了使函数SonataAdminBundle \ Admin \ BaseFieldDescription :: getOptions()返回一个自定义数组对象,该对象记录对issetunset,getters和setters(带有方括号运算符)的每次调用我还记录了SonataAdminBundle \ Admin \ BaseFieldDescription :: getOption($ name,$ default = null)调用。

相关代码:

  • TestBundle \ ArrayTest

    namespace TestBundle;
    
    class ArrayTest implements \ArrayAccess
    {
        private $container = array();
        private $previousOffset;
    
        public function __construct($array, $previousOffset = null) {
            $this->container = $array;
            $this->previousOffset = $previousOffset;
        }
    
        public function offsetSet($offset, $value) {
            if (is_null($offset)) {
                $this->container[] = $value;
            } else {
                $this->dump($offset);
                $this->container[$offset] = $value;
            }
        }
    
        public function offsetExists($offset) {
            $this->dump($offset);
            return isset($this->container[$offset]);
        }
    
        public function offsetUnset($offset) {
            $this->dump($offset);
            unset($this->container[$offset]);
        }
    
        public function offsetGet($offset) {
            $this->dump($offset);
            if (isset($this->container[$offset])) {
                if (is_array($this->container[$offset])) {
                    $newOffset = ($this->previousOffset ?: '').$offset.'.';
    
                    if ($newOffset === 'route.parameter.') { // because of Sonata\AdminBundle\Admin\AbstractAdmin::generateObjectUrl()
                        return $this->container[$offset];
                    }
                    return new ArrayTest($this->container[$offset], $newOffset);
                }
    
                return $this->container[$offset];
            }
            return null;
        }
    
        private function dump($offset)
        {
            $offset = ($this->previousOffset ?: '').$offset;
            file_put_contents("/tmp/toto.txt", $offset."\n", FILE_APPEND);
        }
    }
    
  • SonataAdminBundle \ Admin \ BaseFieldDescription :: getOption($ name,$ default = null)

    public function getOption($name, $default = null)
    {
        file_put_contents("/tmp/toto.txt", $name."\n", FILE_APPEND);
        return isset($this->options[$name]) ? $this->options[$name] : $default;
    }
    
  • SonataAdminBundle \ Admin \ BaseFieldDescription :: getOptions()

    新函数的原型:getOptions($ fakeArray = true)

    public function getOptions($fakeArray = true)
    {
        if ($fakeArray) {
            return new \TestBundle\ArrayTest($this->options);
        }
    
        return $this->options;
    }
    
  • Sonata \ DoctrineORMAdminBundle \ Builder \ DatagridBuilder :: addFilter(DatagridInterface $ datagrid,$ type,FieldDescriptionInterface $ fieldDescription,AdminInterface $ admin)

    129行:

    $filter = $this->filterFactory->create($fieldDescription->getName(), $type, $fieldDescription->getOptions());
    

    $filter = $this->filterFactory->create($fieldDescription->getName(), $type, $fieldDescription->getOptions(false));
    

然后,在sonata admin上显示一个列表,然后运行cat /tmp/toto.txt | sort -u以获取上面的列表。

为了获得此选项列表,我显示了SonataUserBundle的管理员列表您可能会发现显示其他管理列表的更多选项(例如,使用其他模板)。


注意:我在Symfony 2.8.11SonataAdminBundle 3.8.0SonataDoctrineORMAdminBundle 3.1.0SonataUserBundle 3.0.1的全新安装上运行了此程序

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

Symfony表单组件。作为FormBuilderInterface :: add()方法的第三个参数,所有可用选项是什么

JavaScript中的forEach回调函数中的第三个参数的含义是什么

useReducer中第三个参数的目的是什么?

Flutter ProxyProvider构建器函数中的第三个输入参数是什么

为什么在iterator_apply示例中需要第三个参数

以下猫鼬查询中的第三个参数做什么?

什么是fstream open函数中的第三个参数

为什么在getopts bash中不解析第三个参数

std :: thread构造函数第三个模板参数的目的是什么?

传递给侦听器的第三个参数是什么?

Go结构字段的第三个参数是什么?

为什么ioctl调用的原型使用unsigned long作为第三个参数?

第三个参数(false)在document.addEventListener(“ deviceready”,OnDeviceReady,false)中指示什么;

getSupportLoaderManager(id,args,??)的第三个参数类型是什么

为什么 getLoaderManager.initLoader() 第三个参数 = 这是无效的?

文本阴影的第三个参数(模糊半径)有什么作用?

mysqli_poll()-第三个参数是什么?

“ rx”或“ bx”作为ax.plot的第三个参数是什么意思?

什么是第三个参数意味着看起来/像 XInputGetBatteryInformation()

types.MethodType python2中的第三个参数

Java 8函数编程中“ reduce”函数的第三个参数的目的

第三个参数Java8减少Object中的字符串属性

在asp.net MVC中获取第三个参数

如何在 Laravel where 子句数组中添加第三个参数

是否可以在自动完成文本框中添加第三个参数?

使用Express的Node.js中的app.get()第三个参数

restartLoader()和initLoader()片段中的第三个参数

网格搜索中具有第三个参数的自定义评分器

mpandroidchart 我想获得第三个值