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


PHP Tag::friendlyTitle方法代码示例

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


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

示例1: run

 public function run()
 {
     $faker = Faker::create();
     $log = new Stream('php://stdout');
     $log->info('Start ' . __CLASS__);
     /** @var Phalcon\Db\AdapterInterface $database */
     $database = $this->getDI()->get('db');
     $database->begin();
     for ($i = 0; $i <= self::TAGS_TOTAL; $i++) {
         $title = $faker->company;
         $description = $faker->text;
         $tags = new Tags();
         $tags->name = $title;
         $tags->slug = \Phalcon\Tag::friendlyTitle($title);
         $tags->numberPosts = 0;
         $tags->noBounty = 'N';
         $tags->noDigest = 'N';
         $tags->description = $description;
         if (!$tags->save()) {
             var_dump($tags->getMessages());
             $database->rollback();
             die;
         }
         $log->info('tags: ' . $tags->getName());
     }
 }
开发者ID:gitter-badger,项目名称:phanbook,代码行数:26,代码来源:TagsSeeder.php

示例2: run

 public function run()
 {
     $faker = Faker::create();
     $log = new Stream('php://stdout');
     $log->info('Start ' . __CLASS__);
     /** @var Phalcon\Db\AdapterInterface $database */
     $database = $this->getDI()->get('db');
     $userIds = Users::find(['columns' => 'id'])->toArray();
     $database->begin();
     for ($i = 0; $i <= self::POSTS_TOTAL; $i++) {
         $title = $faker->company;
         $userRandId = array_rand($userIds);
         $posts = new Posts();
         $posts->usersId = $userIds[$userRandId]['id'];
         $posts->type = rand(0, 1) ? 'questions' : 'tips';
         $posts->title = $title;
         $posts->slug = \Phalcon\Tag::friendlyTitle($title);
         $posts->numberViews = rand(5, 100);
         $posts->numberReply = rand(0, 20);
         $posts->content = $faker->text;
         $posts->sticked = 'N';
         $posts->status = 'A';
         $posts->locked = 'N';
         $posts->deleted = 0;
         $posts->acceptedAnswer = 'N';
         if (!$posts->save()) {
             var_dump($posts->getMessages());
             $database->rollback();
             die;
         }
         $log->info('posts: ' . $posts->getTitle());
     }
 }
开发者ID:gitter-badger,项目名称:phanbook,代码行数:33,代码来源:PostsSeeder.php

