Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Cache.php « Command « lib - github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dc5ee061a08e315dc4d8c187d8dd672378f5c3d0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php

namespace OCA\Carnet\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\Files\NotFoundException;
use OCA\Carnet\Misc\CacheManager;
use OCP\IDBConnection;

class Cache extends Command {


        /**
         * @param string $appName
         * @param IRootFolder $rootFolder
    */
    public function __construct($AppName, $RootFolder,  $Config,  IDBConnection $IDBConnection, $UserManager){
        parent::__construct();
        $this->appName = $AppName;
        $this->Config = $Config;
        $this->rootFolder = $RootFolder;
        $this->db = $IDBConnection;
        $this->userManager = $UserManager;
        
    }
    /**
    * @param InputInterface $input
    * @param OutputInterface $output
    * @return int
    */
    protected function execute(InputInterface $input, OutputInterface $output) {
        $this->output = $output;
        $this->action = $input->getArgument('action');
        if($this->action === "rebuild"){
            $users = $this->userManager->search("",20000, 0);
            $arrayId = array();
            echo count($users);
            foreach($users as $user){
                array_push($arrayId,$user->getUID());
            }
            $cache = new CacheManager($this->db, null);
            $cache->buildCache($this->Config, $this->appName, $this->rootFolder, $arrayId);
        }
    }
    protected function configure() {
        $this->setName('carnet:cache')
        ->setDescription('Cache')
        ->addArgument(
                'action',
                InputArgument::REQUIRED,
                'Action: rebuild, clear'
        ); 
    }
}

?>