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


PHP Inflector::slug方法代码示例

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


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

示例1: prepare

 public function prepare($text)
 {
     $slugs = explode(' ', Inflector::slug($text, ' '));
     if (count($slugs)) {
         $collection = array();
         foreach ($slugs as $slug) {
             if (strlen($slug) > 1) {
                 if (!Arrays::in($slug, $collection)) {
                     array_push($collection, $slug);
                 }
             }
         }
         asort($collection);
     }
     return $collection;
 }
开发者ID:schpill,项目名称:thin,代码行数:16,代码来源:Fulltext.php

示例2: search

 private function search($condition = null, $results = array(), $populate = true)
 {
     self::$queries++;
     $collection = array();
     $condition = repl('NOT LIKE', 'NOTLIKE', $condition);
     $condition = repl('NOT IN', 'NOTIN', $condition);
     list($field, $op, $value) = explode(' ', $condition, 3);
     $indexes = $this->indexes();
     $fulltextes = $this->fulltextes();
     if (true === Arrays::in($field, $indexes)) {
         $ids = $this->searchIndexes($field, $op, $value);
         if (count($ids)) {
             foreach ($ids as $id) {
                 array_push($collection, $this->find($id, false));
             }
             if (true === $populate) {
                 $this->results = $collection;
             }
             return $collection;
         }
     }
     if ($op == 'LIKE' && Arrays::in($field, $fulltextes)) {
         $ids = $this->searchFulltextes($field, Inflector::slug($value, ' '));
         if (count($ids)) {
             foreach ($ids as $id) {
                 array_push($collection, $this->find($id, false));
             }
             if (true === $populate) {
                 $this->results = $collection;
             }
             return $collection;
         }
     }
     $datas = !count($results) ? $this->all(true) : $results;
     if (empty($condition)) {
         return $datas;
     }
     $keyCache = sha1('eavRDB_search_' . $condition . serialize($datas) . $this->entity);
     $cached = $this->cached($keyCache);
     if (empty($cached)) {
         if (count($datas)) {
             if (strstr($field, '.')) {
                 list($table, $field) = explode('.', $field, 2);
                 if ($table != $this->entity) {
                     $fkFields = isAke($this->joins, $table);
                     if (!empty($fkFields)) {
                         $db = new self($table);
                         list($entityField, $fkField) = Arrays::first($fkFields);
                         $fkField = empty($fkField) ? 'id' : $fkField;
                         foreach ($datas as $tab) {
                             if (!empty($tab)) {
                                 $joinVal = isAke($tab, $entityField, null);
                                 if (strlen($joinVal)) {
                                     $foreignDatas = $db->where("{$fkField} = {$joinVal}")->exec();
                                     foreach ($foreignDatas as $foreignTab) {
                                         if (!empty($foreignTab)) {
                                             $val = isAke($foreignTab, $field, null);
                                             if (strlen($val)) {
                                                 $val = repl('|', ' ', $val);
                                                 $check = $this->compare($val, $op, $value);
                                             } else {
                                                 $check = 'null' == $value ? true : false;
                                             }
                                             if (true === $check) {
                                                 array_push($collection, $tab);
                                             }
                                         }
                                     }
                                 } else {
                                     throw new Exception("The field {$entityField} has no value and must be not nulled.");
                                 }
                             }
                         }
                     } else {
                         throw new Exception("The table {$table} is not correctly joined.");
                     }
                 } else {
                     $condition = repl($this->entity . '.', '', $condition);
                     return $this->search($condition, $results, $populate);
                 }
             } else {
                 foreach ($datas as $tab) {
                     if (!empty($tab)) {
                         $val = isAke($tab, $field, null);
                         if (strlen($val)) {
                             $val = repl('|', ' ', $val);
                             $check = $this->compare($val, $op, $value);
                         } else {
                             $check = 'null' == $value ? true : false;
                         }
                         if (true === $check) {
                             array_push($collection, $tab);
                         }
                     }
                 }
                 $this->cached($keyCache, $collection);
             }
         }
     } else {
         $collection = $cached;
//.........这里部分代码省略.........
开发者ID:schpill,项目名称:thin,代码行数:101,代码来源:Mongonode.php

示例3: compile

 public function compile($code)
 {
     $v = $this;
     $e = function ($_) use($v) {
         return $v->show($_);
     };
     $slug = function ($str) {
         return Inflector::slug($str);
     };
     eval(' ?>' . $code . '<?php ');
 }
开发者ID:schpill,项目名称:thin,代码行数:11,代码来源:View.php


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