Platformsh\Cli\Local\LocalBuild::cleanArchives PHP Method

cleanArchives() public method

Remove old build archives.
public cleanArchives ( string $projectRoot, integer $maxAge = null, integer $keepMax = 10, boolean $quiet = true ) : int[]
$projectRoot string
$maxAge integer
$keepMax integer
$quiet boolean
return int[] The numbers of deleted and kept builds.
    public function cleanArchives($projectRoot, $maxAge = null, $keepMax = 10, $quiet = true)
    {
        return $this->cleanDirectory($projectRoot . '/' . $this->config->get('local.archive_dir'), $maxAge, $keepMax, [], $quiet);
    }

Usage Example

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $projectRoot = $this->getProjectRoot();
     if (!$projectRoot) {
         throw new RootNotFoundException();
     }
     $builder = new LocalBuild(array(), $this->stdErr);
     $result = $builder->cleanBuilds($projectRoot, $input->getOption('max-age'), $input->getOption('keep'), $input->getOption('include-active'), false);
     if (!$result[0] && !$result[1]) {
         $this->stdErr->writeln("There are no builds to delete");
     } else {
         if ($result[0]) {
             $this->stdErr->writeln("Deleted <info>{$result[0]}</info> build(s)");
         }
         if ($result[1]) {
             $this->stdErr->writeln("Kept <info>{$result[1]}</info> build(s)");
         }
     }
     $archivesResult = $builder->cleanArchives($projectRoot);
     if ($archivesResult[0]) {
         $this->stdErr->writeln("Deleted <info>{$archivesResult[0]}</info> archive(s)");
     }
 }
All Usage Examples Of Platformsh\Cli\Local\LocalBuild::cleanArchives