Source for file jDaoCompiler.class.php

Documentation is available at jDaoCompiler.class.php

  1. <?php
  2. /**
  3. @package    jelix
  4. @subpackage dao
  5. @author      Laurent Jouanneau
  6. @copyright   2005-2010 Laurent Jouanneau
  7. *  Idea of this class was get originally from the Copix project
  8. *  (CopixDaoCompiler, Copix 2.3dev20050901, http://www.copix.org)
  9. *  no more line of code are copyrighted by CopixTeam
  10. *
  11. @link        http://www.jelix.org
  12. @licence  http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public Licence, see LICENCE file
  13. */
  14.  
  15. /**
  16.  *
  17.  */
  18. require(JELIX_LIB_PATH.'dao/jDaoXmlException.class.php');
  19. require(JELIX_LIB_PATH.'dao/jDaoParser.class.php');
  20. require(JELIX_LIB_PATH.'dao/jDaoProperty.class.php');
  21. require(JELIX_LIB_PATH.'dao/jDaoMethod.class.php');
  22. require(JELIX_LIB_PATH.'dao/jDaoGenerator.class.php');
  23.  
  24. /**
  25.  * The compiler for the DAO xml files. it is used by jIncluder
  26.  * It produces some php classes
  27.  * @package  jelix
  28.  * @subpackage dao
  29.  */
  30. class jDaoCompiler  implements jISimpleCompiler {
  31.  
  32.     /**
  33.     * compile the given class id.
  34.     */
  35.     public function compile ($selector{
  36.  
  37.         $daoPath $selector->getPath();
  38.  
  39.         // load the XML file
  40.         $doc new DOMDocument();
  41.  
  42.         if(!$doc->load($daoPath)){
  43.             throw new jException('jelix~daoxml.file.unknown'$daoPath);
  44.         }
  45.  
  46.         if($doc->documentElement->namespaceURI != JELIX_NAMESPACE_BASE.'dao/1.0'){
  47.             throw new jException('jelix~daoxml.namespace.wrong',array($daoPath$doc->namespaceURI));
  48.         }
  49.  
  50.         global $gJConfig;
  51.         $tools jApp::loadPlugin($selector->driver'db''.dbtools.php'$selector->driver.'DbTools');
  52.         if(is_null($tools))
  53.             throw new jException('jelix~db.error.driver.notfound'$selector->driver);
  54.  
  55.         $parser new jDaoParser ($selector);
  56.         $parser->parse(simplexml_import_dom($doc)$tools);
  57.  
  58.         require_once($gJConfig->_pluginsPathList_db[$selector->driver].$selector->driver.'.daobuilder.php');
  59.         $class $selector->driver.'DaoBuilder';
  60.         $generator new $class ($selector$tools$parser);
  61.  
  62.         // generation of PHP classes corresponding to the DAO definition
  63.         $compiled '<?php '.$generator->buildClasses ()."\n?>";
  64.         jFile::write ($selector->getCompiledFilePath()$compiled);
  65.         return true;
  66.     }
  67. }

Documentation generated on Wed, 24 Sep 2014 21:57:08 +0200 by phpDocumentor 1.4.3