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


PHP Slugify::addRule方法代码示例

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


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

示例1: customizeSlugEngine

 /**
  * @param \Cocur\Slugify\Slugify $engine
  * @param string $attribute
  * @return \Cocur\Slugify\Slugify
  */
 public function customizeSlugEngine(Slugify $engine, $attribute)
 {
     $engine->addRule('e', 'a');
     $engine->addRule('i', 'a');
     $engine->addRule('o', 'a');
     $engine->addRule('u', 'a');
     return $engine;
 }
开发者ID:cviebrock,项目名称:eloquent-sluggable,代码行数:13,代码来源:PostWithCustomEngine.php

示例2: getSlugEngine

 protected function getSlugEngine()
 {
     $engine = new Slugify();
     $engine->addRule('e', 'a');
     $engine->addRule('i', 'a');
     $engine->addRule('o', 'a');
     $engine->addRule('u', 'a');
     return $engine;
 }
开发者ID:nilsenj,项目名称:itway,代码行数:9,代码来源:PostCustomEngine.php

示例3: genSlug

 /**
  * @param $string
  * @return string
  */
 public static function genSlug($string)
 {
     //		return $string;
     //$accepted = implode(self::$MY_RULE);
     //$replace_char = "/([^a-zA-Z0-9" . $accepted . "]|-)+/u";
     //echo $replace_char;
     $slug_engine = new Slugify();
     //new Slugify($replace_char);
     $slug_engine->addRules(self::$MY_RULE);
     $slug_engine->addRule('#', '-sharp-');
     $slug_engine->addRule('+', '-plus-');
     return $slug_engine->slugify($string);
 }
开发者ID:vuthaihoc,项目名称:flarum-vn-slug,代码行数:17,代码来源:Utils.php

示例4: registerServices

 /**
  * @inheritdoc
  */
 protected function registerServices(Application $app)
 {
     $config = $this->getConfig();
     $app['slugify'] = $app->share(function ($app) use($config) {
         if (!isset($config['regexp'])) {
             $config['regexp'] = '/([^A-Za-z0-9]|-)+/';
         }
         if (!isset($config['lowercase'])) {
             $config['lowercase'] = true;
         }
         $slugify = new Slugify($config['regexp'], array('lowercase' => $config['lowercase']));
         foreach ($config['rules'] as $key => $value) {
             $slugify->addRule($key, $value);
         }
         return $slugify;
     });
 }
开发者ID:SahAssar,项目名称:internationalslugs,代码行数:20,代码来源:InternationalSlugsExtension.php

示例5: getTurkishEngine

 /**
  * @param \Cocur\Slugify\Slugify $engine
  *
  * @return \Cocur\Slugify\Slugify
  */
 protected function getTurkishEngine(Slugify $engine)
 {
     $engine->addRule('Ç', 'C');
     $engine->addRule('Ğ', 'G');
     $engine->addRule('İ', 'I');
     $engine->addRule('Ş', 'S');
     $engine->addRule('Ö', 'O');
     $engine->addRule('Ü', 'U');
     $engine->addRule('ğ', 'g');
     $engine->addRule('ı', 'i');
     $engine->addRule('ş', 's');
     $engine->addRule('ö', 'o');
     $engine->addRule('ü', 'u');
     return $engine;
 }
开发者ID:boynoiz,项目名称:laravel-5-simple-cms,代码行数:20,代码来源:SluggableEngine.php

示例6: addRuleAddsRule

 /**
  * @test
  * @covers Cocur\Slugify\Slugify::addRule()
  * @covers Cocur\Slugify\Slugify::slugify()
  */
 public function addRuleAddsRule()
 {
     $this->assertInstanceOf('Cocur\\Slugify\\Slugify', $this->slugify->addRule('X', 'y'));
     $this->assertEquals('y', $this->slugify->slugify('X'));
 }
开发者ID:xing393939,项目名称:Laravel-5-Bootstrap-3-Starter-Site,代码行数:10,代码来源:SlugifyTest.php

示例7: addRule

 /**
  * Adds a custom rule to Slugify.
  *
  * @param string $character Character
  * @param string $replacement Replacement character
  * @return \Cocur\Slugify\Slugify 
  * @static 
  */
 public static function addRule($character, $replacement)
 {
     return \Cocur\Slugify\Slugify::addRule($character, $replacement);
 }
开发者ID:katzumi,项目名称:talent4startups,代码行数:12,代码来源:_ide_helper.php


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