• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

NIT-Administrative-Systems / dynamic-forms / 3874968769

pending completion
3874968769

push

github

GitHub
PHP 8.2 Support (#383)

1182 of 1279 relevant lines covered (92.42%)

62.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

79.31
/src/Console/Commands/Install.php
1
<?php
2

3
namespace Northwestern\SysDev\DynamicForms\Console\Commands;
4

5
use Illuminate\Console\Command;
6

7
class Install extends Command
8
{
9
    public const FORMIOJS_VERSION = '^4.12.7';
10

11
    protected $signature = 'dynamic-forms:install';
12

13
    protected $description = 'Installs Dynamic Forms for Laravel';
14

15
    /**
16
     * @codeCoverageIgnore
17
     */
18
    public function handle()
19
    {
20
        $this->comment('Publishing file upload controller...');
21
        $this->call('dynamic-forms:installStorageController');
22
        $this->newLine();
23

24
        $this->comment('Publishing resource controller...');
25
        $this->call('dynamic-forms:installResourceController');
26
        $this->newLine();
27

28
        $this->comment('Publishing JS assets...');
29
        $this->callSilent('vendor:publish', ['--tag' => 'dynamic-forms-js']);
30

31
        @mkdir(resource_path('sass'));
32

33
        $this->ejectJsInclude(resource_path('js/app.js'));
34
        $this->ejectCssInclude(resource_path('sass/app.scss'));
35
        $this->updatePackages(base_path('package.json'));
36
        $this->newLine();
37

38
        $this->comment('Publishing routes...');
39
        $this->ejectRoutes(base_path('routes/web.php'));
40
        $this->newLine();
41

42
        $this->info('Dynamic Forms for Laravel has been installed!');
43

44
        $this->newLine();
45
        $this->info('Please review the new controller and implement appropriate authorization rules.');
46
        $this->info('And remember to run `yarn install and Laravel Mix!');
47
    }
48

49
//    protected function getNameInput(): string
50
//    {
51
//        return 'DynamicFormsStorageController';
52
//    }
53
//
54
//    protected function getStub(): string
55
//    {
56
//        return __DIR__.'/../../../stubs/DynamicFormsStorageController.stub';
57
//    }
58
//
59
//    protected function getDefaultNamespace($rootNamespace): string
60
//    {
61
//        return $rootNamespace.'\Http\Controllers';
62
//    }
63

64
    protected function ejectRoutes(string $routesFile): void
65
    {
66
        file_put_contents(
1✔
67
            $routesFile,
1✔
68
            file_get_contents(__DIR__.'/../../../stubs/routes.stub'),
1✔
69
            FILE_APPEND
1✔
70
        );
1✔
71
    }
72

73
    protected function ejectJsInclude(string $appJsFile): void
74
    {
75
        file_put_contents(
1✔
76
            $appJsFile,
1✔
77
            "require('./formio');",
1✔
78
            FILE_APPEND
1✔
79
        );
1✔
80
    }
81

82
    protected function ejectEnv($env)
83
    {
84
        file_put_contents(
×
85
            base_path('.env'),
×
86
            $env,
×
87
            FILE_APPEND
×
88
        );
×
89
    }
90

91
    protected function ejectCssInclude(string $appCssFile): void
92
    {
93
        file_put_contents(
1✔
94
            $appCssFile,
1✔
95
            "@import '~formiojs/dist/formio.full';",
1✔
96
            FILE_APPEND
1✔
97
        );
1✔
98
    }
99

100
    protected function updatePackages(string $packageFile): void
101
    {
102
        if (! file_exists($packageFile)) {
1✔
103
            return;
×
104
        }
105

106
        $packages = json_decode(file_get_contents($packageFile), true);
1✔
107

108
        $packages['devDependencies']['formiojs'] = self::FORMIOJS_VERSION;
1✔
109

110
        ksort($packages['devDependencies']);
1✔
111

112
        file_put_contents(
1✔
113
            $packageFile,
1✔
114
            json_encode($packages, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT).PHP_EOL
1✔
115
        );
1✔
116
    }
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc