Answer the question
In order to leave comments, you need to log in
Yii2 SluggableBehavior not generating slug when creating object from queue?
Hello.
For many days I have been struggling with the problem of generating a slug (CNC) when generating an article in queues (
There is an array, I go through it and send each element to the UpdatePlaceJob task
foreach ($array as $object) {
$object = $object->data->general;
Yii::$app->queue->push(new UpdatePlaceJob([
'object' => $object,
]));
public $place;
public function execute($queue)
{
$object = $this->object;
$place = Place::findOne(['title' => $object->name]);
$place->status = Place::STATUS_UPDATED;
$place->text = $object->description;
$place->save();
public function behaviors()
{
return [
[
'class' => SluggableBehavior::class,
'attribute' => 'title',
'slugAttribute' => 'slug',
'ensureUnique' => true,
'immutable' => true,
],
Answer the question
In order to leave comments, you need to log in
This has nothing to do with the SluggableBehavior
itself . The difference is obvious - the first is launched through the Web Controller, and the second through the queue from the Console Controller . This means that some php configurations in the console and on the web are different.
SluggableBehavior
heavily dependent on the PHP extension php*-intl . Most likely, you do not have it in the console, and therefore it does not work properly. Try to install it for php which works with queues.
Well, if this does not help, look at the logs not only of Yii, but also of php.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question