summaryrefslogtreecommitdiffstats
path: root/source/Command/VerifyInstallation/LocalFiles.php
blob: dafd44aa9d2aad7c9c86bb6de0f37137b93c4a61 (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
63
64
65
66
67
68
69
70
<?php
/**
 * @author stev leibelt <artodeto@bazzline.net>
 * @since 2014-08-21 
 */

/**
 * Class Command_VerifyInstallation_LocalFiles
 */
class Command_VerifyInstallation_LocalFiles extends Command_VerifyInstallation_AbstractCommand
{
    /**
     * @throws Exception
     */
    public function execute()
    {
        $pathToLibDirectory = $this->pathConfiguration->getChatPath() . DIRECTORY_SEPARATOR . 'lib';

        if (!$this->filesystem->isDirectory($pathToLibDirectory)) {
            throw new Exception(
                'directory "lib" is missing, installation needed'
            );
        }

        $pathToDataDirectory = $pathToLibDirectory . DIRECTORY_SEPARATOR . 'data';

        if (!$this->filesystem->isDirectory($pathToDataDirectory)) {
            throw new Exception(
                'directory "data" is missing, installation needed'
            );
        }

        $identifierToPublicPath = array(
            'channels' => $this->pathConfiguration->getChatChannelsFilePath(),
            'pathConfiguration'  => $this->pathConfiguration->getChatConfigurationFilePath(),
            'users' => $this->pathConfiguration->getChatUsersFilePath(),
            'version' => $this->pathConfiguration->getChatVersionFilePath()
        );

        foreach ($identifierToPublicPath as $identifier => $path) {
            if (!$this->filesystem->isFile($path)) {
                throw new Exception(
                    'file "' . $identifier . '" is missing, installation needed'
                );
            }
        }

        $pathToInstallPhp = $this->pathConfiguration->getChatPath() . DIRECTORY_SEPARATOR . 'install.php';

        if ($this->filesystem->isFile($pathToInstallPhp)) {
            throw new Exception(
                'file "' . $pathToInstallPhp . '" still available'
            );
        }
    }

    /**
     * @return array
     */
    public function getUsage()
    {
    }

    /**
     * @throws Exception
     */
    public function verify()
    {
    }
}