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


PHP Doctrine_Inflector::tableize方法代码示例

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


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

示例1: preSave

 /**
  * Throws an exception if the record is modified while it is 
  * locked. 
  * 
  * @param Doctrine_Event $event 
  * @return void
  */
 public function preSave(Doctrine_Event $event)
 {
     $modelName = Doctrine_Inflector::tableize(get_class($event->getInvoker()));
     $modifiedFields = $event->getInvoker()->getModified();
     $locked = $event->getInvoker()->isLocked;
     $lockModified = array_key_exists('isLocked', $modifiedFields);
     $numModified = count($modifiedFields);
     /**
      * Record fields haven't been modified, nothing to do here. 
      */
     if (!$event->getInvoker()->isModified()) {
         return;
     }
     /**
      * The record is not locked, and the lock isn't being changed, nothing to do here. 
      */
     if (!$locked && !$lockModified) {
         return;
     }
     /**
      * Only the lock is being modified so there's nothing to
      * do here. 
      */
     if ($lockModified && $numModified == 1) {
         return;
     }
     /**
      * The record is locked, throw an exception. 
      */
     if ($locked) {
         throw new Behavior_Lockable_Exception('The record must be unlocked before it can be modified.');
     }
 }
开发者ID:boydjd,项目名称:doctrine-addons,代码行数:40,代码来源:Listener.php

示例2: executeCreate

 /**
  * Display comment form incase of validation issues
  *  
  * @param sfWebRequest $request
  */
 public function executeCreate(sfWebRequest $request)
 {
     $this->rating_enabled = $request->hasParameter('rating_enabled') ? $request->getParameter('rating_enabled') : false;
     $form = $this->getForm($this->rating_enabled);
     if ($request->isMethod(sfRequest::POST) || $request->isMethod(sfRequest::PUT)) {
         $form->bind($request->getParameter($form->getName()));
         if ($form->isValid()) {
             if (sfConfig::get('app_rt_comment_moderation', false)) {
                 $form->save();
                 $this->notifyAdministrator($form->getObject());
             } else {
                 $form->getObject()->setIsActive(true);
                 $form->save();
                 $routes = $this->getContext()->getRouting()->getRoutes();
                 $route_name = Doctrine_Inflector::tableize($form->getObject()->getModel()) . '_show';
                 if (isset($routes[$route_name])) {
                     $target_object = $form->getObject()->getObject();
                     $cache_class = $form->getObject()->getModel() . 'CacheToolkit';
                     if (class_exists($cache_class)) {
                         call_user_func($cache_class . '::clearCache', $target_object);
                     }
                     $this->redirect($this->getContext()->getRouting()->generate($route_name, $target_object));
                 }
             }
             $this->redirect(sprintf('rtComment/saved?model=%s&model_id=%s', $form->getObject()->getModel(), $form->getObject()->getModelId()));
         } else {
             $this->getUser()->setFlash('default_error', true, false);
         }
     }
     $this->form = $form;
 }
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:36,代码来源:BasertCommentActions.class.php

示例3: getPopularTagsQueryTableProxy

 public function getPopularTagsQueryTableProxy($relations = null, $limit = 10, $hydrationMode = Doctrine::HYDRATE_RECORD)
 {
     if (!$relations) {
         $relations = array();
         $allRelations = $this->getInvoker()->getTable()->getRelations();
         foreach ($allRelations as $name => $relation) {
             if ($relation['refTable']) {
                 $relations[] = $name;
             }
         }
     }
     $relations = (array) $relations;
     $q = $this->getInvoker()->getTable()->createQuery('t')->select('t.*');
     $counts = array();
     foreach ($relations as $relation) {
         $countAlias = 'num_' . Doctrine_Inflector::tableize($relation);
         $q->leftJoin('t.' . $relation . ' ' . $relation);
         $q->addSelect('COUNT(DISTINCT ' . $relation . '.id) AS ' . $countAlias);
         $counts[] = 'COUNT(DISTINCT ' . $relation . '.id)';
     }
     $q->addSelect('(' . implode(' + ', $counts) . ') as total_num');
     $q->orderBy('total_num DESC');
     $q->groupBy('t.id');
     $q->addHaving('total_num > 0');
     $q->limit($limit);
     return $q;
 }
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:27,代码来源:TaggableTag.php

