当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Core::loadModel方法代码示例

本文整理汇总了PHP中Doctrine_Core::loadModel方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Core::loadModel方法的具体用法?PHP Doctrine_Core::loadModel怎么用?PHP Doctrine_Core::loadModel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Core的用法示例。


在下文中一共展示了Doctrine_Core::loadModel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeTableClassDefinition

 /**
  * writeTableClassDefinition
  *
  * @return void
  */
 public function writeTableClassDefinition(array $definition, $path, $options = array())
 {
     $className = $definition['tableClassName'];
     $pos = strpos($className, "Model_");
     $fileName = substr($className, $pos + 6) . $this->_suffix;
     $writePath = $path . DIRECTORY_SEPARATOR . $fileName;
     $content = $this->buildTableClassDefinition($className, $definition, $options);
     Doctrine_Lib::makeDirectories(dirname($writePath));
     Doctrine_Core::loadModel($className, $writePath);
     if (!file_exists($writePath)) {
         file_put_contents($writePath, $content);
     }
 }
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:18,代码来源:Builder.php

示例2: writeDefinition

 /**
  * writeDefinition
  *
  * @param array $options
  * @param array $columns
  * @param array $relations
  * @param array $indexes
  * @param array $attributes
  * @param array $templates
  * @param array $actAs
  * @return void
  */
 public function writeDefinition(array $definition)
 {
     $originalClassName = $definition['className'];
     if ($prefix = $this->_classPrefix) {
         $definition['className'] = $prefix . $definition['className'];
         if (isset($definition['connectionClassName'])) {
             $definition['connectionClassName'] = $prefix . $definition['connectionClassName'];
         }
         $definition['topLevelClassName'] = $prefix . $definition['topLevelClassName'];
         if (isset($definition['inheritance']['extends'])) {
             $definition['inheritance']['extends'] = $prefix . $definition['inheritance']['extends'];
         }
     }
     $definitionCode = $this->buildDefinition($definition);
     if ($prefix) {
         $definitionCode = str_replace("this->hasOne('", "this->hasOne('{$prefix}", $definitionCode);
         $definitionCode = str_replace("this->hasMany('", "this->hasMany('{$prefix}", $definitionCode);
         $definitionCode = str_replace("'refClass' => '", "'refClass' => '{$prefix}", $definitionCode);
     }
     $fileName = $this->_getFileName($originalClassName, $definition);
     $packagesPath = $this->_packagesPath ? $this->_packagesPath : $this->_path;
     // If this is a main class that either extends from Base or Package class
     if (isset($definition['is_main_class']) && $definition['is_main_class']) {
         // If is package then we need to put it in a package subfolder
         if (isset($definition['is_package']) && $definition['is_package']) {
             $writePath = $this->_path . DIRECTORY_SEPARATOR . $definition['package_name'];
             // Otherwise lets just put it in the root of the path
         } else {
             $writePath = $this->_path;
         }
         if ($this->generateTableClasses()) {
             $this->writeTableClassDefinition($definition, $writePath, array('extends' => $definition['inheritance']['tableExtends']));
         }
     } else {
         if (isset($definition['is_package_class']) && $definition['is_package_class']) {
             if (isset($definition['package_custom_path'])) {
                 $writePath = $definition['package_custom_path'];
             } else {
                 $writePath = $packagesPath . DIRECTORY_SEPARATOR . $definition['package_path'];
             }
             if ($this->generateTableClasses()) {
                 $this->writeTableClassDefinition($definition, $writePath, array('extends' => $definition['inheritance']['tableExtends']));
             }
         } else {
             if (isset($definition['is_base_class']) && $definition['is_base_class']) {
                 // If it is a part of a package then we need to put it in a package subfolder
                 if (isset($definition['is_package']) && $definition['is_package']) {
                     $basePath = $this->_path . DIRECTORY_SEPARATOR . $definition['package_name'];
                     $writePath = $basePath . DIRECTORY_SEPARATOR . $this->_baseClassesDirectory;
                     // Otherwise lets just put it in the root generated folder
                 } else {
                     $writePath = $this->_path . DIRECTORY_SEPARATOR . $this->_baseClassesDirectory;
                 }
             }
         }
     }
     // If we have a writePath from the if else conditionals above then use it
     if (isset($writePath)) {
         Doctrine_Lib::makeDirectories($writePath);
         $writePath .= DIRECTORY_SEPARATOR . $fileName;
         // Otherwise none of the conditions were met and we aren't generating base classes
     } else {
         Doctrine_Lib::makeDirectories($this->_path);
         $writePath = $this->_path . DIRECTORY_SEPARATOR . $fileName;
     }
     $code = "<?php" . PHP_EOL;
     if (isset($definition['connection']) && $definition['connection']) {
         $code .= "// Connection Component Binding" . PHP_EOL;
         $code .= "Doctrine_Manager::getInstance()->bindComponent('" . $definition['connectionClassName'] . "', '" . $definition['connection'] . "');" . PHP_EOL;
     }
     $code .= PHP_EOL . $definitionCode;
     if ($this->_eolStyle) {
         $code = str_replace(PHP_EOL, $this->_eolStyle, $code);
     }
     Doctrine_Lib::makeDirectories(dirname($writePath));
     if (isset($definition['generate_once']) && $definition['generate_once'] === true) {
         if (!file_exists($writePath)) {
             $bytes = file_put_contents($writePath, $code);
         }
     } else {
         $bytes = file_put_contents($writePath, $code);
     }
     if (isset($bytes) && $bytes === false) {
         throw new Doctrine_Import_Builder_Exception("Couldn't write file " . $writePath);
     }
     Doctrine_Core::loadModel($definition['className'], $writePath);
 }
开发者ID:jamespaulmuir,项目名称:cotinga,代码行数:99,代码来源:Builder.php


注:本文中的Doctrine_Core::loadModel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。