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-2009 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.         // chargement du fichier XML
  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.         if(!isset($gJConfig->_pluginsPathList_db[$selector->driver])
  52.             || !file_exists($gJConfig->_pluginsPathList_db[$selector->driver]) ){
  53.             throw new jException('jelix~db.error.driver.notfound'$selector->driver);
  54.         }
  55.         $path $gJConfig->_pluginsPathList_db[$selector->driver].$selector->driver;
  56.         require_once($path.'.dbtools.php');
  57.         $class $selector->driver.'DbTools';
  58.         $tools new $class(null);
  59.  
  60.         $parser new jDaoParser ($selector);
  61.         $parser->parse(simplexml_import_dom($doc)$tools);
  62.  
  63.         require_once($path.'.daobuilder.php');
  64.         $class $selector->driver.'DaoBuilder';
  65.         $generator new $class ($selector$tools$parser);
  66.  
  67.         // génération des classes PHP correspondant à la définition de la DAO
  68.         $compiled '<?php '.$generator->buildClasses ()."\n?>";
  69.         jFile::write ($selector->getCompiledFilePath()$compiled);
  70.         return true;
  71.     }
  72. }

Documentation generated on Thu, 19 Sep 2013 00:03:06 +0200 by phpDocumentor 1.4.3