示例4: testClassifyTableize

 public function testClassifyTableize() {
     $name = "Forum_Category";
     $this->assertEqual(Doctrine_Inflector::tableize($name), "forum__category");
     $this->assertEqual(Doctrine_Inflector::classify(Doctrine_Inflector::tableize($name)), $name);
     
     
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:7,代码来源:ManagerTestCase.php

示例5: getPopularTagsQuery

 public function getPopularTagsQuery($relations = null, $limit = null, dmDoctrineQuery $q = null)
 {
     if (empty($relations)) {
         $this->loadTaggableModels();
         $relations = array_keys($this->getRelationHolder()->getAssociations());
         if (empty($relations)) {
             throw new dmException('There is no taggable model');
         }
     } else {
         $relations = (array) $relations;
     }
     $q = $q ? $q : $this->createQuery('t')->select('t.*');
     $rootAlias = $q->getRootAlias();
     $counts = array();
     foreach ($relations as $relation) {
         $countAlias = 'num_' . Doctrine_Inflector::tableize($relation);
         $q->leftJoin($rootAlias . '.' . $relation . ' ' . $relation);
         $q->addSelect('COUNT(DISTINCT ' . $relation . '.id) AS ' . $countAlias);
         $counts[] = 'COUNT(DISTINCT ' . $relation . '.id)';
     }
     $q->addSelect('(' . implode(' + ', $counts) . ') as total_num');
     //$q->orderBy('total_num DESC');
     $q->groupBy($rootAlias . '.id');
     $q->addHaving('total_num > 0');
     if (null !== $limit) {
         $q->limit($limit);
     }
     return $q;
 }
开发者ID:rafix,项目名称:bibliocnic,代码行数:29,代码来源:PluginDmTagTable.class.php

示例6: executeAjaxSearch

 public function executeAjaxSearch(sfWebRequest $request)
 {
     if ($request->hasParameter('models')) {
         $query = Doctrine::getTable('rtIndex')->getStandardSearchComponentInQuery($request->getParameter('q', ''), $this->getUser()->getCulture(), Doctrine::getTable('rtIndex')->getModelTypeRestrictionQuery(explode(',', $request->getParameter('models'))));
     } else {
         $query = Doctrine::getTable('rtIndex')->getBasePublicSearchQuery($request->getParameter('q'), $this->getUser()->getCulture());
     }
     $this->logMessage('{testing}' . $request->getParameter('q', ''), 'notice');
     $query->limit(100);
     $rt_indexes = $query->execute();
     $routes = $this->getContext()->getRouting()->getRoutes();
     $items = array();
     foreach ($rt_indexes as $rt_index) {
         $route = Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show';
         $url = '';
         if (isset($routes[Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show'])) {
             $url = sfContext::getInstance()->getController()->genUrl(array('sf_route' => $route, 'sf_subject' => $rt_index->getObject()));
             $url = str_replace('/frontend_dev.php', '', $url);
         }
         $object = $rt_index->getObject();
         $item = array('title' => $object->getTitle(), 'link' => $url);
         $item['placeholder'] = $object instanceof rtSnippet ? '![' . $object->getTitle() . '](snippet:' . $object->getCollection() . ')' : '';
         $items[] = $item;
     }
     return $this->returnJSONResponse(array('status' => 'success', 'items' => $items), $request);
 }
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:26,代码来源:BasertSearchAdminActions.class.php

示例7: setTableDefinition

 /**
  * Set table definition for contactable behavior
  * (borrowed from Sluggable in Doctrine core)
  *
  * @return void
  * @author Brent Shaffer
  */
 public function setTableDefinition()
 {
     foreach ($this->_options['fields'] as $field => $unit) {
         $name = Doctrine_Inflector::tableize($field . '_' . strtolower($unit));
         $this->_options['columns'][$field] = $name;
         $this->hasColumn($name, 'float');
     }
     $this->_table->unshiftFilter(new Doctrine_Record_Filter_Localizable($this->_options));
 }
开发者ID:JoshuaEstes,项目名称:sfDoctrineExtraPlugin,代码行数:16,代码来源:Localizable.php

示例8: getDetails

 static function getDetails($id, $categoryId)
 {
     $categoryName = RelationshipCategoryTable::$categoryNames[$categoryId];
     $db = Doctrine_Manager::connection();
     $sql = 'SELECT * FROM ' . Doctrine_Inflector::tableize($categoryName) . ' WHERE relationship_id = ?';
     $stmt = $db->execute($sql, array($id));
     $ret = $stmt->fetch(PDO::FETCH_ASSOC);
     unset($ret['id'], $ret['relationship_id']);
     return $ret;
 }
开发者ID:silky,项目名称:littlesis,代码行数:10,代码来源:RelationshipApi.class.php

示例9: deriveTaskName

 /**
  * Returns the name of the task the specified class _would_ implement
  * 
  * N.B. This method does not check if the specified class is actually a Doctrine Task
  * 
  * This is public so we can easily test its reactions to fully-qualified class names, without having to add
  * PHP 5.3-specific test code
  * 
  * @param string $className
  * @return string|bool
  */
 public static function deriveTaskName($className)
 {
     $nameParts = explode('\\', $className);
     foreach ($nameParts as &$namePart) {
         $prefix = __CLASS__ . '_';
         $baseName = strpos($namePart, $prefix) === 0 ? substr($namePart, strlen($prefix)) : $namePart;
         $namePart = str_replace('_', '-', Doctrine_Inflector::tableize($baseName));
     }
     return implode('-', $nameParts);
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:21,代码来源:Task.php

示例10: getShortPluginName

 public static function getShortPluginName($name)
 {
     // Special shortening for non sympal plugins
     if (substr($name, 0, 2) == 'sf' && !strstr($name, 'sfSympal')) {
         return $name;
     }
     if (strstr($name, 'sfSympal')) {
         return substr($name, 8, strlen($name) - 14);
     } else {
         return Doctrine_Inflector::classify(Doctrine_Inflector::tableize($name));
     }
 }
开发者ID:sympal,项目名称:sympal,代码行数:12,代码来源:sfSympalPluginToolkit.class.php

示例11: getDetails

 static function getDetails($id)
 {
     $entity = array();
     $db = Doctrine_Manager::connection();
     $sql = 'SELECT ed.name FROM extension_definition ed ' . 'LEFT JOIN extension_record er ON (er.definition_id = ed.id) ' . 'WHERE er.entity_id = ?';
     $stmt = $db->execute($sql, array($id));
     $extAry = $stmt->fetchAll(PDO::FETCH_COLUMN);
     $entity['types'] = implode(',', $extAry);
     $extsWithFields = array_intersect($extAry, ExtensionDefinitionTable::$extensionNamesWithFields);
     //get fields and values for each extension
     foreach ($extsWithFields as $ext) {
         $sql = 'SELECT * FROM ' . Doctrine_Inflector::tableize($ext) . ' WHERE entity_id = ?';
         $stmt = $db->execute($sql, array($id));
         $extData = $stmt->fetch(PDO::FETCH_ASSOC);
         unset($extData['id'], $extData['entity_id']);
         $entity = array_merge($entity, $extData);
     }
     return $entity;
 }
开发者ID:silky,项目名称:littlesis,代码行数:19,代码来源:EntityApi.class.php

示例12: _buildRelationships

 /**
  * buildRelationships
  *
  * Loop through an array of schema information and build all the necessary relationship information
  * Will attempt to auto complete relationships and simplify the amount of information required 
  * for defining a relationship
  *
  * @param  string $array 
  * @return void
  */
 protected function _buildRelationships($array)
 {
     // Handle auto detecting relations by the names of columns
     // User.contact_id will automatically create User hasOne Contact local => contact_id, foreign => id
     foreach ($array as $className => $properties) {
         if (isset($properties['columns']) && !empty($properties['columns']) && isset($properties['detect_relations']) && $properties['detect_relations']) {
             foreach ($properties['columns'] as $column) {
                 // Check if the column we are inflecting has a _id on the end of it before trying to inflect it and find
                 // the class name for the column
                 if (strpos($column['name'], '_id')) {
                     $columnClassName = Doctrine_Inflector::classify(str_replace('_id', '', $column['name']));
                     if (isset($array[$columnClassName]) && !isset($array[$className]['relations'][$columnClassName])) {
                         $array[$className]['relations'][$columnClassName] = array();
                         // Set the detected foreign key type and length to the same as the primary key
                         // of the related table
                         $type = isset($array[$columnClassName]['columns']['id']['type']) ? $array[$columnClassName]['columns']['id']['type'] : 'integer';
                         $length = isset($array[$columnClassName]['columns']['id']['length']) ? $array[$columnClassName]['columns']['id']['length'] : 8;
                         $array[$className]['columns'][$column['name']]['type'] = $type;
                         $array[$className]['columns'][$column['name']]['length'] = $length;
                     }
                 }
             }
         }
     }
     foreach ($array as $name => $properties) {
         if (!isset($properties['relations'])) {
             continue;
         }
         $className = $properties['className'];
         $relations = $properties['relations'];
         foreach ($relations as $alias => $relation) {
             $class = isset($relation['class']) ? $relation['class'] : $alias;
             if (!isset($array[$class])) {
                 continue;
             }
             $relation['class'] = $class;
             $relation['alias'] = isset($relation['alias']) ? $relation['alias'] : $alias;
             // Attempt to guess the local and foreign
             if (isset($relation['refClass'])) {
                 $relation['local'] = isset($relation['local']) ? $relation['local'] : Doctrine_Inflector::tableize($name) . '_id';
                 $relation['foreign'] = isset($relation['foreign']) ? $relation['foreign'] : Doctrine_Inflector::tableize($class) . '_id';
             } else {
                 $relation['local'] = isset($relation['local']) ? $relation['local'] : Doctrine_Inflector::tableize($relation['class']) . '_id';
                 $relation['foreign'] = isset($relation['foreign']) ? $relation['foreign'] : 'id';
             }
             if (isset($relation['refClass'])) {
                 $relation['type'] = 'many';
             }
             if (isset($relation['type']) && $relation['type']) {
                 $relation['type'] = $relation['type'] === 'one' ? Doctrine_Relation::ONE : Doctrine_Relation::MANY;
             } else {
                 $relation['type'] = Doctrine_Relation::ONE;
             }
             if (isset($relation['foreignType']) && $relation['foreignType']) {
                 $relation['foreignType'] = $relation['foreignType'] === 'one' ? Doctrine_Relation::ONE : Doctrine_Relation::MANY;
             }
             $relation['key'] = $this->_buildUniqueRelationKey($relation);
             $this->_validateSchemaElement('relation', array_keys($relation), $className . '->relation->' . $relation['alias']);
             $this->_relations[$className][$alias] = $relation;
         }
     }
     // Now we auto-complete opposite ends of relationships
     $this->_autoCompleteOppositeRelations();
     // Make sure we do not have any duplicate relations
     $this->_fixDuplicateRelations();
     // Set the full array of relationships for each class to the final array
     foreach ($this->_relations as $className => $relations) {
         $array[$className]['relations'] = $relations;
     }
     return $array;
 }
开发者ID:sensorsix,项目名称:app,代码行数:81,代码来源:Schema.php

示例13: generateMigrationClass

 /**
  * generateMigrationClass
  *
  * @return void
  */
 public function generateMigrationClass($className, $options = array(), $up = null, $down = null, $return = false)
 {
     $className = Doctrine_Inflector::urlize($className);
     $className = str_replace('-', '_', $className);
     $className = Doctrine_Inflector::classify($className);
     if ($return || !$this->getMigrationsPath()) {
         return $this->buildMigrationClass($className, null, $options, $up, $down);
     } else {
         if (!$this->getMigrationsPath()) {
             throw new Doctrine_Migration_Exception('You must specify the path to your migrations.');
         }
         $next = (string) $this->migration->getNextVersion();
         $fileName = str_repeat('0', 3 - strlen($next)) . $next . '_' . Doctrine_Inflector::tableize($className) . $this->suffix;
         $class = $this->buildMigrationClass($className, $fileName, $options, $up, $down);
         $path = $this->getMigrationsPath() . DIRECTORY_SEPARATOR . $fileName;
         if (class_exists($className) || file_exists($path)) {
             return false;
         }
         file_put_contents($path, $class);
         return true;
     }
 }
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:27,代码来源:Builder.php

示例14: include_partial

            <?php 
            if (rtSiteToolkit::isMultiSiteEnabled()) {
                ?>
            <?php 
                include_partial('rtAdmin/site_reference_key', array('id' => $rt_index->getSiteId()));
                ?>
            <?php 
            }
            ?>
          </h2>
          <p>
            <?php 
            echo $rt_index->getObject()->getDescription();
            ?>
 ... <?php 
            echo link_to_if(isset($routes[Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show']), __('read more'), Doctrine_Inflector::tableize($rt_index->getCleanModel()) . '_show', $rt_index->getObject());
            ?>
          </p>
        </li>
      <?php 
            $i++;
        }
        ?>
      </ul>
    <?php 
    } else {
        ?>
    <p><?php 
        echo __('Nothing found, please try again.');
        ?>
</p>
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:31,代码来源:indexSuccess.php

示例15: __construct

 /**
  * __construct
  *
  * Since this is an abstract classes that extend this must follow a patter of Doctrine_Task_{TASK_NAME}
  * This is what determines the task name for executing it.
  *
  * @return void
  */
 public function __construct($dispatcher = null)
 {
     $this->dispatcher = $dispatcher;
     $this->taskName = str_replace('_', '-', Doctrine_Inflector::tableize(str_replace('Doctrine_Task_', '', get_class($this))));
 }
开发者ID:JimmyVB,项目名称:Symfony-v1.2,代码行数:13,代码来源:Task.php


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