@@ -9,26 +9,26 @@ |
||
| 9 | 9 | |
| 10 | 10 | class CleanupGeneratedPdfDailyTaskTest extends SapphireTest |
| 11 | 11 | { |
| 12 | - /** |
|
| 13 | - * @var CleanupGeneratedPdfDailyTask |
|
| 14 | - */ |
|
| 15 | - protected $task; |
|
| 12 | + /** |
|
| 13 | + * @var CleanupGeneratedPdfDailyTask |
|
| 14 | + */ |
|
| 15 | + protected $task; |
|
| 16 | 16 | |
| 17 | - protected function setUp() |
|
| 18 | - { |
|
| 19 | - parent::setUp(); |
|
| 17 | + protected function setUp() |
|
| 18 | + { |
|
| 19 | + parent::setUp(); |
|
| 20 | 20 | |
| 21 | - if (!interface_exists(CronTask::class)) { |
|
| 22 | - $this->markTestSkipped('Test class requires the silverstripe/crontask module to be installed'); |
|
| 23 | - } |
|
| 21 | + if (!interface_exists(CronTask::class)) { |
|
| 22 | + $this->markTestSkipped('Test class requires the silverstripe/crontask module to be installed'); |
|
| 23 | + } |
|
| 24 | 24 | |
| 25 | - $this->task = new CleanupGeneratedPdfDailyTask(); |
|
| 26 | - } |
|
| 25 | + $this->task = new CleanupGeneratedPdfDailyTask(); |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function testCronScheduleIsConfigurable() |
|
| 29 | - { |
|
| 30 | - Config::modify()->set(CleanupGeneratedPdfDailyTask::class, 'schedule', '* 1 2 3 *'); |
|
| 28 | + public function testCronScheduleIsConfigurable() |
|
| 29 | + { |
|
| 30 | + Config::modify()->set(CleanupGeneratedPdfDailyTask::class, 'schedule', '* 1 2 3 *'); |
|
| 31 | 31 | |
| 32 | - $this->assertSame('* 1 2 3 *', $this->task->getSchedule()); |
|
| 33 | - } |
|
| 32 | + $this->assertSame('* 1 2 3 *', $this->task->getSchedule()); |
|
| 33 | + } |
|
| 34 | 34 | } |
@@ -7,7 +7,7 @@ discard block |
||
| 7 | 7 | use SilverStripe\CronTask\Interfaces\CronTask; |
| 8 | 8 | |
| 9 | 9 | if (!interface_exists(CronTask::class)) { |
| 10 | - return; |
|
| 10 | + return; |
|
| 11 | 11 | } |
| 12 | 12 | |
| 13 | 13 | /** |
@@ -15,36 +15,36 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | class CleanupGeneratedPdfDailyTask implements CronTask |
| 17 | 17 | { |
| 18 | - use Configurable; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * The cron schedule for this task (default: midnight every day) |
|
| 22 | - * |
|
| 23 | - * @config |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - private static $schedule = '0 0 * * *'; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Whether this task is enabled (default false) |
|
| 30 | - * |
|
| 31 | - * @config |
|
| 32 | - * @return bool |
|
| 33 | - */ |
|
| 34 | - private static $enabled = false; |
|
| 35 | - |
|
| 36 | - public function getSchedule() |
|
| 37 | - { |
|
| 38 | - return $this->config()->get('schedule'); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function process() |
|
| 42 | - { |
|
| 43 | - if (!$this->config()->get('enabled')) { |
|
| 44 | - return; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - $task = Injector::inst()->create(CleanupGeneratedPdfBuildTask::class); |
|
| 48 | - $task->run(null); |
|
| 49 | - } |
|
| 18 | + use Configurable; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * The cron schedule for this task (default: midnight every day) |
|
| 22 | + * |
|
| 23 | + * @config |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + private static $schedule = '0 0 * * *'; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Whether this task is enabled (default false) |
|
| 30 | + * |
|
| 31 | + * @config |
|
| 32 | + * @return bool |
|
| 33 | + */ |
|
| 34 | + private static $enabled = false; |
|
| 35 | + |
|
| 36 | + public function getSchedule() |
|
| 37 | + { |
|
| 38 | + return $this->config()->get('schedule'); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function process() |
|
| 42 | + { |
|
| 43 | + if (!$this->config()->get('enabled')) { |
|
| 44 | + return; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + $task = Injector::inst()->create(CleanupGeneratedPdfBuildTask::class); |
|
| 48 | + $task->run(null); |
|
| 49 | + } |
|
| 50 | 50 | } |
@@ -7,24 +7,24 @@ |
||
| 7 | 7 | |
| 8 | 8 | class CleanupGeneratedPdfBuildTask extends BuildTask |
| 9 | 9 | { |
| 10 | - protected $title = 'Cleanup generated PDFs'; |
|
| 10 | + protected $title = 'Cleanup generated PDFs'; |
|
| 11 | 11 | |
| 12 | - protected $description = 'Removes generated PDFs on the site, forcing a regeneration of all exports to PDF ' |
|
| 13 | - . 'when users go to download them. This is most useful when templates have been changed so users should ' |
|
| 14 | - . 'receive a new copy'; |
|
| 12 | + protected $description = 'Removes generated PDFs on the site, forcing a regeneration of all exports to PDF ' |
|
| 13 | + . 'when users go to download them. This is most useful when templates have been changed so users should ' |
|
| 14 | + . 'receive a new copy'; |
|
| 15 | 15 | |
| 16 | - public function run($request) |
|
| 17 | - { |
|
| 18 | - $path = sprintf('%s/%s', BASE_PATH, BasePage::config()->get('generated_pdf_path')); |
|
| 19 | - if (!file_exists($path)) { |
|
| 20 | - return false; |
|
| 21 | - } |
|
| 16 | + public function run($request) |
|
| 17 | + { |
|
| 18 | + $path = sprintf('%s/%s', BASE_PATH, BasePage::config()->get('generated_pdf_path')); |
|
| 19 | + if (!file_exists($path)) { |
|
| 20 | + return false; |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | - exec(sprintf('if [ "$(ls -A %s 2> /dev/null)" != "" ]; then rm %s/*; fi', $path, $path), $output, $return_val); |
|
| 23 | + exec(sprintf('if [ "$(ls -A %s 2> /dev/null)" != "" ]; then rm %s/*; fi', $path, $path), $output, $return_val); |
|
| 24 | 24 | |
| 25 | - // output any errors |
|
| 26 | - if ($return_val != 0) { |
|
| 27 | - user_error(sprintf('%s failed: ', get_class($this)) . implode("\n", $output), E_USER_ERROR); |
|
| 28 | - } |
|
| 29 | - } |
|
| 25 | + // output any errors |
|
| 26 | + if ($return_val != 0) { |
|
| 27 | + user_error(sprintf('%s failed: ', get_class($this)) . implode("\n", $output), E_USER_ERROR); |
|
| 28 | + } |
|
| 29 | + } |
|
| 30 | 30 | } |
@@ -11,16 +11,16 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class CwpSearchPage extends Page |
| 13 | 13 | { |
| 14 | - private static $hide_ancestor = CwpSearchPage::class; |
|
| 14 | + private static $hide_ancestor = CwpSearchPage::class; |
|
| 15 | 15 | |
| 16 | - private static $table_name = 'CwpSearchPage'; |
|
| 16 | + private static $table_name = 'CwpSearchPage'; |
|
| 17 | 17 | |
| 18 | - public function canViewStage($stage = Versioned::LIVE, $member = null) |
|
| 19 | - { |
|
| 20 | - if (Permission::checkMember($member, 'VIEW_DRAFT_CONTENT')) { |
|
| 21 | - return true; |
|
| 22 | - } |
|
| 18 | + public function canViewStage($stage = Versioned::LIVE, $member = null) |
|
| 19 | + { |
|
| 20 | + if (Permission::checkMember($member, 'VIEW_DRAFT_CONTENT')) { |
|
| 21 | + return true; |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - return parent::canViewStage($stage, $member); |
|
| 25 | - } |
|
| 24 | + return parent::canViewStage($stage, $member); |
|
| 25 | + } |
|
| 26 | 26 | } |