Example #1
0
 public static function renderDescription($data, $id = null)
 {
     if ($id) {
         $data['id'] = $id;
     }
     $result = null;
     $type = isset($data['type']) ? $data['type'] : null;
     if (isset($data['description'])) {
         $result = $data['description'];
         $result .= '<br>';
     }
     if (isset($data['$ref'])) {
         $refClass = self::getObjectFromRef($data['$ref']);
         $result .= 'An object of class ' . Html::a(ucfirst($refClass), Url::toRoute(['objects/' . $refClass]));
         $result .= '<br/>';
     }
     if (isset($data['enum'])) {
         $result .= self::renderEnum($data);
     }
     if ($type == 'array') {
         if (isset($data['items']['$ref'])) {
             $refClass = self::getObjectFromRef($data['items']['$ref']);
             $result .= 'Array of objects ' . Html::a(ucfirst($refClass), Url::toRoute(['objects/' . $refClass]));
             $result .= '<br/>';
         }
         if (isset($data['items']['type']) && $data['items']['type'] == 'object' && isset($data['items']['properties'])) {
             $result .= '<br>';
             $result .= '<strong>Object description:</strong>';
             $result .= ObjectAttrTableWidget::widget(['object' => $data['items']]);
         }
         if (isset($data['items']['oneOf'][0]['$ref'])) {
             $result .= 'An array of objects:';
             $property = isset($data['id']) ? $data['id'] : null;
             $result .= self::renderOneOf($data['items']['oneOf'], $property);
         }
         if (isset($data['items']['enum'])) {
             $result .= self::renderEnum($data['items'], 'The array consists of');
         }
     }
     if ($type == 'object' && !empty($data['properties'])) {
         $result .= '<br>';
         $result .= '<strong>:</strong>';
         $result .= ObjectAttrTableWidget::widget(['object' => $data, 'showNull' => false, 'showRequired' => true]);
     }
     if (isset($data['meta']['html'])) {
         $result .= $data['meta']['html'];
     }
     if (isset($data['oneOf']) && is_array($data['oneOf'])) {
         $result .= self::renderOneOf($data['oneOf'], $data['id']);
     }
     if (isset($data['default'])) {
         $result .= '<strong>Default value: </strong><code>' . $data['default'] . '</code>';
     }
     if (isset($data['meta']['restrictions'])) {
         $result .= '<div class="alert alert-warning" role="alert"><strong>Restrictions</strong><br>' . $data['meta']['restrictions'] . '</div>';
     }
     return $result;
 }
Example #2
0
?>



    <h4>result.data</h4>

<?php 
if ($data) {
    ?>

    <?php 
    $object = ['properties' => ['data' => $data]];
    ?>

    <?php 
    echo ObjectAttrTableWidget::widget(['object' => $object, 'showRequired' => true]);
    ?>

<?php 
} else {
    ?>

    No data

<?php 
}
?>


<?php 
if (isset($method['meta']['md'])) {
Example #3
0
echo ucfirst($object['id']);
?>
</h1>

<?php 
if (isset($object['title'])) {
    ?>
    <h4><?php 
    echo $object['title'];
    ?>
</h4>
<?php 
}
?>

<?php 
if (isset($object['description'])) {
    ?>
    <p>
        <?php 
    echo $object['description'];
    ?>
    </p>
<?php 
}
?>

<h3>Fields</h3>
<?php 
echo \app\components\widgets\ObjectAttrTableWidget::widget(['object' => $object, 'showRequired' => true]);