示例3: registryFunctions

 /**
  * Registers common function in Twig
  *
  * @param \Phalcon\Mvc\ViewInterface $view
  * @param \Phalcon\DiInterface       $di
  * @param array                      $userFunctions
  */
 protected function registryFunctions($view, DiInterface $di, $userFunctions = array())
 {
     $options = array('is_safe' => array('html'));
     $functions = array(new \Twig_SimpleFunction('content', function () use($view) {
         return $view->getContent();
     }, $options), new \Twig_SimpleFunction('partial', function ($partialPath) use($view) {
         return $view->partial($partialPath);
     }, $options), new \Twig_SimpleFunction('linkTo', function ($parameters, $text = null) {
         return \Phalcon\Tag::linkTo($parameters, $text);
     }, $options), new \Twig_SimpleFunction('textField', function ($parameters) {
         return \Phalcon\Tag::textField($parameters);
     }, $options), new \Twig_SimpleFunction('passwordField', function ($parameters) {
         return \Phalcon\Tag::passwordField($parameters);
     }, $options), new \Twig_SimpleFunction('hiddenField', function ($parameters) {
         return \Phalcon\Tag::hiddenField($parameters);
     }, $options), new \Twig_SimpleFunction('fileField', function ($parameters) {
         return \Phalcon\Tag::fileField($parameters);
     }, $options), new \Twig_SimpleFunction('checkField', function ($parameters) {
         return \Phalcon\Tag::checkField($parameters);
     }, $options), new \Twig_SimpleFunction('radioField', function ($parameters) {
         return \Phalcon\Tag::radioField($parameters);
     }, $options), new \Twig_SimpleFunction('submitButton', function ($parameters) {
         return \Phalcon\Tag::submitButton($parameters);
     }, $options), new \Twig_SimpleFunction('selectStatic', function ($parameters, $data = array()) {
         return \Phalcon\Tag::selectStatic($parameters, $data);
     }, $options), new \Twig_SimpleFunction('select', function ($parameters, $data = array()) {
         return \Phalcon\Tag::select($parameters, $data);
     }, $options), new \Twig_SimpleFunction('textArea', function ($parameters) {
         return \Phalcon\Tag::textArea($parameters);
     }, $options), new \Twig_SimpleFunction('form', function ($parameters = array()) {
         return \Phalcon\Tag::form($parameters);
     }, $options), new \Twig_SimpleFunction('endForm', function () {
         return \Phalcon\Tag::endForm();
     }, $options), new \Twig_SimpleFunction('getTitle', function () {
         return \Phalcon\Tag::getTitle();
     }, $options), new \Twig_SimpleFunction('stylesheetLink', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::stylesheetLink($parameters, $local);
     }, $options), new \Twig_SimpleFunction('javascriptInclude', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::javascriptInclude($parameters, $local);
     }, $options), new \Twig_SimpleFunction('image', function ($parameters) {
         return \Phalcon\Tag::image($parameters);
     }, $options), new \Twig_SimpleFunction('friendlyTitle', function ($text, $separator = null, $lowercase = true) {
         return \Phalcon\Tag::friendlyTitle($text, $separator, $lowercase);
     }, $options), new \Twig_SimpleFunction('getDocType', function () {
         return \Phalcon\Tag::getDocType();
     }, $options), new \Twig_SimpleFunction('getSecurityToken', function () use($di) {
         return $di->get("security")->getToken();
     }, $options), new \Twig_SimpleFunction('getSecurityTokenKey', function () use($di) {
         return $di->get("security")->getTokenKey();
     }, $options), new \Twig_SimpleFunction('url', function ($route) use($di) {
         return $di->get("url")->get($route);
     }, $options));
     if (!empty($userFunctions)) {
         $functions = array_merge($functions, $userFunctions);
     }
     foreach ($functions as $function) {
         $this->twig->addFunction($function);
     }
 }
开发者ID:lisong,项目名称:incubator,代码行数:66,代码来源:Twig.php

示例4: havePost

 /**
  * Creates a random post and return its id
  *
  * @param array $attributes Model attributes [Optional]
  * @return int
  */
 public function havePost(array $attributes = [])
 {
     $I = $this;
     $title = $this->faker->title;
     $default = ['title' => $title, 'slug' => Tag::friendlyTitle($title), 'content' => $this->faker->text(), 'users_id' => $this->faker->numberBetween(), 'categories_id' => $this->faker->numberBetween()];
     // do not generate slug manually
     if (array_key_exists('slug', $attributes) && $attributes['slug'] === false) {
         unset($attributes['slug'], $default['slug']);
     }
     return $I->haveRecord('Phosphorum\\Models\\Posts', array_merge($default, $attributes));
 }
开发者ID:foxman209,项目名称:forum,代码行数:17,代码来源:UserSteps.php

