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


PHP Inflector::slug方法代码示例

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


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

示例1: actionCreate

 /**
  * Creates a new Participant model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($meeting_id)
 {
     $mtg = new Meeting();
     $title = $mtg->getMeetingTitle($meeting_id);
     $model = new Participant();
     $model->meeting_id = $meeting_id;
     $model->invited_by = Yii::$app->user->getId();
     // load friends for auto complete field
     $friends = Friend::getFriendList(Yii::$app->user->getId());
     if ($model->load(Yii::$app->request->post())) {
         if (!User::find()->where(['email' => $model->email])->exists()) {
             // if email not already registered
             //  create new user with temporary username & password
             $temp_email_arr[] = $model->email;
             $model->username = Inflector::slug(implode('-', $temp_email_arr));
             $model->password = Yii::$app->security->generateRandomString(12);
             $model->participant_id = $model->addUser();
         } else {
             // add participant from user record
             $usr = User::find()->where(['email' => $model->email])->one();
             $model->participant_id = $usr->id;
         }
         // validate the form against model rules
         if ($model->validate()) {
             // all inputs are valid
             $model->save();
             return $this->redirect(['/meeting/view', 'id' => $meeting_id]);
         } else {
             // validation failed
             return $this->render('create', ['model' => $model, 'title' => $title, 'friends' => $friends]);
         }
     } else {
         return $this->render('create', ['model' => $model, 'title' => $title, 'friends' => $friends]);
     }
 }
开发者ID:Jagus,项目名称:study_project,代码行数:40,代码来源:ParticipantController.php

示例2: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->id) {
         $this->id = Inflector::slug($this->label);
     }
 }
开发者ID:asdf-studio,项目名称:yii2-admin-module,代码行数:10,代码来源:Item.php

示例3: getDetailUrl

 public function getDetailUrl($contextNavItemId = null)
 {
     if ($contextNavItemId) {
         return \luya\helpers\Url::toModule($contextNavItemId, 'gallery/album/index', ['albumId' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]);
     }
     return \luya\helpers\Url::to('gallery/album/index', ['albumId' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]);
 }
开发者ID:efueger,项目名称:luya,代码行数:7,代码来源:Album.php

示例4: getDetailUrl

 public function getDetailUrl($contextNavItemId = null)
 {
     if ($contextNavItemId) {
         return \cms\helpers\Url::toMenuItem($contextNavItemId, 'news/default/detail', ['id' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]);
     }
     return \luya\helpers\Url::toManager('news/default/detail', ['id' => $this->id, 'title' => \yii\helpers\Inflector::slug($this->title)]);
 }
开发者ID:gitter-badger,项目名称:luya,代码行数:7,代码来源:Article.php

示例5: up

 public function up()
 {
     $this->addColumn('{{%topic}}', 'slug', Schema::TYPE_STRING . ' NOT NULL');
     $topics = (new Query())->select('id, title')->from('{{%topic}}')->all();
     foreach ($topics as $topic) {
         $this->update('{{%topic}}', array('slug' => Inflector::slug($topic['title'])), 'id = :id', array(':id' => $topic['id']));
     }
 }
开发者ID:keltstr,项目名称:yii2-forum-1,代码行数:8,代码来源:m140918_054349_add_slug_column_to_topic.php

示例6: run

 public function run()
 {
     $alias = Inflector::slug(Yii::$app->request->post('name'));
     // if ($this->checkCommand->bindValues([':alias'=> $alias])->queryScalar() === false) {
     //}
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return ['alias' => $alias, 'code' => 100];
 }
开发者ID:worstinme,项目名称:yii2-uikit,代码行数:8,代码来源:AliasAction.php

示例7: testSlug

 public function testSlug()
 {
     $data = ['Привет. Hello, Йии-- Framework !--- Как дела ? How it goes ?' => 'privet-hello-jii-framework-kak-dela-how-it-goes', 'this is a title' => 'this-is-a-title', 'недвижимость' => 'nedvizimost', 'áàâéèêíìîóòôúùûã' => 'aaaeeeiiiooouuua', 'Ναδάλης ṃỹṛèşưḿĕ' => 'nadales-myresume', 'E=mc²' => 'e-mc2', '載å¥' => 'e14a'];
     foreach ($data as $source => $expected) {
         $this->assertEquals($expected, Inflector::slug($source));
     }
     //$this->assertEquals('this-is-my-text-', Inflector::slug('! this is my / text $## '));
 }
开发者ID:sciurodont,项目名称:yii2,代码行数:8,代码来源:InflectorTest.php

示例8: slugify

 private function slugify($slug)
 {
     if ($this->translit) {
         return Inflector::slug(TransliteratorHelper::process($slug), '-', true);
     } else {
         return $this->slug($slug, '-', true);
     }
 }
开发者ID:BayramovNicat,项目名称:toyplan,代码行数:8,代码来源:Slug.php

示例9: renderHeadline

 /**
  * @inheritDoc
  */
 protected function renderHeadline($block)
 {
     $content = $this->parseInline($block['content']);
     $hash = Inflector::slug(strip_tags($content));
     $hashLink = "<a href=\"#{$hash}\" name=\"{$hash}\" class=\"hashlink\">&para;</a>";
     $tag = 'h' . $block['level'];
     return "<{$tag}>{$content} {$hashLink}</{$tag}>";
 }
