Piwik\Plugins\API\Renderer\Json::renderArray PHP Метод

renderArray() публичный Метод

public renderArray ( $array )
    public function renderArray($array)
    {
        if (Piwik::isMultiDimensionalArray($array)) {
            $jsonRenderer = Renderer::factory('json');
            $jsonRenderer->setTable($array);
            $result = $jsonRenderer->render();
            return $this->applyJsonpIfNeeded($result);
        }
        $result = $this->renderDataTable($array);
        // if $array is a simple associative array, remove the JSON root array that is added by renderDataTable
        if (!empty($array) && Piwik::isAssociativeArray($array) && !Piwik::isMultiDimensionalArray($array)) {
            $result = substr($result, 1, strlen($result) - 2);
        }
        return $result;
    }

Usage Example

Пример #1
0
 public function renderArray($array)
 {
     $result = parent::renderArray($array);
     // if $array is a simple associative array, remove the JSON root array that is added by renderDataTable
     if (!empty($array) && Piwik::isAssociativeArray($array) && !Piwik::isMultiDimensionalArray($array)) {
         $result = substr($result, 1, strlen($result) - 2);
     }
     return $result;
 }
All Usage Examples Of Piwik\Plugins\API\Renderer\Json::renderArray