src/Model/Table/DblistsTable.php
public function getOptions(string $listName) : array
    {
        try {
            $entity = $this->find('all')
                ->enableHydration(true)
                ->where(['name' => $listName])
                ->firstOrFail();
        } catch (RecordNotFoundException $e) {
            return [];
        }

        $treeOptions = [
            'keyPath' => 'value',
            'valuePath' => 'name',
            'spacer' => ' - '
        ];

        Assert::isInstanceOf($entity, EntityInterface::class);

        return $this->DblistItems->find('treeList', $treeOptions)
            ->where(['dblist_id' => $entity->get('id')])
            ->toArray();
    }
public function getOptions(string $listName) : array
    {
        try {
            $entity = $this->find('all')
                ->enableHydration(true)
                ->where(['name' => $listName])
                ->firstOrFail();
        } catch (RecordNotFoundException $e) {
            return [];
        }

        $treeOptions = [
            'keyPath' => 'value',
            'valuePath' => 'name',
            'spacer' => ' - '
        ];

        Assert::isInstanceOf($entity, EntityInterface::class);

        return $this->DblistItems->find('treeList', $treeOptions)
            ->where(['dblist_id' => $entity->get('id')])
            ->toArray();
    }
public function getOptions ( string $ listName ) : array { try { $ entity = $ this -> find ( 'all' ) -> enableHydration ( true ) -> where ( [ 'name' => $ listName ] ) -> firstOrFail ( ) ; } catch ( RecordNotFoundException $ e ) { return [ ] ; } $ treeOptions = [ 'keyPath' => 'value' , 'valuePath' => 'name' , 'spacer' => ' - ' ] ; Assert :: isInstanceOf ( $ entity , EntityInterface :: class ) ; return $ this -> DblistItems -> find ( 'treeList' , $ treeOptions ) -> where ( [ 'dblist_id' => $ entity -> get ( 'id' ) ] ) -> toArray ( ) ; }
Reusable query options.

It can be used for retreving the options of the select field(list).
Options:
- name: List name (required)

@param string $listName List name to retrieve options from
@return mixed[] Options for the select option field
Reusable query options .