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


PHP Propel::importClass方法代码示例

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


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

示例1: modifyDatabase

  public function modifyDatabase()
  {
    foreach ($this->getDatabase()->getTables() as $table)
    {
      $behaviors = $table->getBehaviors();

      if (!isset($behaviors['symfony']))
      {
        $behavior = clone $this;
        $table->addBehavior($behavior);
      }

      // symfony behaviors
      if (!isset($behaviors['symfony_behaviors']) && $this->getBuildProperty('propel.builder.addBehaviors'))
      {
        $class = Propel::importClass($this->getBuildProperty('propel.behavior.symfony_behaviors.class'));
        $behavior = new $class();
        $behavior->setName('symfony_behaviors');
        $table->addBehavior($behavior);
      }

      // timestampable
      if (!isset($behaviors['symfony_timestampable']))
      {
        $parameters = array();
        foreach ($table->getColumns() as $column)
        {
          if (!isset($parameters['create_column']) && in_array($column->getName(), array('created_at', 'created_on')))
          {
            $parameters['create_column'] = $column->getName();
          }

          if (!isset($parameters['update_column']) && in_array($column->getName(), array('updated_at', 'updated_on')))
          {
            $parameters['update_column'] = $column->getName();
          }
        }

        if ($parameters)
        {
          $class = Propel::importClass($this->getBuildProperty('propel.behavior.symfony_timestampable.class'));
          $behavior = new $class();
          $behavior->setName('symfony_timestampable');
          $behavior->setParameters($parameters);
          $table->addBehavior($behavior);
        }
      }
    }
  }
开发者ID:nurhidayatullah,项目名称:inventory,代码行数:49,代码来源:SfPropelBehaviorSymfony.php

示例2: modifyDatabase

 /**
  * Looks for tables marked as I18N and adds behaviors.
  */
 public function modifyDatabase()
 {
     $translationBehavior = Propel::importClass($this->getBuildProperty('propel.behavior.symfony_i18n_translation.class'));
     foreach ($this->getDatabase()->getTables() as $table) {
         $behaviors = $table->getBehaviors();
         if (!isset($behaviors['symfony_i18n']) && 'true' == $table->getAttribute('isI18N')) {
             $i18nTable = $this->getDatabase()->getTable($table->getAttribute('i18nTable'));
             // add the current behavior to the translatable model
             $behavior = clone $this;
             $behavior->setParameters(array('i18n_table' => $i18nTable->getName()));
             $table->addBehavior($behavior);
             // add the translation behavior to the translation model
             $behavior = new $translationBehavior();
             $behavior->setName('symfony_i18n_translation');
             $behavior->setParameters(array('culture_column' => $this->getCultureColumn($i18nTable)->getName()));
             $i18nTable->addBehavior($behavior);
         }
     }
 }
开发者ID:cuongnv540,项目名称:jobeet,代码行数:22,代码来源:SfPropelBehaviorI18n.php

示例3: getValidator

 /**
  * This function searches for the given validator $name under propel/validator/$name.php,
  * imports and caches it.
  *
  * @param      string $classname The dot-path name of class (e.g. myapp.propel.MyValidator)
  * @return     Validator object or null if not able to instantiate validator class (and error will be logged in this case)
  */
 public static function getValidator($classname)
 {
     try {
         $v = isset(self::$validatorMap[$classname]) ? self::$validatorMap[$classname] : null;
         if ($v === null) {
             $cls = Propel::importClass($classname);
             $v = new $cls();
             self::$validatorMap[$classname] = $v;
         }
         return $v;
     } catch (Exception $e) {
         Propel::log("BasePeer::getValidator(): failed trying to instantiate " . $classname . ": " . $e->getMessage(), Propel::LOG_ERR);
     }
 }
开发者ID:RadioCampusFrance,项目名称:airtime,代码行数:21,代码来源:BasePeer.php

