Пример #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'));
 }
Пример #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;
 }
Пример #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);
 }
Пример #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;
 }
Пример #5
0
 /**
  * @return string
  */
 protected function _getProfFileName()
 {
     return Slug::filter($this->_getFileName() . '-' . $this->_getOpt('profile'));
 }
Пример #6
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));
 }