Exemple #1
0
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 *
 * @package   APF-1.6
 * @version   1.3
 * @since     File available since 1.0
 * @author    Florian TEISSIER <*****@*****.**>
 * @copyright Copyright (c) 2015 by Teicorp. All rights reserved.
 */
$initial = array('status' => 'ko', 'error' => '');
try {
    if (!file_exists(SITE_ROOT . DS . 'Src' . DS . 'Service' . DS . ($route->path('prefix') ? $route->path('prefix') . DS : '') . $route->path('main') . 'Service.php')) {
        $site = new \Vendor\Core\CoreSite($config, $route->path('all'));
        $site->bddCnx();
        $result = $site->serviceExecute(false);
    } else {
        $site = new $service($config, $route->path('all'));
        $site->bddCnx();
        $result = $site->serviceExecute();
    }
} catch (\Vendor\Core\CoreCNXException $e) {
    $result['error'] = "une erreur c'est produite pendant la connexion à la base de données";
}
// Recherche error pour modification initial
if (!isset($result['error'])) {
    $initial['status'] = 'ok';
}
// Fusion réponse avec initial.
$retour = array_replace($initial, $result);
// Retour JSON