Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Nov 8, 2017
1 parent 653ab36 commit 47b4292
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ CHANGELOG
* Full transition to the use of the component hiqdev/composer-config-plugin
* Loss of compatibility with older components

4.0.3.2.pre
4.0.4
---------------
* Used https://github.com/skeeks-semenov/yii2-ya-slug.
* Removed slug behavior https://github.com/skeeks-semenov/yii2-slug-behavior.
* The ability to filter content properties by type

4.0.3.1
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"paulzi/yii2-adjacency-list": "^2.0",
"paulzi/yii2-materialized-path": "^2.0",
"skeeks/yii2-slug-behavior": "^1",
"skeeks/yii2-ya-slug": "^1",
"hiqdev/composer-config-plugin": "^0.2",
"bower-asset/fancybox": "^3.1",
"bower-asset/jquery": "2.2.*@stable | 2.1.*@stable | 1.11.*@stable | 1.12.*@stable"
Expand Down
11 changes: 3 additions & 8 deletions src/models/CmsContentElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use skeeks\cms\relatedProperties\models\RelatedPropertyModel;
use skeeks\yii2\ajaxfileupload\validators\FileValidator;
use skeeks\yii2\slug\SlugBehavior;
use skeeks\yii2\yaslug\YaSlugBehavior;
use Yii;
use yii\db\ActiveQuery;
use yii\helpers\ArrayHelper;
Expand Down Expand Up @@ -177,18 +178,12 @@ public function behaviors()
'class' => HasTrees::className(),
],

SlugBehavior::className() =>
YaSlugBehavior::class =>
[
'class' => SlugBehavior::class,
'class' => YaSlugBehavior::class,
'attribute' => 'name',
'slugAttribute' => 'code',
'maxLength' => \Yii::$app->cms->element_max_code_length,
'slugifyOptions' => [
'rulesets' => [
skeeks\yii2\slug\SlugRuleProvider::YANDEX,
'default'
]
]
]
]);
}
Expand Down
8 changes: 3 additions & 5 deletions src/models/Tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
use skeeks\cms\models\behaviors\traits\TreeBehaviorTrait;
use skeeks\cms\models\behaviors\TreeBehavior;
use skeeks\yii2\slug\SlugRuleProvider;
use skeeks\yii2\yaslug\YaSlugHelper;
use Yii;
use yii\base\Event;
use yii\base\Exception;
Expand Down Expand Up @@ -658,10 +659,7 @@ protected function _generateCode()
return $this;
}

$slugify = new Slugify(['rulesets' => [
SlugRuleProvider::YANDEX, 'default'
]], new SlugRuleProvider());
$this->code = $slugify->slugify($this->name);
$this->code = YaSlugHelper::slugify($this->name);

if (strlen($this->code) < 2) {
$this->code = $this->code . "-" . md5(microtime());
Expand All @@ -680,7 +678,7 @@ protected function _generateCode()

if (!$this->_isValidCode())
{
$this->code = $slugify->slugify($this->code . "-" . substr(md5(uniqid() . time()), 0, 4));
$this->code = YaSlugHelper::slugify($this->code . "-" . substr(md5(uniqid() . time()), 0, 4));

if (!$this->_isValidCode())
{
Expand Down

0 comments on commit 47b4292

Please sign in to comment.