src/FieldHandlers/Provider/SelectOptions/ListSelectOptions.php
public function provide($data = null, array $options = []) : array
    {
        $spacer = isset($options['spacer']) ? (string)$options['spacer'] : ' - ';
        $flatten = isset($options['flatten']) ? (bool)$options['flatten'] : true;

        list($module, $list) = false !== strpos($data, '.') ?
            explode('.', $data, 2) :
            [App::shortName(get_class($this->config->getTable()), 'Model/Table', 'Table'), $data];

        $result = [];
        try {
            $config = new ModuleConfig(ConfigType::LISTS(), $module, $list, ['flatten' => $flatten, 'filter' => true]);
            $config = $config->parse();
            if (! property_exists($config, 'items')) {
                return [];
            }

            $config = json_encode($config->items);
            if (false === $config) {
                return [];
            }

            $result = json_decode($config, true);
        } catch (InvalidArgumentException $e) {
            /* Do nothing.
             *
             * ModuleConfig checks for the file to exist and to be readable and so on, but here we do load lists
             * recursively (for sub-lists, etc), which might result in files not always being there.
             *
             * In this particular case, it's not the end of the world.
             */
            return [];
        }

        if (empty($result)) {
            return [];
        }

        if (! $flatten) {
            return $result;
        }

        foreach ($result as $key => $value) {
            $result[$key] = str_repeat($spacer, substr_count($key, '.')) . $value['label'];
        }

        return $result;
    }
public function provide($data = null, array $options = []) : array
    {
        $spacer = isset($options['spacer']) ? (string)$options['spacer'] : ' - ';
        $flatten = isset($options['flatten']) ? (bool)$options['flatten'] : true;

        list($module, $list) = false !== strpos($data, '.') ?
            explode('.', $data, 2) :
            [App::shortName(get_class($this->config->getTable()), 'Model/Table', 'Table'), $data];

        $result = [];
        try {
            $config = new ModuleConfig(ConfigType::LISTS(), $module, $list, ['flatten' => $flatten, 'filter' => true]);
            $config = $config->parse();
            if (! property_exists($config, 'items')) {
                return [];
            }

            $config = json_encode($config->items);
            if (false === $config) {
                return [];
            }

            $result = json_decode($config, true);
        } catch (InvalidArgumentException $e) {
            /* Do nothing.
             *
             * ModuleConfig checks for the file to exist and to be readable and so on, but here we do load lists
             * recursively (for sub-lists, etc), which might result in files not always being there.
             *
             * In this particular case, it's not the end of the world.
             */
            return [];
        }

        if (empty($result)) {
            return [];
        }

        if (! $flatten) {
            return $result;
        }

        foreach ($result as $key => $value) {
            $result[$key] = str_repeat($spacer, substr_count($key, '.')) . $value['label'];
        }

        return $result;
    }
public function provide ( $ data = null , array $ options = [ ] ) : array { $ spacer = isset ( $ options [ 'spacer' ] ) ? ( string ) $ options [ 'spacer' ] : ' - ' ; $ flatten = isset ( $ options [ 'flatten' ] ) ? ( bool ) $ options [ 'flatten' ] : true ; list ( $ module , $ list ) = false !== strpos ( $ data , '.' ) ? explode ( '.' , $ data , 2 ) : [ App :: shortName ( get_class ( $ this -> config -> getTable ( ) ) , 'Model/Table' , 'Table' ) , $ data ] ; $ result = [ ] ; try { $ config = new ModuleConfig ( ConfigType :: LISTS ( ) , $ module , $ list , [ 'flatten' => $ flatten , 'filter' => true ] ) ; $ config = $ config -> parse ( ) ; if ( ! property_exists ( $ config , 'items' ) ) { return [ ] ; } $ config = json_encode ( $ config -> items ) ; if ( false === $ config ) { return [ ] ; } $ result = json_decode ( $ config , true ) ; } catch ( InvalidArgumentException $ e ) { /* Do nothing.
             *
             * ModuleConfig checks for the file to exist and to be readable and so on, but here we do load lists
             * recursively (for sub-lists, etc), which might result in files not always being there.
             *
             * In this particular case, it's not the end of the world.
             */ return [ ] ; } if ( empty ( $ result ) ) { return [ ] ; } if ( ! $ flatten ) { return $ result ; } foreach ( $ result as $ key => $ value ) { $ result [ $ key ] = str_repeat ( $ spacer , substr_count ( $ key , '.' ) ) . $ value [ 'label' ] ; } return $ result ; }
Provide select options

@param mixed $data Data to use for provision
@param array $options Options to use for provision
@return array
Provide select options