示例5: registryFunctions

 /**
  * Registers common function in Twig
  *
  * @param \Phalcon\Mvc\ViewInterface $view
  */
 private function registryFunctions($view)
 {
     $options = array('is_safe' => array('html'));
     $functions = array(new \Twig_SimpleFunction('content', function () use($view) {
         return $view->getContent();
     }, $options), new \Twig_SimpleFunction('partial', function ($partialPath) use($view) {
         return $view->partial($partialPath);
     }, $options), new \Twig_SimpleFunction('linkTo', function ($parameters, $text = null) {
         return \Phalcon\Tag::linkTo($parameters, $text);
     }, $options), new \Twig_SimpleFunction('textField', function ($parameters) {
         return \Phalcon\Tag::textField($parameters);
     }, $options), new \Twig_SimpleFunction('passwordField', function ($parameters) {
         return \Phalcon\Tag::passwordField($parameters);
     }, $options), new \Twig_SimpleFunction('hiddenField', function ($parameters) {
         return \Phalcon\Tag::hiddenField($parameters);
     }, $options), new \Twig_SimpleFunction('fileField', function ($parameters) {
         return \Phalcon\Tag::fileField($parameters);
     }, $options), new \Twig_SimpleFunction('checkField', function ($parameters) {
         return \Phalcon\Tag::checkField($parameters);
     }, $options), new \Twig_SimpleFunction('radioField', function ($parameters) {
         return \Phalcon\Tag::radioField($parameters);
     }, $options), new \Twig_SimpleFunction('submitButton', function ($parameters) {
         return \Phalcon\Tag::submitButton($parameters);
     }, $options), new \Twig_SimpleFunction('selectStatic', function ($parameters, $data = []) {
         return \Phalcon\Tag::selectStatic($parameters, $data);
     }, $options), new \Twig_SimpleFunction('select', function ($parameters, $data = []) {
         return \Phalcon\Tag::select($parameters, $data);
     }, $options), new \Twig_SimpleFunction('textArea', function ($parameters) {
         return \Phalcon\Tag::textArea($parameters);
     }, $options), new \Twig_SimpleFunction('form', function ($parameters = []) {
         return \Phalcon\Tag::form($parameters);
     }, $options), new \Twig_SimpleFunction('endForm', function () {
         return \Phalcon\Tag::endForm();
     }, $options), new \Twig_SimpleFunction('getTitle', function () {
         return \Phalcon\Tag::getTitle();
     }, $options), new \Twig_SimpleFunction('getTitle', function () {
         return \Phalcon\Tag::getTitle();
     }, $options), new \Twig_SimpleFunction('stylesheetLink', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::stylesheetLink($parameters, $local);
     }, $options), new \Twig_SimpleFunction('javascriptInclude', function ($parameters = null, $local = true) {
         return \Phalcon\Tag::javascriptInclude($parameters, $local);
     }, $options), new \Twig_SimpleFunction('image', function ($parameters) {
         return \Phalcon\Tag::image($parameters);
     }, $options), new \Twig_SimpleFunction('friendlyTitle', function ($text, $separator = null, $lowercase = true) {
         return \Phalcon\Tag::friendlyTitle($text, $separator, $lowercase);
     }, $options), new \Twig_SimpleFunction('getDocType', function () {
         return \Phalcon\Tag::getDocType();
     }, $options));
     foreach ($functions as $function) {
         $this->_twig->addFunction($function);
     }
 }
开发者ID:tashik,项目名称:phalcon_core,代码行数:57,代码来源:Twig.php

示例6: setAlias

 /**
  * Set Alias
  */
 public function setAlias($alias = '')
 {
     if (!$alias) {
         $alias = \Phalcon\Tag::friendlyTitle($this->name, "-");
     }
     $this->alias = $alias;
 }
开发者ID:sarahsampan,项目名称:compare-api,代码行数:10,代码来源:Products.php

示例7: friendlyTitle

 public static function friendlyTitle($text, $separator = "-", $lowercase = true, $replace = null)
 {
     return parent::friendlyTitle($text, $separator, $lowercase, $replace);
 }
开发者ID:mattvb91,项目名称:cphalcon,代码行数:4,代码来源:Tag.php

示例8: beforeUpdate

 public function beforeUpdate()
 {
     $this->slug = \Phalcon\Tag::friendlyTitle($this->title);
 }
开发者ID:moaljazaery,项目名称:phalcon-module-admin,代码行数:4,代码来源:Slugable.php

