private function getEntityValues(Bag $field)
    {
        $baseParts = explode('/', $field->get('values'));
        if (count($baseParts) < 2) {
            throw new \InvalidArgumentException(sprintf('The "values" key for a ContentType select must be in the form of ContentType/field_name but "%s" given', $field->get('values')));
        }

        $contentType = $baseParts[0];
        $queryFields = explode(',', $baseParts[1]);
        foreach ($queryFields as $queryField) {
            if ($queryField) {
                continue;
            }
            throw new \InvalidArgumentException(sprintf('The "values" key for a ContentType select must include a single field, or comma separated fields, "%s" given', $field->get('values')));
        }

        $filter = $field->get('filter');
        $filter['order'] = $field->get('sort');
        $filter['limit'] = $field->get('limit', self::DEFAULT_LIMIT);
        /** @var QueryResultset $entities */
        $entities = $this->query->getContent($contentType, $filter);
        if (!$entities) {
            return [];
        }

        $values = [];
        $ctCount = count($entities->getOriginalQueries());
        foreach ($entities as $entity) {
            $id = $entity->get($field->get('keys', 'id'));
            if ($ctCount > 1) {
                $values[(string)$entity->getContenttype() . '/' . $id] = $entity->get($queryFields[0]);
            } else {
                $values[$id] = $entity->get($queryFields[0]);
            }
            if (isset($queryFields[1])) {
                $values[$id] .= ' / ' . $entity->get($queryFields[1]);
            }
        }

        return $values;
    }
private function getEntityValues(Bag $field)
    {
        $baseParts = explode('/', $field->get('values'));
        if (count($baseParts) < 2) {
            throw new \InvalidArgumentException(sprintf('The "values" key for a ContentType select must be in the form of ContentType/field_name but "%s" given', $field->get('values')));
        }

        $contentType = $baseParts[0];
        $queryFields = explode(',', $baseParts[1]);
        foreach ($queryFields as $queryField) {
            if ($queryField) {
                continue;
            }
            throw new \InvalidArgumentException(sprintf('The "values" key for a ContentType select must include a single field, or comma separated fields, "%s" given', $field->get('values')));
        }

        $filter = $field->get('filter');
        $filter['order'] = $field->get('sort');
        $filter['limit'] = $field->get('limit', self::DEFAULT_LIMIT);
        /** @var QueryResultset $entities */
        $entities = $this->query->getContent($contentType, $filter);
        if (!$entities) {
            return [];
        }

        $values = [];
        $ctCount = count($entities->getOriginalQueries());
        foreach ($entities as $entity) {
            $id = $entity->get($field->get('keys', 'id'));
            if ($ctCount > 1) {
                $values[(string)$entity->getContenttype() . '/' . $id] = $entity->get($queryFields[0]);
            } else {
                $values[$id] = $entity->get($queryFields[0]);
            }
            if (isset($queryFields[1])) {
                $values[$id] .= ' / ' . $entity->get($queryFields[1]);
            }
        }

        return $values;
    }
private function getEntityValues ( Bag $ field ) { $ baseParts = explode ( '/' , $ field -> get ( 'values' ) ) ; if ( count ( $ baseParts ) < 2 ) { throw new \ InvalidArgumentException ( sprintf ( 'The "values" key for a ContentType select must be in the form of ContentType/field_name but "%s" given' , $ field -> get ( 'values' ) ) ) ; } $ contentType = $ baseParts [ 0 ] ; $ queryFields = explode ( ',' , $ baseParts [ 1 ] ) ; foreach ( $ queryFields as $ queryField ) { if ( $ queryField ) { continue ; } throw new \ InvalidArgumentException ( sprintf ( 'The "values" key for a ContentType select must include a single field, or comma separated fields, "%s" given' , $ field -> get ( 'values' ) ) ) ; } $ filter = $ field -> get ( 'filter' ) ; $ filter [ 'order' ] = $ field -> get ( 'sort' ) ; $ filter [ 'limit' ] = $ field -> get ( 'limit' , self :: DEFAULT_LIMIT ) ; /** @var QueryResultset $entities */ $ entities = $ this -> query -> getContent ( $ contentType , $ filter ) ; if ( ! $ entities ) { return [ ] ; } $ values = [ ] ; $ ctCount = count ( $ entities -> getOriginalQueries ( ) ) ; foreach ( $ entities as $ entity ) { $ id = $ entity -> get ( $ field -> get ( 'keys' , 'id' ) ) ; if ( $ ctCount > 1 ) { $ values [ ( string ) $ entity -> getContenttype ( ) . '/' . $ id ] = $ entity -> get ( $ queryFields [ 0 ] ) ; } else { $ values [ $ id ] = $ entity -> get ( $ queryFields [ 0 ] ) ; } if ( isset ( $ queryFields [ 1 ] ) ) { $ values [ $ id ] .= ' / ' . $ entity -> get ( $ queryFields [ 1 ] ) ; } } return $ values ; }
Return select field value options from a ContentType's records.

@param Bag $field

@return array
Return select field value options from a ContentType s records .