Book Image

FuelPHP Application Development Blueprints

By : Sebastien Drouyer
Book Image

FuelPHP Application Development Blueprints

By: Sebastien Drouyer

Overview of this book

Table of Contents (13 chapters)
FuelPHP Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Clearing rejected comments


If your blog gets spammed and you find yourself with a lot of comments with status set as not_published, you might want to remove all these comments to clean your comments database. We could simply implement a link and an action but, for the sake of the example, let's implement a task for doing that.

Tasks are classes that can be executed through the command line using the oil utility. They are generally used for background processes or cron jobs. Sometimes, they can also be used for generating or modifying existing code, like the task we previously used for moving scaffolds to modules.

Let's generate our task file using the oil utility:

php oil generate task clearComments

It should output:

No tasks actions have been provided, the TASK will only create default task.
    Preparing task method [Index]
Creating tasks: APPPATH/tasks/clearcomments.php

If you now open the task file located at APPPATH/tasks/clearcomments.php, you should see the following class:

<?php...