Example #1
0
 public function testSlugSpeed()
 {
     $_this = $this;
     runBench(array('Slug::filter' => function () use($_this) {
         return Slug::filter($_this->getRandomString(15));
     }), array('count' => 1000, 'name' => 'Slug speed'));
 }
Example #2
0
 /**
  * Before save callback.
  *
  * @param Event $event
  * @param EntityInterface $entity
  * @param \ArrayObject $options
  * @return bool
  * @SuppressWarnings("unused")
  */
 public function afterSave(Event $event, EntityInterface $entity, \ArrayObject $options)
 {
     $aro = $this->node($entity)->first();
     $aro->set('role_id', $entity->get('parent_id'));
     $aro->set('alias', sprintf('User-%s', Slug::filter($entity->get('username'))));
     $this->Aro->save($aro);
     return true;
 }
Example #3
0
 /**
  * Get plugin alias.
  *
  * @param $plugin
  * @return string
  */
 public static function alias($plugin)
 {
     $_plg = $plugin;
     $plugin = FS::clean(Slug::filter($plugin), '/');
     if (!strpos($_plg, '/') && !strpos($_plg, '\\')) {
         $plugin = Inflector::underscore($_plg);
     }
     return Str::low($plugin);
 }
Example #4
0
 /**
  * @return string
  */
 protected function _getResultFile()
 {
     // Normalize relative path
     $relPath = Slug::filter($this->_hash, '_');
     $relPath = Str::low($relPath);
     // Gett full clean path
     $fullPath = FS::real($this->_options->get('cache_path')) . '/' . $relPath . '.css';
     $fullPath = FS::clean($fullPath);
     return $fullPath;
 }
Example #5
0
 public function test()
 {
     isTrue(Slug::seemsUTF8('Денис'));
     is('A', Slug::removeAccents("Á"));
     is('e', Slug::removeAccents("ė"));
     is('U', Slug::removeAccents("Ü"));
     is('Ae', Slug::removeAccents("Ä", 'de'));
     is('OEoeAEDHTHssaedhth', Slug::removeAccents(chr(140) . chr(156) . chr(198) . chr(208) . chr(222) . chr(223) . chr(230) . chr(240) . chr(254)));
     $input = 'Benoit! à New-York? j’ai perçu 1 % : Qu’as-tu "gagné" chez M. V. Noël? Dix francs.';
     $expect = 'Benoit! a New-York? j’ai percu 1 % : Qu’as-tu "gagne" chez M. V. Noel? Dix francs.';
     is($expect, Slug::removeAccents($input));
 }
Example #6
0
 /**
  * @return string
  */
 protected function _getProfFileName()
 {
     return Slug::filter($this->_getFileName() . '-' . $this->_getOpt('profile'));
 }
Example #7
0
 public function testSlug()
 {
     is('a-simple-title', Slug::filter(' A simple     title '));
     is('this-post-it-has-a-dash', Slug::filter('This post -- it has a dash'));
     is('123-1251251', Slug::filter('123----1251251'));
     is('one23-1251251', Slug::filter('123----1251251', '-', true));
     is('a-simple-title', Slug::filter('A simple title', '-'));
     is('this-post-it-has-a-dash', Slug::filter('This post -- it has a dash', '-'));
     is('123-1251251', Slug::filter('123----1251251', '-'));
     is('one23-1251251', Slug::filter('123----1251251', '-', true));
     is('a_simple_title', Slug::filter('A simple title', '_'));
     is('this_post_it_has_a_dash', Slug::filter('This post -- it has a dash', '_'));
     is('123_1251251', Slug::filter('123----1251251', '_'));
     is('one23_1251251', Slug::filter('123----1251251', '_', true));
     // Blank seperator tests
     is('asimpletitle', Slug::filter('A simple title', ''));
     is('thispostithasadash', Slug::filter('This post -- it has a dash', ''));
     is('1231251251', Slug::filter('123----1251251', ''));
     is('one231251251', Slug::filter('123----1251251', '', true));
 }