コード例 #1
0
 protected function setBuilder(AbstractOMBuilder $builder)
 {
     $this->builder = $builder;
     $this->objectClassName = $builder->getObjectClassName();
     $this->queryClassName = $builder->getQueryClassName();
     $this->queryFullClassName = $builder->getStubQueryBuilder()->getFullyQualifiedClassName();
     $this->tableMapClassName = $builder->getTableMapClassName();
 }
コード例 #2
0
 /**
  * Gets the namespace for the [base] object classes.
  *
  * @return string
  */
 public function getNamespace()
 {
     if ($namespace = parent::getNamespace()) {
         return $namespace . '\\Base';
     }
     return 'Base';
 }
コード例 #3
0
 public function getNamespace()
 {
     if ($namespace = parent::getNamespace()) {
         if ($this->getGeneratorConfig() && ($omns = $this->getGeneratorConfig()->getBuildProperty('namespaceOm'))) {
             return $namespace . '\\' . $omns;
         } else {
             return $namespace;
         }
     }
 }
コード例 #4
0
ファイル: PropelOMTask.php プロジェクト: norfil/Propel2
 /**
  * Uses a builder class to create the output class.
  * This method assumes that the DataModelBuilder class has been initialized with the build properties.
  * @param      OMBuilder $builder
  * @param      boolean $overwrite Whether to overwrite existing files with te new ones (default is YES).
  * @todo       -cPropelOMTask Consider refactoring build() method into AbstractPropelDataModelTask (would need to be more generic).
  */
 protected function build(AbstractOMBuilder $builder, $overwrite = true)
 {
     $path = $builder->getClassFilePath();
     $this->ensureDirExists(dirname($path));
     $_f = new PhingFile($this->getOutputDirectory(), $path);
     // skip files already created once
     if ($_f->exists() && !$overwrite) {
         $this->log("\t-> (exists) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
         return 0;
     }
     $script = $builder->build();
     foreach ($builder->getWarnings() as $warning) {
         $this->log($warning, Project::MSG_WARN);
     }
     // skip unchanged files
     if ($_f->exists() && $script == $_f->contents()) {
         $this->log("\t-> (unchanged) " . $builder->getClassFilePath(), Project::MSG_VERBOSE);
         return 0;
     }
     // write / overwrite new / changed files
     $action = $_f->exists() ? 'Updating' : 'Creating';
     $this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
     file_put_contents($_f->getAbsolutePath(), $script);
     return 1;
 }
コード例 #5
0
 /**
  * This declare the class use and get the correct name to use (short classname, Alias, or FQCN)
  *
  * @param  AbstractOMBuilder $builder
  * @param  boolean           $fqcn    true to return the $fqcn classname
  * @return string            ClassName, Alias or FQCN
  */
 public function getClassNameFromBuilder($builder, $fqcn = false)
 {
     if ($fqcn) {
         return $builder->getFullyQualifiedClassName();
     }
     $namespace = $builder->getNamespace();
     $class = $builder->getUnqualifiedClassName();
     if (isset($this->declaredClasses[$namespace]) && isset($this->declaredClasses[$namespace][$class])) {
         return $this->declaredClasses[$namespace][$class];
     }
     return $this->declareClassNamespace($class, $namespace, true);
 }
コード例 #6
0
ファイル: ModelManager.php プロジェクト: bondarovich/Propel2
 /**
  * Uses a builder class to create the output class.
  * This method assumes that the DataModelBuilder class has been initialized
  * with the build properties.
  *
  * @param  AbstractOMBuilder $builder
  * @param  boolean           $overwrite
  * @return int
  */
 protected function doBuild(AbstractOMBuilder $builder, $overwrite = true)
 {
     $path = $builder->getClassFilePath();
     $file = new \SplFileInfo($this->getWorkingDirectory() . DIRECTORY_SEPARATOR . $path);
     $this->filesystem->mkdir($file->getPath());
     // skip files already created once
     if ($file->isFile() && !$overwrite) {
         $this->log("\t-> (exists) " . $builder->getClassFilePath());
         return 0;
     }
     $script = $builder->build();
     foreach ($builder->getWarnings() as $warning) {
         $this->log($warning);
     }
     // skip unchanged files
     if ($file->isFile() && $script == file_get_contents($file->getPathname())) {
         $this->log("\t-> (unchanged) " . $builder->getClassFilePath());
         return 0;
     }
     // write / overwrite new / changed files
     $action = $file->isFile() ? 'Updating' : 'Creating';
     $this->log(sprintf("\t-> %s %s (table: %s, builder: %s)", $action, $builder->getClassFilePath(), $builder->getTable()->getName(), get_class($builder)));
     file_put_contents($file->getPathname(), $script);
     return 1;
 }
コード例 #7
0
ファイル: QueryBuilder.php プロジェクト: ktounet/Propel2
 /**
  * Checks whether any registered behavior on that table has a modifier for a hook
  * @param  string  $hookName The name of the hook as called from one of this class methods, e.g. "preSave"
  * @return boolean
  */
 public function hasBehaviorModifier($hookName, $modifier = null)
 {
     return parent::hasBehaviorModifier($hookName, 'QueryBuilderModifier');
 }
コード例 #8
0
ファイル: AbstractOMBuilder.php プロジェクト: disider/Propel2
 /**
  * @param  self           $builder
  * @param  boolean|string $aliasPrefix the prefix for the Alias or True for auto generation of the Alias
  * @return string
  */
 public function declareClassFromBuilder(self $builder, $aliasPrefix = false)
 {
     return $this->declareClassNamespacePrefix($builder->getUnqualifiedClassName(), $builder->getNamespace(), $aliasPrefix);
 }
コード例 #9
0
 public static function getRefRelatedBySuffix(ForeignKey $fk)
 {
     return parent::getRefRelatedBySuffix($fk);
 }
コード例 #10
0
ファイル: QueryBuilderTest.php プロジェクト: spryker/Propel
 /**
  * @param \Propel\Generator\Builder\Om\AbstractOMBuilder $queryBuilder
  * @param string $fileName
  *
  * @return void
  */
 protected function writePropelFile(AbstractOMBuilder $queryBuilder, $fileName)
 {
     $fileContent = $queryBuilder->build();
     file_put_contents($fileName, $fileContent);
 }
コード例 #11
0
 /**
  * Gets the package for the [base] object classes.
  * @return     string
  */
 public function getPackage()
 {
     return $this->getChild()->getPackage() ? $this->getChild()->getPackage() : parent::getPackage();
 }
コード例 #12
0
 public function getPackage()
 {
     return parent::getPackage();
 }