Completed
Push — cleanup-service ( 73e309...ffbb72 )
by Romain
02:47
created

injectEnvironmentService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/*
3
 * 2017 Romain CANON <[email protected]>
4
 *
5
 * This file is part of the TYPO3 Formz project.
6
 * It is free software; you can redistribute it and/or modify it
7
 * under the terms of the GNU General Public License, either
8
 * version 3 of the License, or any later version.
9
 *
10
 * For the full copyright and license information, see:
11
 * http://www.gnu.org/licenses/gpl-3.0.html
12
 */
13
14
namespace Romm\Formz\AssetHandler\Connector;
15
16
use Romm\Formz\AssetHandler\AbstractAssetHandler;
17
use Romm\Formz\AssetHandler\JavaScript\FieldsActivationJavaScriptAssetHandler;
18
use Romm\Formz\AssetHandler\JavaScript\FieldsValidationActivationJavaScriptAssetHandler;
19
use Romm\Formz\AssetHandler\JavaScript\FieldsValidationJavaScriptAssetHandler;
20
use Romm\Formz\AssetHandler\JavaScript\FormInitializationJavaScriptAssetHandler;
21
use Romm\Formz\AssetHandler\JavaScript\FormRequestDataJavaScriptAssetHandler;
22
use Romm\Formz\AssetHandler\JavaScript\FormzConfigurationJavaScriptAssetHandler;
23
use Romm\Formz\AssetHandler\JavaScript\FormzLocalizationJavaScriptAssetHandler;
24
use Romm\Formz\Condition\Processor\ConditionProcessor;
25
use Romm\Formz\Condition\Processor\ConditionProcessorFactory;
26
use Romm\Formz\Core\Core;
27
use Romm\Formz\Form\FormObject;
28
use TYPO3\CMS\Extbase\Mvc\Web\Routing\UriBuilder;
29
use TYPO3\CMS\Extbase\Service\EnvironmentService;
30
31
class JavaScriptAssetHandlerConnector
32
{
33
    /**
34
     * List of JavaScript files which will be included whenever this view helper
35
     * is used.
36
     *
37
     * @var array
38
     */
39
    private $javaScriptFiles = [
40
        'Formz.Main.js',
41
        'Formz.Misc.js',
42
        'Formz.EventsManager.js',
43
        'Formz.Result.js',
44
        'Formz.Localization.js',
45
        'Form/Formz.Form.js',
46
        'Form/Formz.Form.SubmissionService.js',
47
        'Field/Formz.Field.js',
48
        'Field/Formz.Field.DataAttributesService.js',
49
        'Field/Formz.Field.ValidationService.js',
50
        'Conditions/Formz.Condition.js',
51
        'Validators/Formz.Validation.js',
52
        'Validators/Formz.Validator.Ajax.js'
53
    ];
54
55
    /**
56
     * @var AssetHandlerConnectorManager
57
     */
58
    private $assetHandlerConnectorManager;
59
60
    /**
61
     * @var EnvironmentService
62
     */
63
    protected $environmentService;
64
    /**
65
     * @param AssetHandlerConnectorManager $assetHandlerConnectorManager
66
     */
67
    public function __construct(AssetHandlerConnectorManager $assetHandlerConnectorManager)
68
    {
69
        $this->assetHandlerConnectorManager = $assetHandlerConnectorManager;
70
    }
71
72
    /**
73
     * Will include all default JavaScript files declared in the property
74
     * `$javaScriptFiles` of this class, as well as the main Formz
75
     * configuration.
76
     *
77
     * @return $this
78
     */
79
    public function includeDefaultJavaScriptFiles()
80
    {
81
        if (Core::get()->isInDebugMode()) {
82
            $this->javaScriptFiles[] = 'Formz.Debug.js';
83
        }
84
85
        foreach ($this->javaScriptFiles as $file) {
86
            $filePath = Core::get()->getExtensionRelativePath('Resources/Public/JavaScript/' . $file);
87
88
            $this->includeJsFile($filePath);
89
        }
90
91
        return $this;
92
    }
93
94
    /**
95
     * This function will handle the JavaScript language files.
96
     *
97
     * A file will be created for the current language (there can be as many
98
     * files as languages), containing the translations handling for JavaScript.
99
     * If the file already exists, it is directly included.
100
     *
101
     * @return $this
102
     */
103
    public function includeLanguageJavaScriptFiles()
104
    {
105
        $filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath('local-' . Core::get()->getLanguageKey()) . '.js';
106
107
        $this->assetHandlerConnectorManager->createFileInTemporaryDirectory(
108
            $filePath,
109
            function () {
110
                return $this->getFormzLocalizationJavaScriptAssetHandler()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Romm\Formz\AssetHandler\AbstractAssetHandler as the method injectTranslationsForFormFieldsValidation() does only exist in the following sub-classes of Romm\Formz\AssetHandler\AbstractAssetHandler: Romm\Formz\AssetHandler\...nJavaScriptAssetHandler. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
111
                    ->injectTranslationsForFormFieldsValidation()
112
                    ->getJavaScriptCode();
113
            }
114
        );
115
116
        $this->includeJsFile(Core::get()->getResourceRelativePath($filePath));
117
118
        return $this;
119
    }
120
121
    /**
122
     * Includes Formz configuration JavaScript declaration. If the file exists,
123
     * it is directly included, otherwise the JavaScript code is calculated,
124
     * then put in the cache file.
125
     *
126
     * @return $this
127
     */
128
    public function generateAndIncludeFormzConfigurationJavaScript()
129
    {
130
        $formzConfigurationJavaScriptAssetHandler = $this->getFormzConfigurationJavaScriptAssetHandler();
131
        $fileName = $formzConfigurationJavaScriptAssetHandler->getJavaScriptFileName();
132
133
        $this->assetHandlerConnectorManager->createFileInTemporaryDirectory(
134
            $fileName,
135
            function () use ($formzConfigurationJavaScriptAssetHandler) {
136
                return $formzConfigurationJavaScriptAssetHandler->getJavaScriptCode();
137
            }
138
        );
139
140
        $this->includeJsFile(Core::get()->getResourceRelativePath($fileName));
141
142
        return $this;
143
    }
144
145
    /**
146
     * Will include the generated JavaScript, from multiple asset handlers
147
     * sources.
148
     *
149
     * @return $this
150
     */
151
    public function generateAndIncludeJavaScript()
152
    {
153
        $filePath = $this->assetHandlerConnectorManager->getFormzGeneratedFilePath() . '.js';
154
155
        $this->assetHandlerConnectorManager->createFileInTemporaryDirectory(
156
            $filePath,
157
            function () {
158
                return
159
                    // Form initialization code.
160
                    $this->getFormInitializationJavaScriptAssetHandler()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Romm\Formz\AssetHandler\AbstractAssetHandler as the method getFormInitializationJavaScriptCode() does only exist in the following sub-classes of Romm\Formz\AssetHandler\AbstractAssetHandler: Romm\Formz\AssetHandler\...nJavaScriptAssetHandler. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
161
                        ->getFormInitializationJavaScriptCode() .
162
                    LF .
163
                    // Fields validation code.
164
                    $this->getFieldsValidationJavaScriptAssetHandler()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Romm\Formz\AssetHandler\AbstractAssetHandler as the method getJavaScriptCode() does only exist in the following sub-classes of Romm\Formz\AssetHandler\AbstractAssetHandler: Romm\Formz\AssetHandler\...nJavaScriptAssetHandler, Romm\Formz\AssetHandler\...nJavaScriptAssetHandler, Romm\Formz\AssetHandler\...nJavaScriptAssetHandler. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
165
                        ->getJavaScriptCode() .
166
                    LF .
167
                    // Fields activation conditions code.
168
                    $this->getFieldsActivationJavaScriptAssetHandler()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Romm\Formz\AssetHandler\AbstractAssetHandler as the method getFieldsActivationJavaScriptCode() does only exist in the following sub-classes of Romm\Formz\AssetHandler\AbstractAssetHandler: Romm\Formz\AssetHandler\...nJavaScriptAssetHandler. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
169
                        ->getFieldsActivationJavaScriptCode() .
170
                    LF .
171
                    // Fields validation activation conditions code.
172
                    $this->getFieldsValidationActivationJavaScriptAssetHandler()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Romm\Formz\AssetHandler\AbstractAssetHandler as the method getFieldsValidationActivationJavaScriptCode() does only exist in the following sub-classes of Romm\Formz\AssetHandler\AbstractAssetHandler: Romm\Formz\AssetHandler\...nJavaScriptAssetHandler. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
173
                        ->getFieldsValidationActivationJavaScriptCode();
174
            }
175
        );
176
177
        $this->includeJsFile(Core::get()->getResourceRelativePath($filePath));
178
179
        return $this;
180
    }
181
182
    /**
183
     * Here we generate the JavaScript code containing the submitted values, and
184
     * the existing errors, which is dynamically created at each request.
185
     *
186
     * The code is then injected as inline code in the DOM.
187
     *
188
     * @return $this
189
     */
190
    public function generateAndIncludeInlineJavaScript()
191
    {
192
        $formName = $this->assetHandlerConnectorManager
193
            ->getAssetHandlerFactory()
194
            ->getFormObject()
195
            ->getName();
196
197
        $javaScriptCode = $this->getFormRequestDataJavaScriptAssetHandler()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Romm\Formz\AssetHandler\AbstractAssetHandler as the method getFormRequestDataJavaScriptCode() does only exist in the following sub-classes of Romm\Formz\AssetHandler\AbstractAssetHandler: Romm\Formz\AssetHandler\...aJavaScriptAssetHandler. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
198
            ->getFormRequestDataJavaScriptCode();
199
200
        if (Core::get()->isInDebugMode()) {
201
            $javaScriptCode .= LF . $this->getDebugActivationCode();
202
        }
203
204
        $uri = $this->getAjaxUrl();
205
206
        $javaScriptCode .= LF;
207
        $javaScriptCode .= "Formz.setAjaxUrl('$uri');";
208
209
        $this->addInlineJs('Formz - Initialization ' . $formName, $javaScriptCode);
210
211
        return $this;
212
    }
213
214
    /**
215
     * Will include all new JavaScript files given, by checking that every given
216
     * file was not already included.
217
     *
218
     * @return $this
219
     */
220
    public function includeJavaScriptValidationAndConditionFiles()
221
    {
222
        $javaScriptValidationFiles = $this->getJavaScriptFiles();
223
        $assetHandlerConnectorStates = $this->assetHandlerConnectorManager
224
            ->getAssetHandlerConnectorStates();
225
226
        foreach ($javaScriptValidationFiles as $file) {
227
            if (false === in_array($file, $assetHandlerConnectorStates->getAlreadyIncludedValidationJavaScriptFiles())) {
228
                $assetHandlerConnectorStates->registerIncludedValidationJavaScriptFiles($file);
229
                $this->includeJsFile(Core::get()->getResourceRelativePath($file));
230
            }
231
        }
232
233
        return $this;
234
    }
235
236
    /**
237
     * Returns the list of JavaScript files which are used for the current form
238
     * object.
239
     *
240
     * @return array
241
     */
242
    protected function getJavaScriptFiles()
243
    {
244
        $formObject = $this->assetHandlerConnectorManager
245
            ->getAssetHandlerFactory()
246
            ->getFormObject();
247
248
        $javaScriptFiles = $this->getFieldsValidationJavaScriptAssetHandler()
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Romm\Formz\AssetHandler\AbstractAssetHandler as the method getJavaScriptValidationFiles() does only exist in the following sub-classes of Romm\Formz\AssetHandler\AbstractAssetHandler: Romm\Formz\AssetHandler\...nJavaScriptAssetHandler. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
249
            ->getJavaScriptValidationFiles();
250
251
        $conditionProcessor = $this->getConditionProcessor($formObject);
252
253
        $javaScriptFiles = array_merge($javaScriptFiles, $conditionProcessor->getJavaScriptFiles());
254
255
        return $javaScriptFiles;
256
    }
257
258
    /**
259
     * We need an abstraction function because the footer inclusion for assets
260
     * does not work in backend. It means we include every JavaScript asset in
261
     * the header when the request is in a backend context.
262
     *
263
     * @see https://forge.typo3.org/issues/60213
264
     *
265
     * @param string $path
266
     */
267
    protected function includeJsFile($path)
268
    {
269
        $pageRenderer = $this->assetHandlerConnectorManager->getPageRenderer();
270
271
        if ($this->environmentService->isEnvironmentInFrontendMode()) {
272
            $pageRenderer->addJsFooterFile($path);
273
        } else {
274
            $pageRenderer->addJsFile($path);
275
        }
276
    }
277
278
    /**
279
     * @see includeJsFile()
280
     *
281
     * @param string $name
282
     * @param string $javaScriptCode
283
     */
284
    protected function addInlineJs($name, $javaScriptCode)
285
    {
286
        $pageRenderer = $this->assetHandlerConnectorManager->getPageRenderer();
287
288
        if ($this->environmentService->isEnvironmentInFrontendMode()) {
289
            $pageRenderer->addJsFooterInlineCode($name, $javaScriptCode);
290
        } else {
291
            $pageRenderer->addJsInlineCode($name, $javaScriptCode);
292
        }
293
    }
294
295
    /**
296
     * @return string
297
     */
298
    protected function getAjaxUrl()
299
    {
300
        /** @var UriBuilder $uriBuilder */
301
        $uriBuilder = Core::instantiate(UriBuilder::class);
302
303
        return $uriBuilder->reset()
304
            ->setTargetPageType(1473682545)
305
            ->setNoCache(true)
306
            ->setUseCacheHash(false)
307
            ->setCreateAbsoluteUri(true)
308
            ->build();
309
    }
310
311
    /**
312
     * @return string
313
     */
314
    protected function getDebugActivationCode()
315
    {
316
        return 'Formz.Debug.activate();';
317
    }
318
319
    /**
320
     * @param FormObject $formObject
321
     * @return ConditionProcessor
322
     */
323
    protected function getConditionProcessor(FormObject $formObject)
324
    {
325
        return ConditionProcessorFactory::getInstance()
326
            ->get($formObject);
327
    }
328
329
    /**
330
     * @return FormzConfigurationJavaScriptAssetHandler|AbstractAssetHandler
331
     */
332
    protected function getFormzConfigurationJavaScriptAssetHandler()
333
    {
334
        return $this->assetHandlerConnectorManager
335
            ->getAssetHandlerFactory()
336
            ->getAssetHandler(FormzConfigurationJavaScriptAssetHandler::class);
337
    }
338
339
    /**
340
     * @return FormInitializationJavaScriptAssetHandler|AbstractAssetHandler
341
     */
342
    protected function getFormInitializationJavaScriptAssetHandler()
343
    {
344
        return $this->assetHandlerConnectorManager
345
            ->getAssetHandlerFactory()
346
            ->getAssetHandler(FormInitializationJavaScriptAssetHandler::class);
347
    }
348
349
    /**
350
     * @return FieldsValidationJavaScriptAssetHandler|AbstractAssetHandler
351
     */
352
    protected function getFieldsValidationJavaScriptAssetHandler()
353
    {
354
        return $this->assetHandlerConnectorManager
355
            ->getAssetHandlerFactory()
356
            ->getAssetHandler(FieldsValidationJavaScriptAssetHandler::class);
357
    }
358
359
    /**
360
     * @return FieldsActivationJavaScriptAssetHandler|AbstractAssetHandler
361
     */
362
    protected function getFieldsActivationJavaScriptAssetHandler()
363
    {
364
        return $this->assetHandlerConnectorManager
365
            ->getAssetHandlerFactory()
366
            ->getAssetHandler(FieldsActivationJavaScriptAssetHandler::class);
367
    }
368
369
    /**
370
     * @return FieldsValidationActivationJavaScriptAssetHandler|AbstractAssetHandler
371
     */
372
    protected function getFieldsValidationActivationJavaScriptAssetHandler()
373
    {
374
        return $this->assetHandlerConnectorManager
375
            ->getAssetHandlerFactory()
376
            ->getAssetHandler(FieldsValidationActivationJavaScriptAssetHandler::class);
377
    }
378
379
    /**
380
     * @return FormRequestDataJavaScriptAssetHandler|AbstractAssetHandler
381
     */
382
    protected function getFormRequestDataJavaScriptAssetHandler()
383
    {
384
        return $this->assetHandlerConnectorManager
385
            ->getAssetHandlerFactory()
386
            ->getAssetHandler(FormRequestDataJavaScriptAssetHandler::class);
387
    }
388
389
    /**
390
     * @return FormzLocalizationJavaScriptAssetHandler|AbstractAssetHandler
391
     */
392
    protected function getFormzLocalizationJavaScriptAssetHandler()
393
    {
394
        return $this->assetHandlerConnectorManager
395
            ->getAssetHandlerFactory()
396
            ->getAssetHandler(FormzLocalizationJavaScriptAssetHandler::class);
397
    }
398
399
    /**
400
     * @param EnvironmentService $environmentService
401
     */
402
    public function injectEnvironmentService(EnvironmentService $environmentService)
403
    {
404
        $this->environmentService = $environmentService;
405
    }
406
}
407