示例9: uploadByEncodedData

 public function uploadByEncodedData($data, $originalName, $mimeType = null)
 {
     if (!($headPos = strpos($data, ','))) {
         throw new Exception\InvalidArgumentException('ERR_FILE_ENCODED_UPLOAD_FORMAT_INCORRECT');
     }
     $fileHead = substr($data, 0, $headPos + 1);
     $fileEncodedData = trim(substr($data, $headPos + 1));
     $data = base64_decode($fileEncodedData);
     $tmpName = Text::random(\Phalcon\Text::RANDOM_ALNUM, 6);
     $tmpPath = $this->getUploadTmpPath();
     $tmp = $tmpPath . '/' . $tmpName;
     $adapter = new \Gaufrette\Adapter\Local($tmpPath);
     $filesystem = new \Gaufrette\Filesystem($adapter);
     $filesystem->write($tmpName, $data);
     $fileSize = filesize($tmp);
     $type = $mimeType;
     $filenameArray = explode(".", $originalName);
     $fileExtension = strtolower(array_pop($filenameArray));
     $originalFileName = implode('.', $filenameArray);
     $fileName = Tag::friendlyTitle($originalFileName);
     if ($fileName == '-') {
         $fileName = Text::random(Text::RANDOM_ALNUM, 6);
     }
     //hash file less then 10M
     if ($fileSize < 1048576 * 10) {
         $fileHash = hash_file('CRC32', $tmp, false);
     }
     if (false === strpos($type, 'image')) {
         $isImage = 0;
     } else {
         $isImage = 1;
     }
     $fileinfo = array('title' => $originalFileName, 'status' => 'published', 'storageAdapter' => 'local', 'originalName' => $originalName, 'fileSize' => $fileSize, 'mimeType' => $type, 'fileExtension' => $fileExtension, 'fileHash' => $fileHash, 'isImage' => $isImage, 'fileName' => $fileName . '.' . $fileExtension, 'createdAt' => time());
     if ($isImage) {
         $image = getimagesize($tmp);
         $fileinfo['imageWidth'] = $image[0];
         $fileinfo['imageHeight'] = $image[1];
     }
     $filesystem = $this->getDI()->getFileSystem();
     $path = md5(time());
     $path = str_split($path, 2);
     $pathlevel = $this->getUploadPathLevel();
     $pathlevel = $pathlevel > 6 ? 6 : $pathlevel;
     $path = array_slice($path, 0, $pathlevel);
     $filePath = implode('/', $path);
     $path = $filePath . '/' . $fileName . '.' . $fileExtension;
     $fileinfo['filePath'] = $filePath;
     $this->assign($fileinfo);
     if ($this->save()) {
         if (!$filesystem->has($path)) {
             if ($filesystem->write($path, file_get_contents($tmp))) {
                 unlink($tmp);
             } else {
                 throw new Exception\IOException('ERR_FILE_MOVE_TO_STORAGE_FAILED');
             }
         } else {
             throw new Exception\ResourceConflictException('ERR_FILE_UPLOAD_BY_CONFLICT_NAME');
         }
     } else {
         throw new Exception\RuntimeException('ERR_FILE_SAVE_TO_DB_FAILED');
     }
     return $this;
 }
开发者ID:skybird,项目名称:phalcon,代码行数:63,代码来源:Upload.php

示例10: die

    $user->timezone = $faker->timezone;
    if (!$user->save()) {
        $database->rollback();
        die(join(PHP_EOL, $user->getMessages()));
    }
    $log->info('User: ' . $user->name);
}
$database->commit();
$categoryIds = Categories::find(['columns' => 'id'])->toArray();
$userIds = Users::find(['columns' => 'id'])->toArray();
$database->begin();
for ($i = 0; $i <= 500; $i++) {
    $title = $faker->company;
    $post = new Posts();
    $post->title = $title;
    $post->slug = Tag::friendlyTitle($title);
    $post->content = $faker->text();
    $userRandId = array_rand($userIds);
    $post->users_id = $userIds[$userRandId]['id'];
    $categoryRandId = array_rand($categoryIds);
    $post->categories_id = $categoryIds[$categoryRandId]['id'];
    if (!$post->save()) {
        $database->rollback();
        die(join(PHP_EOL, $post->getMessages()));
    }
    if (!mt_rand(0, 10)) {
        $size = mt_rand(2, 10);
        $options = [];
        for ($j = 0; $j < $size; $j++) {
            $options[$j] = $faker->company;
        }
开发者ID:foxman209,项目名称:forum,代码行数:31,代码来源:random-entries.php

示例11: setAlias

 /**
  * Method to set the value of field alias
  *
  * @param string $name
  * @return $this
  */
 public function setAlias($alias)
 {
     $this->alias = \Phalcon\Tag::friendlyTitle($alias);
     return $this;
 }
开发者ID:stanislav-web,项目名称:phalcon-development,代码行数:11,代码来源:Categories.php


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