[ Index ] |
|
Code source de Symfony 1.0.0 |
1 <?php 2 3 /* 4 * $Id: PropelDataModelTask.php 64 2005-05-13 02:43:56Z root $ 5 * 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 7 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 8 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 9 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 10 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 11 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 12 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 13 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 14 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 15 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 16 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 17 * 18 * This software consists of voluntary contributions made by many individuals 19 * and is licensed under the LGPL. For more information please see 20 * <http://propel.phpdb.org>. 21 */ 22 23 require_once 'propel/phing/AbstractPropelDataModelTask.php'; 24 include_once 'propel/engine/database/model/AppData.php'; 25 include_once 'propel/engine/database/model/Database.php'; 26 include_once 'propel/engine/database/transform/XmlToAppData.php'; 27 28 /** 29 * A generic class that simply loads the data model and parses a control template. 30 * 31 * This class exists largely for compatibility with early Propel where this was 32 * a CapsuleTask subclass. This class also makes it easy to quickly add some custom 33 * datamodel-based transformations (by allowing you to put the logic in the templates). 34 * 35 * @author Hans Lellelid <hans@xmpl.org> 36 * @package propel.phing 37 * @version $Revision: 64 $ 38 */ 39 class PropelDataModelTask extends AbstractPropelDataModelTask { 40 41 /** 42 * This is the file where the generated text 43 * will be placed. 44 * @var string 45 */ 46 protected $outputFile; 47 48 /** 49 * This is the control template that governs the output. 50 * It may or may not invoke the services of worker 51 * templates. 52 * @var string 53 */ 54 protected $controlTemplate; 55 56 57 /** 58 * [REQUIRED] Set the output file for the 59 * generation process. 60 * @param string $outputFile (TODO: change this to File) 61 * @return void 62 */ 63 public function setOutputFile($outputFile) { 64 $this->outputFile = $outputFile; 65 } 66 67 /** 68 * Get the output file for the 69 * generation process. 70 * @return string 71 */ 72 public function getOutputFile() { 73 return $this->outputFile; 74 } 75 76 /** 77 * [REQUIRED] Set the control template for the 78 * generating process. 79 * @param string $controlTemplate 80 * @return void 81 */ 82 public function setControlTemplate ($controlTemplate) { 83 $this->controlTemplate = $controlTemplate; 84 } 85 86 /** 87 * Get the control template for the 88 * generating process. 89 * @return string 90 */ 91 public function getControlTemplate() { 92 return $this->controlTemplate; 93 } 94 95 protected function validate() 96 { 97 parent::validate(); 98 99 // Make sure the control template is set. 100 if ($this->controlTemplate === null) { 101 throw new BuildException("The control template needs to be defined!"); 102 } 103 // Make sure there is an output file. 104 if ($this->outputFile === null) { 105 throw new BuildException("The output file needs to be defined!"); 106 } 107 108 } 109 110 /** 111 * Creates Capsule context and parses control template. 112 * @return void 113 */ 114 public function main() 115 { 116 $this->validate(); 117 $context = $this->createContext(); 118 119 $context->put("dataModels", $this->getDataModels()); 120 121 $path = $this->outputDirectory . DIRECTORY_SEPARATOR . $this->outputFile; 122 $this->log("Generating to file " . $path); 123 124 try { 125 $this->log("Parsing control template: " . $this->controlTemplate); 126 $context->parse($this->controlTemplate, $path); 127 } catch (Exception $ioe) { 128 throw new BuildException("Cannot write parsed template: ". $ioe->getMessage()); 129 } 130 } 131 }
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Fri Mar 16 22:42:14 2007 | par Balluche grâce à PHPXref 0.7 |