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


PHP F0FTable::getKnownFields方法代码示例

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


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

示例1: getReplacedPlaceholders

 /**
  * Replace all ITEM:* placeholders contained in a URL (or a string).
  *
  * @param string   $url   The URL wherein will be replaced the placeholders.
  * @param F0FTable $table A table object instance from which get known fields to replace.
  *
  * @return string The replaced URL.
  */
 private function getReplacedPlaceholders($url, F0FTable &$table)
 {
     // Ask to table which are the fields to replace
     $fields = $table->getKnownFields();
     // Replace all placeholders in the URL
     foreach ($fields as $field) {
         $url = str_replace('[ITEM:' . strtoupper($field) . ']', $table->get($field), $url);
     }
     return $url;
 }
开发者ID:fede91it,项目名称:fof-nnrelation,代码行数:18,代码来源:nnrelation.php

示例2: __construct

 /**
  * Create a relations object based on the provided F0FTable instance
  *
  * @param   F0FTable   $table  The table instance used to initialise the relations
  */
 public function __construct(F0FTable $table)
 {
     // Store the table
     $this->table = $table;
     // Get the table's type from its name
     $tableName = $table->getTableName();
     $tableName = str_replace('#__', '', $tableName);
     $type = explode("_", $tableName);
     if (count($type) == 1) {
         $this->tableType = array_pop($type);
     } else {
         $this->componentName = array_shift($type);
         $this->tableType = array_pop($type);
     }
     $this->tableType = F0FInflector::singularize($this->tableType);
     $tableKey = $table->getKeyName();
     unset($type);
     // Scan all table keys and look for foo_bar_id fields. These fields are used to populate parent relations.
     foreach ($table->getKnownFields() as $field) {
         // Skip the table key name
         if ($field == $tableKey) {
             continue;
         }
         if (substr($field, -3) != '_id') {
             continue;
         }
         $parts = explode('_', $field);
         // If the component type of the field is not set assume 'joomla'
         if (count($parts) == 2) {
             array_unshift($parts, 'joomla');
         }
         // Sanity check
         if (count($parts) != 3) {
             continue;
         }
         // Make sure we skip any references back to ourselves (should be redundant, due to key field check above)
         if ($parts[1] == $this->tableType) {
             continue;
         }
         // Default item name: the name of the table, singular
         $itemName = F0FInflector::singularize($parts[1]);
         // Prefix the item name with the component name if we refer to a different component
         if ($parts[0] != $this->componentName) {
             $itemName = $parts[0] . '_' . $itemName;
         }
         // Figure out the table class
         $tableClass = ucfirst($parts[0]) . 'Table' . ucfirst($parts[1]);
         $default = empty($this->relations['parent']);
         $this->addParentRelation($itemName, $tableClass, $field, $field, $default);
     }
     // Get the relations from the configuration provider
     $key = $table->getConfigProviderKey() . '.relations';
     $configRelations = $table->getConfigProvider()->get($key, array());
     if (!empty($configRelations)) {
         foreach ($configRelations as $relation) {
             if (empty($relation['type'])) {
                 continue;
             }
             if (isset($relation['pivotTable'])) {
                 $this->addMultipleRelation($relation['itemName'], $relation['tableClass'], $relation['localKey'], $relation['ourPivotKey'], $relation['theirPivotKey'], $relation['remoteKey'], $relation['pivotTable'], $relation['default']);
             } else {
                 $method = 'add' . ucfirst($relation['type']) . 'Relation';
                 if (!method_exists($this, $method)) {
                     continue;
                 }
                 $this->{$method}($relation['itemName'], $relation['tableClass'], $relation['localKey'], $relation['remoteKey'], $relation['default']);
             }
         }
     }
 }
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:75,代码来源:relations.php


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