protected function _messages(ResultSetInterface $results)
    {
        if (!$results->count()) {
            return [];
        }

        $messages = [];
        $pluralForms = 0;
        $item = $results->first();
        // There are max 6 plural forms possible but most people won't need
        // that so will only have the required number of value_{n} fields in db.
        for ($i = 5; $i > 0; $i--) {
            if (isset($item['value_' . $i])) {
                $pluralForms = $i;
                break;
            }
        }

        foreach ($results as $item) {
            $singular = $item['singular'];
            $context = $item['context'];
            $translation = $item['value_0'];
            if ($context) {
                $messages[$singular]['_context'][$context] = $item['value_0'];
            } else {
                $messages[$singular] = $item['value_0'];
            }

            if (empty($item['plural'])) {
                continue;
            }

            $key = $item['plural'];
            $plurals = [];
            for ($i = 0; $i <= $pluralForms; $i++) {
                $plurals[] = $item['value_' . $i];
            }

            if ($context) {
                $messages[$key]['_context'][$context] = $plurals;
            } else {
                $messages[$key] = $plurals;
            }
        }

        return $messages;
    }
protected function _messages(ResultSetInterface $results)
    {
        if (!$results->count()) {
            return [];
        }

        $messages = [];
        $pluralForms = 0;
        $item = $results->first();
        // There are max 6 plural forms possible but most people won't need
        // that so will only have the required number of value_{n} fields in db.
        for ($i = 5; $i > 0; $i--) {
            if (isset($item['value_' . $i])) {
                $pluralForms = $i;
                break;
            }
        }

        foreach ($results as $item) {
            $singular = $item['singular'];
            $context = $item['context'];
            $translation = $item['value_0'];
            if ($context) {
                $messages[$singular]['_context'][$context] = $item['value_0'];
            } else {
                $messages[$singular] = $item['value_0'];
            }

            if (empty($item['plural'])) {
                continue;
            }

            $key = $item['plural'];
            $plurals = [];
            for ($i = 0; $i <= $pluralForms; $i++) {
                $plurals[] = $item['value_' . $i];
            }

            if ($context) {
                $messages[$key]['_context'][$context] = $plurals;
            } else {
                $messages[$key] = $plurals;
            }
        }

        return $messages;
    }
protected function _messages ( ResultSetInterface $ results ) { if ( ! $ results -> count ( ) ) { return [ ] ; } $ messages = [ ] ; $ pluralForms = 0 ; $ item = $ results -> first ( ) ; // There are max 6 plural forms possible but most people won't need // that so will only have the required number of value_{n} fields in db. for ( $ i = 5 ; $ i > 0 ; $ i -- ) { if ( isset ( $ item [ 'value_' . $ i ] ) ) { $ pluralForms = $ i ; break ; } } foreach ( $ results as $ item ) { $ singular = $ item [ 'singular' ] ; $ context = $ item [ 'context' ] ; $ translation = $ item [ 'value_0' ] ; if ( $ context ) { $ messages [ $ singular ] [ '_context' ] [ $ context ] = $ item [ 'value_0' ] ; } else { $ messages [ $ singular ] = $ item [ 'value_0' ] ; } if ( empty ( $ item [ 'plural' ] ) ) { continue ; } $ key = $ item [ 'plural' ] ; $ plurals = [ ] ; for ( $ i = 0 ; $ i <= $ pluralForms ; $ i ++ ) { $ plurals [ ] = $ item [ 'value_' . $ i ] ; } if ( $ context ) { $ messages [ $ key ] [ '_context' ] [ $ context ] = $ plurals ; } else { $ messages [ $ key ] = $ plurals ; } } return $ messages ; }
Convert db resultset to messages array.

@param \Cake\Datasource\ResultSetInterface $results ResultSet instance.

@return array
Convert db resultset to messages array .