本文整理汇总了PHP中Artisan::queue方法的典型用法代码示例。如果您正苦于以下问题:PHP Artisan::queue方法的具体用法?PHP Artisan::queue怎么用?PHP Artisan::queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Artisan
的用法示例。
在下文中一共展示了Artisan::queue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deploy
/**
* Application deploy.
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public function deploy(Request $request)
{
list($algo, $hash) = explode('=', $request->header('X-Hub-Signature'), 2);
if (!hash_equals($hash, hash_hmac($algo, $request->getContent(), config('services.github-webhook.secret')))) {
\Log::notice('Github Webhook', ['auth' => 'failed', 'ip' => $request->ip()]);
} else {
\Log::info('Github Webhook', ['auth' => 'success', 'ip' => $request->ip()]);
\Artisan::queue('deploy');
}
return response()->json('', 200);
}
示例2: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$source = $this->option('source');
// get all object ids from source
$source_object_uids = $this->harvester->getAllIDs($source);
// get all harvester object uids
$objects = \DB::table('objects')->lists('object_uid');
$harvester_object_uids = ['results' => $objects, 'total' => count($objects)];
$harvester_object_uids = (object) $harvester_object_uids;
// get harvester_object_uids not in the source_object_uids array
$harvester_delete = array_diff($harvester_object_uids->results, $source_object_uids->results);
// delete harvesterUIDs if not in sourceIDs
foreach ($harvester_delete as $object_uid) {
$object = Object::where('object_uid', '=', $object_uid)->first();
$object->delete();
Source::where('object_id', '=', $object->id)->delete();
Asset::where('object_id', '=', $object->id)->delete();
}
// get source_object_uids not in the harvester_object_uids array
$harvester_queue = array_diff($source_object_uids->results, $harvester_object_uids->results);
// queue sourceIDs if not in harvesterIDs
foreach ($harvester_queue as $object_uid) {
// Queue artisan command for data only
\Artisan::queue('harvest:object', ['--uid' => $object_uid, '--only' => 'data', '--source' => $source]);
// Queue command to process images
$command = new HarvestImages($object_uid);
$this->dispatch($command);
}
// compare sourece assets to harvester assets
foreach ($source_object_uids->results as $source_uid) {
// if source uid has not already been queued then compare assets
if (!in_array($source_uid, $harvester_queue)) {
// get source object
$source_object = $this->harvester->getObject($source_uid, $source);
// get source object assets
$source_asset_ids = [];
foreach ($source_object->images as $asset) {
$source_asset_ids[] = $asset->source_id;
}
// get harvester object
$harvester_object = Object::with(['source'])->where('object_uid', '=', $source_uid)->first();
// get harvester object
$harvester_asset_ids = [];
foreach ($harvester_object->source as $asset) {
$harvester_asset_ids[] = $asset->origin_id;
}
// get harvester_asset_ids not in the source_asset_ids array
$harvester_asset_delete = array_diff($harvester_asset_ids, $source_asset_ids);
// delete harvester source assets no longer found in the source
$harvester_delete_queue = false;
foreach ($harvester_asset_delete as $origin_id) {
// remove source reference from database
Source::where('object_id', '=', $harvester_object->id)->delete();
Asset::where('object_id', '=', $harvester_object->id)->delete();
$harvester_delete_queue = true;
}
// regenerate images associated with object
if ($harvester_delete_queue) {
// Queue artisan command for data only
\Artisan::queue('harvest:object', ['--uid' => $source_uid, '--only' => 'data', '--source' => $source]);
// Queue command to process images
$command = new HarvestImages($source_uid);
$this->dispatch($command);
}
// get source_asset_ids not in the harvester_object_ids array
$harvester_asset_queue = array_diff($source_asset_ids, $harvester_asset_ids);
if (!empty($harvester_asset_queue)) {
// Queue artisan command for data only
\Artisan::queue('harvest:object', ['--uid' => $source_uid, '--only' => 'data', '--source' => $source]);
// Queue command to process images
$command = new HarvestImages($source_uid);
$this->dispatch($command);
}
}
}
// Queue the export command
if ($this->option('export')) {
\Artisan::queue('harvest:export', ['--deleted' => true]);
\Artisan::queue('harvest:export', ['--modified' => true]);
}
}
示例3: handle
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$source = $this->option('source');
$only = $this->option('only');
$objects = \DB::table('objects')->pluck('object_uid');
$objects = ['results' => $objects, 'total' => count($objects)];
$objects = (object) $objects;
$deleted_uids = [];
if ($this->option('initial')) {
$this->info('Getting all object IDs for seeding.');
}
if ($this->option('refresh')) {
$this->info('Getting all object IDs for refresh.');
}
if ($this->option('update')) {
$this->info('Getting all updated object IDs.');
}
// create extended types maybe should of a harvester config
if ($this->option('initial')) {
$this->harvester->createTypes();
}
// get all object_uid from piction
if ($this->option('initial')) {
$response = $this->harvester->getAllIDs($source);
}
// set response to objects in harvester
if ($this->option('refresh')) {
$response = $this->harvester->getAllIDs($source);
// get object ids that are still part of piciton response
$intersectResponse = array_intersect($objects->results, $response->results);
// get items that have been deleted from source
$deleted_uids = array_diff($objects->results, $response->results);
// set response to intersectResponse
$response->results = $intersectResponse;
$response->total = count($intersectResponse);
}
if ($this->option('update')) {
// get updated ids from piciton
$response = $this->harvester->getUpdateIDs($source);
// get all ids from piction
$allResponse = $this->harvester->getAllIDs($source);
// get deleted ids not in the all response
$deleted_uids = array_diff($objects->results, $allResponse->results);
// get ids from all response not currently in harvester
$added_uids = array_diff($allResponse->results, $objects->results);
// get ids that are also not in the updated response
$diffAdded_uids = array_diff($added_uids, $response->results);
// merge response with diff added
$response->results = array_merge($response->results, $diffAdded_uids);
// set count of response
$response->total = count($response->results);
}
$objectIDs = $response->results;
if (count($objectIDs) > 0) {
// start progress display in console
$this->output->progressStart($response->total);
foreach ($objectIDs as $objectID) {
if ($only == 'null') {
// Queue artisan command for data only
\Artisan::queue('harvest:object', ['--uid' => $objectID, '--only' => 'data', '--source' => $source]);
// Queue command to process images
$command = new HarvestImages($objectID);
$this->dispatch($command);
}
if ($only == 'data') {
// Queue artisan command for data only
\Artisan::queue('harvest:object', ['--uid' => $objectID, '--only' => 'data', '--source' => $source]);
}
if ($only == 'images') {
// Queue command to process images
$command = new HarvestImages($objectID);
$this->dispatch($command);
}
// advance progress display in console
$this->output->progressAdvance();
}
// complete progress display in console
$this->output->progressFinish();
} else {
$this->info('No objects have been updated.');
}
if (!empty($deleted_uids)) {
foreach ($deleted_uids as $object_uid) {
$object = Object::where('object_uid', '=', $object_uid)->first();
$object->delete();
Source::where('object_id', '=', $object->id)->delete();
Asset::where('object_id', '=', $object->id)->delete();
}
}
// Queue the export command
if ($this->option('export')) {
\Artisan::queue('harvest:export', ['--modified' => true]);
\Artisan::queue('harvest:export', ['--deleted' => true]);
}
}