當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ForeignKey::getInterface方法代碼示例

本文整理匯總了PHP中Propel\Generator\Model\ForeignKey::getInterface方法的典型用法代碼示例。如果您正苦於以下問題:PHP ForeignKey::getInterface方法的具體用法?PHP ForeignKey::getInterface怎麽用?PHP ForeignKey::getInterface使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Propel\Generator\Model\ForeignKey的用法示例。


在下文中一共展示了ForeignKey::getInterface方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addFKMutator

 /**
  * Adds the mutator (setter) method for setting an fkey related object.
  * @param string     &$script The script will be modified in this method.
  * @param ForeignKey $fk
  */
 protected function addFKMutator(&$script, ForeignKey $fk)
 {
     $table = $this->getTable();
     $fkTable = $fk->getForeignTable();
     if ($interface = $fk->getInterface()) {
         $className = $this->declareClass($interface);
     } else {
         $className = $this->getClassNameFromTable($fkTable);
     }
     $varName = $this->getFKVarName($fk);
     $script .= "\n    /**\n     * Declares an association between this object and a {$className} object.\n     *\n     * @param  {$className} \$v\n     * @return \$this|" . $this->getObjectClassName(true) . " The current object (for fluent API support)\n     * @throws PropelException\n     */\n    public function set" . $this->getFKPhpNameAffix($fk, false) . "({$className} \$v = null)\n    {";
     foreach ($fk->getMapping() as $map) {
         list($column, $rightValueOrColumn) = $map;
         if ($rightValueOrColumn instanceof Column) {
             $script .= "\n        if (\$v === null) {\n            \$this->set" . $column->getPhpName() . "(" . $this->getDefaultValueString($column) . ");\n        } else {\n            \$this->set" . $column->getPhpName() . "(\$v->get" . $rightValueOrColumn->getPhpName() . "());\n        }\n";
         } else {
             $val = var_export($rightValueOrColumn, true);
             $script .= "\n        if (\$v === null) {\n            \$this->set" . $column->getPhpName() . "(null);\n        } else {\n            \$this->set" . $column->getPhpName() . "({$val});\n        }\n                ";
         }
     }
     /* foreach local col */
     $script .= "\n        \$this->{$varName} = \$v;\n";
     // Now add bi-directional relationship binding, taking into account whether this is
     // a one-to-one relationship.
     if ($fk->isLocalPrimaryKey()) {
         $script .= "\n        // Add binding for other direction of this 1:1 relationship.\n        if (\$v !== null) {\n            \$v->set" . $this->getRefFKPhpNameAffix($fk, false) . "(\$this);\n        }\n";
     } else {
         $script .= "\n        // Add binding for other direction of this n:n relationship.\n        // If this object has already been added to the {$className} object, it will not be re-added.\n        if (\$v !== null) {\n            \$v->add" . $this->getRefFKPhpNameAffix($fk, false) . "(\$this);\n        }\n";
     }
     $script .= "\n\n        return \$this;\n    }\n";
 }
開發者ID:SwissalpS,項目名稱:Propel2,代碼行數:36,代碼來源:ObjectBuilder.php


注:本文中的Propel\Generator\Model\ForeignKey::getInterface方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。