PHP Classes

File: build/generation/api.php

Recommend this page to a friend!
  Classes of Will Tinsdeall   Boiler Framework   build/generation/api.php   Download  
File: build/generation/api.php
Role: Application script
Content type: text/plain
Description: Auxiliary script
Class: Boiler Framework
Web application framework that implements MVC
Author: By
Last change:
Date: 9 years ago
Size: 2,636 bytes
 

Contents

Class file image Download
<?php
/**
 * API Generation for the framework
 *
 * @category API
 * @package Generation
 * @author Will Tinsdeall <will.tinsdeall@mercianlabels.com>
 * @copyright 2013 Mercian Labels
 * @license http://www.gnu.org/licenses/gpl.html GPL 3.0
 * @link http://www.mercianlabels.com
 * @since File available since Release 1.0.0
 */
require_once "common.php";





$models = getModels();

foreach (
$models as $table=>$model) {
    if (
strpos($table, "_") !== false) {
       
$class = implode("_",array_map(function($data) {
            return
ucfirst($data);
        },
explode("_", $table)));
    } else {
       
$class = ucfirst($table);
    }
   
   
$modelName = getClassName($table);
   
   
$name = ucfirst($table);
    echo
"API: /api/$table\n";
   
$file = <<<EOF
<?php
/**
 * API Generation for the framework
 *
 * PHP version 5.4
 *
 * @category API
 * @package Boiler
 * @author Will Tinsdeall <will.tinsdeall@mercianlabels.com>
 * @copyright 2013 Mercian Labels
 * @license http://www.mercianlabels.com All Rights Reserved
 * @link http://www.mercianlabels.com
 */
namespace System\Controller\Api;


/**
 * Autogenerated class for API access to the model \\Model\\
$class
 *
 * PHP version 5.4
 *
 * @category API
 * @package Boiler
 * @author Will Tinsdeall <will.tinsdeall@mercianlabels.com>
 * @license All Rights Reserved
 * @version GIT: \$Id$
 * @link http://www.mercianlabels.com
 *
 */
class
{$class} extends \\Controller\\Api\\ModelController {

    /**
     * Parses the name of the model which this API endpoint represents to the ModelController
     *
     * @return string
     */
    protected function getModelClass() {
        return "\\Model\\
{$modelName}";
    }
}
EOF;
   
   
$f = __DIR__."/../../framework/system/controller/api/{$class}.php";
   
file_put_contents($f, $file);
   
   
$f = __DIR__."/../../framework/application/controller/api/{$class}.php";
    if (!
file_exists($f)) {
       
$file = <<<EOF
<?php
/**
 * API Generation for the framework
 *
 * PHP version 5.4
 *
 * @category API
 * @package Boiler
 * @author Will Tinsdeall <will.tinsdeall@mercianlabels.com>
 * @copyright 2013 Mercian Labels
 * @license http://www.mercianlabels.com All Rights Reserved
 * @link http://www.mercianlabels.com
 */
namespace Controller\Api;

/**
 * Autogenerated stub for API access to the model \\Model\\
$class
 *
 * PHP version 5.4
 *
 * @category API
 * @package Boiler
 * @author ivebeenlinuxed <will.tinsdeall@mercianlabels.com>
 * @license All Rights Reserved
 * @version GIT: \$Id$
 * @link http://www.mercianlabels.com
 *
 */
class
{$class} extends \\System\\Controller\\Api\\{$class} {
}
EOF;
       
file_put_contents($f, $file);
    }
   
}