示例4: loadDataFromArray

 /**
  * Implements the abstract loadDataFromArray method and loads the data using the generated data model.
  *
  * @param array   $data  The data to be loaded into the data source
  *
  * @throws Exception If data is unnamed.
  * @throws sfException If an object defined in the model does not exist in the data
  * @throws sfException If a column that does not exist is referenced
  */
 public function loadDataFromArray($data)
 {
     if ($data === null) {
         // no data
         return;
     }
     foreach ($data as $class => $datas) {
         $class = trim($class);
         $tableMap = $this->dbMap->getTable(constant(constant($class . '::PEER') . '::TABLE_NAME'));
         $column_names = call_user_func_array(array(constant($class . '::PEER'), 'getFieldNames'), array(BasePeer::TYPE_FIELDNAME));
         // iterate through datas for this class
         // might have been empty just for force a table to be emptied on import
         if (!is_array($datas)) {
             continue;
         }
         foreach ($datas as $key => $data) {
             // create a new entry in the database
             if (!class_exists($class)) {
                 throw new InvalidArgumentException(sprintf('Unknown class "%s".', $class));
             }
             $obj = new $class();
             if (!$obj instanceof BaseObject) {
                 throw new RuntimeException(sprintf('The class "%s" is not a Propel class. This probably means there is already a class named "%s" somewhere in symfony or in your project.', $class, $class));
             }
             if (!is_array($data)) {
                 throw new InvalidArgumentException(sprintf('You must give a name for each fixture data entry (class %s).', $class));
             }
             foreach ($data as $name => $value) {
                 if (is_array($value) && 's' == substr($name, -1)) {
                     // many to many relationship
                     $this->loadMany2Many($obj, substr($name, 0, -1), $value);
                     continue;
                 }
                 $isARealColumn = true;
                 try {
                     $column = $tableMap->getColumn($name);
                 } catch (PropelException $e) {
                     $isARealColumn = false;
                 }
                 // foreign key?
                 if ($isARealColumn) {
                     if ($column->isForeignKey() && null !== $value) {
                         $relatedTable = $this->dbMap->getTable($column->getRelatedTableName());
                         if (!isset($this->object_references[$relatedTable->getPhpName() . '_' . $value])) {
                             throw new InvalidArgumentException(sprintf('The object "%s" from class "%s" is not defined in your data file.', $value, $relatedTable->getPhpName()));
                         }
                         $value = $this->object_references[$relatedTable->getPhpName() . '_' . $value]->getByName($column->getRelatedName(), BasePeer::TYPE_COLNAME);
                     }
                 }
                 if (false !== ($pos = array_search($name, $column_names))) {
                     $obj->setByPosition($pos, $value);
                 } else {
                     if (is_callable(array($obj, $method = 'set' . sfInflector::camelize($name)))) {
                         $obj->{$method}($value);
                     } else {
                         throw new InvalidArgumentException(sprintf('Column "%s" does not exist for class "%s".', $name, $class));
                     }
                 }
             }
             $obj->save($this->con);
             // save the object for future reference
             if (method_exists($obj, 'getPrimaryKey')) {
                 $this->object_references[Propel::importClass(constant(constant($class . '::PEER') . '::CLASS_DEFAULT')) . '_' . $key] = $obj;
             }
         }
     }
 }
开发者ID:sanemat,项目名称:bllik,代码行数:76,代码来源:sfPropelData.class.php

示例5: importClass

 /**
  * @deprecated Use Propel::importClass() instead
  */
 public static function importClass($path)
 {
     return Propel::importClass($path);
 }
开发者ID:ketheriel,项目名称:ETVA,代码行数:7,代码来源:sfPropel.class.php

示例6: doSelectWithI18n

 public static function doSelectWithI18n(Criteria $c, $culture = null, PropelPDO $con = null)
 {
     $c = clone $c;
     if ($culture === null) {
         $culture = sfPropel::getDefaultCulture();
     }
     foreach (sfMixer::getCallables('BaseProductPeer:doSelectJoin:doSelectJoin') as $callable) {
         call_user_func($callable, 'BaseProductPeer', $c, $con);
     }
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     ProductPeer::addSelectColumns($c);
     $startcol = ProductPeer::NUM_COLUMNS - ProductPeer::NUM_LAZY_LOAD_COLUMNS;
     ProductI18nPeer::addSelectColumns($c);
     $c->addJoin(ProductPeer::ID, ProductI18nPeer::ID);
     $c->add(ProductI18nPeer::CULTURE, $culture);
     $stmt = BasePeer::doSelect($c, $con);
     $results = array();
     while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
         $omClass = ProductPeer::getOMClass();
         $cls = Propel::importClass($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($row);
         $obj1->setCulture($culture);
         $omClass = ProductI18nPeer::getOMClass();
         $cls = Propel::importClass($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($row, $startcol);
         $obj1->setProductI18nForCulture($obj2, $culture);
         $obj2->setProduct($obj1);
         $results[] = $obj1;
     }
     return $results;
 }
开发者ID:yasirgit,项目名称:afids,代码行数:35,代码来源:BaseProductPeer.php


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