/**
  * Returns all toplevel interface objects that are public (i.e. not assigned to a role)
  * @return InterfaceObject[]
  */
 public static function getPublicInterfaces()
 {
     return array_values(array_filter(InterfaceObject::getAllInterfaces(), function ($ifc) {
         return $ifc->isPublic();
     }));
 }
Exemple #2
0
            $content['invConjuncts'][] = $conj->__toString();
        }
        if ($conj->isSigConj()) {
            $content['sigConjuncts'][] = $conj->__toString();
        }
        if (!$conj->isInvConj() && !$conj->isSigConj()) {
            $content['unused'][] = $conj->__toString();
        }
    }
    print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
});
$app->get('/admin/report/interfaces', function () use($app) {
    if (Config::get('productionEnv')) {
        throw new Exception("Reports are not allowed in production environment", 403);
    }
    $arr = array();
    foreach (InterfaceObject::getAllInterfaces() as $key => $ifc) {
        $arr = array_merge($arr, $ifc->getInterfaceFlattened());
    }
    $content = array_map(function (InterfaceObject $ifc) {
        return array('path' => $ifc->path, 'label' => $ifc->label, 'crudC' => $ifc->crudC, 'crudR' => $ifc->crudR, 'crudU' => $ifc->crudU, 'crudD' => $ifc->crudD, 'src' => $ifc->srcConcept->name, 'tgt' => $ifc->tgtConcept->name, 'view' => $ifc->view->label, 'relation' => $ifc->relation->signature, 'flipped' => $ifc->relationIsFlipped, 'ref' => $ifc->refInterfaceId, 'root' => $ifc->isRoot(), 'public' => $ifc->isPublic(), 'roles' => implode(',', $ifc->ifcRoleNames));
    }, $arr);
    // Output
    $output = new OutputCSV();
    $output->addColumns(array_keys($content[0]));
    foreach ($content as $row) {
        $output->addRow($row);
    }
    $output->render('ifc-report.csv');
    // print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
});
<?php

use Ampersand\Config;
use Ampersand\Interfacing\InterfaceObject;
global $app;
$app->get('/interfaces', function () use($app) {
    if (Config::get('productionEnv')) {
        throw new Exception("List of all interfaces is not allowed in production environment", 403);
    }
    $content = InterfaceObject::getAllInterfaces();
    // Return all interfaces
    print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
});
$app->get('/interfaces/public', function () use($app) {
    if (Config::get('productionEnv')) {
        throw new Exception("List of public interfaces is not allowed in production environment", 403);
    }
    $content = InterfaceObject::getPublicInterfaces();
    // Return all public interfaces
    print json_encode($content, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
});