开发者ID:aivavic,项目名称:yii2,代码行数:11,代码来源:ApiMarkdown.php

示例10: run

 public function run()
 {
     $text = Yii::$app->request->post('text');
     $translateText = Yii::$app->translate->translate($text, 'en');
     $result[] = Inflector::slug($text);
     $result[] = Inflector::slug($translateText);
     return json_encode($result);
 }
开发者ID:rybinden,项目名称:yii2-select-slug,代码行数:8,代码来源:SlugAction.php

示例11: behaviors

 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return [TimestampBehavior::className(), ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => 'alias'], 'value' => function ($event) {
         return Inflector::slug($event->sender->title);
     }], ['class' => AttributeBehavior::className(), 'attributes' => [ActiveRecord::EVENT_AFTER_FIND => 'body'], 'value' => function ($event) {
         return HtmlPurifier::process(Markdown::process($event->sender->content, 'gfm'));
     }]];
 }
开发者ID:faninv,项目名称:gtqa,代码行数:11,代码来源:Question.php

示例12: getFileName

 static function getFileName($fileInstanse, $namePostfix = true)
 {
     $baseName = str_ireplace('.' . $fileInstanse->extension, '', $fileInstanse->name);
     $fileName = StringHelper::truncate(Inflector::slug($baseName), 32, '');
     if ($namePostfix || !$fileName) {
         $fileName .= ($fileName ? '-' : '') . substr(uniqid(md5(rand()), true), 0, 10);
     }
     $fileName .= '.' . $fileInstanse->extension;
     return $fileName;
 }
开发者ID:radiegtya,项目名称:easyii,代码行数:10,代码来源:Upload.php

示例13: validateName

 public function validateName($attribute)
 {
     $name = Inflector::camelize(Inflector::slug($this->{$attribute}));
     $label = $this->getAttributeLabel($attribute);
     if (empty($name)) {
         $this->addError($attribute, "'{$label}' должно состоять только из букв и цифр");
     } else {
         $this->{$attribute} = $name;
     }
 }
开发者ID:shubnikofff,项目名称:teleport,代码行数:10,代码来源:RoleForm.php

示例14: init

 /**
  * Initializes the module.
  */
 public function init()
 {
     if (is_null($this->cronGroup)) {
         $this->cronGroup = Inflector::slug(Yii::$app->id . '-' . Yii::getAlias('@app'));
     } else {
         $this->cronGroup = Inflector::slug($this->cronGroup);
     }
     $this->setComponents([$this->nameComponent => ['class' => 'gofmanaa\\crontask\\components\\Crontab', 'filename' => $this->fileName, 'directory' => $this->fileDir, 'crontabPath' => $this->crontabPath, 'cronGroup' => $this->cronGroup]]);
     parent::init();
 }
开发者ID:gofmanaa,项目名称:yii2-crontask,代码行数:13,代码来源:Module.php

示例15: getFileName

 public function getFileName()
 {
     if (!$this->_fileName) {
         $fileName = substr(uniqid(md5(rand()), true), 0, 10);
         $fileName .= '-' . Inflector::slug($this->file->baseName);
         $fileName .= '.' . $this->file->extension;
         $this->_fileName = $fileName;
     }
     return $this->_fileName;
 }
开发者ID:kintastish,项目名称:mobil,代码行数:10,代码来源:FileUploadModel.php


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