summaryrefslogtreecommitdiff
path: root/framework/Wsat/TWsatScaffoldingGenerator.php
blob: 7986793dd2c960d7f81a1314e34d8a4804589ce0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php

/**
 * @author Daniel Sampedro Bello <darthdaniel85@gmail.com>
 * @link http://www.pradosoft.com/
 * @copyright Copyright &copy; 2005-2014 PradoSoft
 * @license http://www.pradosoft.com/license/
 * @version $Id$
 * @since 3.3
 * @package Wsat
 */
Prado::using("System.Wsat.TWsatBaseGenerator");

class TWsatScaffoldingGenerator extends TWsatBaseGenerator
{

        function __construct()
        {
                parent::__construct();
        }

        public function generate()
        {
                $unitName = "Example";
                $class = $this->generateClass($unitName);
                $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php";
                file_put_contents($outputClass, $class);

                $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page";
                $page = $this->generatePage($unitName);
                file_put_contents($outputPage, $page);
        }

        // <editor-fold defaultstate="collapsed" desc="Generate Sigle Page">
        private function generatePage($fileName, $tContentId = "Content")
        {
                return <<<EOD
<com:TContent ID="Content">   

</com:TContent>
EOD;
        }

        private function generateClass($classname)
        {
                $date = date('Y-m-d h:i:s');
                $env_user = getenv("username");
                return <<<EOD
<?php
/**
 * Auto generated by PRADO - WSAT on $date.
 * @author $env_user
 */
class $classname extends TPage
{

}
EOD;
        }

// </editor-fold>
}

?>