mardi 23 février 2016

How to run a method of a class as a cron task in laravel 5.1

Look I have a class that looks like this, i want to cache some info every day in a cron job with this method cacheTopFilters in laravel 5.1

   <?php
namespace namescape/of/the/class;

class FilterTypeCacheService extends BaseService implements IFilterTypeCacheService
{

private $searchFilterService;
private $filterCacheHandler;

function __construct(SearchFilterService $searchFilterService, IFilterTypeCacheHandler $filterCacheHandler){
    $this->searchFilterService = $searchFilterService;
    $this->filterCacheHandler = $filterCacheHandler;
}

public function cacheTopFilters($type,$keyValuePair,$limit){
    $filters = $this->searchFilterService->getAllFilters($type,$keyValuePair);
    $this->filterCacheHandler->deleteFiltersBulkFromCache();
    $this->filterCacheHandler->SaveFiltersBulk($filters,$type);
}

public function getTopFilters(){
    $topFilters = $this->filterCacheHandler->getCachedTopFilters();
    return $topFilters;
}
}

As they have dependency injection how can i accomplished to called that method on the app/console/kernel on the schedule method?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire