PHP code example of honcho / craft-queue-bouncer
1. Go to this page and download the library: Download honcho/craft-queue-bouncer library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
honcho / craft-queue-bouncer example snippets
// config/queuebouncer.php
return [
'feed-me-import' => [
'skipClasses' => [
\craft\feedme\queue\jobs\FeedImport::class,
],
'callback' => function () {
$feed = FeedMe::getInstance()->getFeeds()->getFeedById(1);
if ($feed) {
Queue::push(new FeedImport(['feed' => $feed]));
}
},
],
];
'feed-me-import-17' => [
'skipIf' => function () {
// Only block if feed #17 is specifically already queued.
return (new \yii\db\Query())
->from(\craft\db\Table::QUEUE)
->where(['fail' => false])
->andWhere(['like', 'job', 'FeedImport'])
->andWhere(['like', 'job', '"id";i:17'])
->exists();
},
'callback' => function () {
$feed = FeedMe::getInstance()->getFeeds()->getFeedById(17);
if ($feed) {
Queue::push(new FeedImport(['feed' => $feed]));
}
},
],
'feed-me-import-42' => [
'skipIf' => function () {
return (new \yii\db\Query())
->from(\craft\db\Table::QUEUE)
->where(['fail' => false])
->andWhere(['like', 'job', 'FeedImport'])
->andWhere(['like', 'job', '"id";i:42'])
->exists();
},
'callback' => function () {
$feed = FeedMe::getInstance()->getFeeds()->getFeedById(42);
if ($feed) {
Queue::push(new FeedImport(['feed' => $feed]));
}
},
],
bash
# Before
php craft feed-me/feeds/queue 1
# After
php craft queue-bouncer/queue feed-me-import