GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bf6f51...19227d )
by Robbie
56:02
created

AdvancedWorkflowAdmin::setWorkflowService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Symbiote\AdvancedWorkflow\Admin;
4
5
use SilverStripe\Admin\ModelAdmin;
6
use SilverStripe\CMS\Controllers\CMSPageEditController;
7
use SilverStripe\Control\HTTPRequest;
8
use SilverStripe\Control\HTTPResponse;
9
use SilverStripe\Forms\FieldList;
10
use SilverStripe\Forms\FormAction;
11
use SilverStripe\Forms\GridField\GridField;
12
use SilverStripe\Forms\GridField\GridFieldConfig_Base;
13
use SilverStripe\Forms\GridField\GridFieldDataColumns;
14
use SilverStripe\Forms\GridField\GridFieldDetailForm;
15
use SilverStripe\Forms\GridField\GridFieldEditButton;
16
use SilverStripe\Forms\GridField\GridFieldExportButton;
17
use SilverStripe\Forms\GridField\GridFieldImportButton;
18
use SilverStripe\Forms\GridField\GridFieldPaginator;
19
use SilverStripe\ORM\ArrayList;
20
use SilverStripe\ORM\DataObject;
21
use SilverStripe\Security\Member;
22
use SilverStripe\Security\Permission;
23
use SilverStripe\Security\Security;
24
use SilverStripe\View\Requirements;
25
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowDefinition;
26
use Symbiote\AdvancedWorkflow\Dev\WorkflowBulkLoader;
27
use Symbiote\AdvancedWorkflow\Forms\GridField\GridFieldExportAction;
28
use Symbiote\AdvancedWorkflow\Forms\GridField\GridFieldWorkflowRestrictedEditButton;
29
use Symbiote\AdvancedWorkflow\Services\WorkflowService;
30
31
/**
32
 * @package advancedworkflow
33
 * @todo UI/UX needs looking at for when current user has no pending and/or submitted items, (Current
34
 * implementation is bog-standard <p> text)
35
 */
36
class AdvancedWorkflowAdmin extends ModelAdmin
37
{
38
    private static $menu_title    = 'Workflows';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
39
    private static $menu_priority = -1;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
40
    private static $url_segment   = 'workflows';
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
41
    private static $menu_icon_class = 'font-icon-flow-tree';
42
43
    /**
44
     *
45
     * @var array Allowable actions on this controller.
46
     */
47
    private static $allowed_actions = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
48
        'export',
49
        'ImportForm'
50
    );
51
52
    private static $url_handlers = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
53
        '$ModelClass/export/$ID!' => 'export',
54
        '$ModelClass/$Action' => 'handleAction',
55
        '' => 'index'
56
    );
57
58
    private static $managed_models = WorkflowDefinition::class;
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
59
60
    private static $model_importers = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
61
        'WorkflowDefinition' => WorkflowBulkLoader::class
62
    );
63
64
    private static $dependencies = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
65
        'workflowService' => '%$' . WorkflowService::class,
66
    );
67
68
    private static $fileEditActions = 'getCMSActions';
69
70
    /**
71
     * Defaults are set in {@link getEditForm()}.
72
     *
73
     * @var array
74
     */
75
    private static $fieldOverrides = array();
76
77
    /**
78
     * @var WorkflowService
79
     */
80
    public $workflowService;
81
82
    /**
83
     * Initialise javascript translation files
84
     *
85
     * @return void
86
     */
87
    protected function init()
88
    {
89
        parent::init();
90
91
        Requirements::add_i18n_javascript('symbiote/silverstripe-advancedworkflow:client/lang');
92
        Requirements::javascript('symbiote/silverstripe-advancedworkflow:client/dist/js/advancedworkflow.js');
93
        Requirements::css('symbiote/silverstripe-advancedworkflow:client/dist/styles/advancedworkflow.css');
94
    }
95
96
    /*
97
     * Shows up to x2 GridFields for Pending and Submitted items, dependent upon the current CMS user and
98
     * that user's permissions on the objects showing in each field.
99
     */
100
    public function getEditForm($id = null, $fields = null)
101
    {
102
        $form = parent::getEditForm($id, $fields);
103
104
        $definitionGridFieldName = $this->sanitiseClassName(WorkflowDefinition::class);
105
106
        // Show items submitted into a workflow for current user to action
107
        $fieldName = 'PendingObjects';
108
        $pending = $this->userObjects(Security::getCurrentUser(), $fieldName);
0 ignored issues
show
Bug introduced by
It seems like \SilverStripe\Security\Security::getCurrentUser() can be null; however, userObjects() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
109
110
        if ($this->config()->fieldOverrides) {
111
            $displayFields = $this->config()->fieldOverrides;
112
        } else {
113
            $displayFields = array(
114
                'Title'          => _t('AdvancedWorkflowAdmin.Title', 'Title'),
115
                'LastEdited'     => _t('AdvancedWorkflowAdmin.LastEdited', 'Changed'),
116
                'WorkflowTitle'  => _t('AdvancedWorkflowAdmin.WorkflowTitle', 'Effective workflow'),
117
                'WorkflowStatus' => _t('AdvancedWorkflowAdmin.WorkflowStatus', 'Current action'),
118
            );
119
        }
120
121
        // Pending/Submitted items GridField Config
122
        $config = new GridFieldConfig_Base();
123
        $config->addComponent(new GridFieldEditButton());
124
        $config->addComponent(new GridFieldDetailForm());
125
        $config->getComponentByType(GridFieldPaginator::class)->setItemsPerPage(5);
0 ignored issues
show
Bug introduced by
It seems like you code against a concrete implementation and not the interface SilverStripe\Forms\GridField\GridFieldComponent as the method setItemsPerPage() does only exist in the following implementations of said interface: SilverStripe\Forms\GridField\GridFieldPaginator.

Let’s take a look at an example:

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

class MyUser implements 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 implementation 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 interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
126
        $columns = $config->getComponentByType(GridFieldDataColumns::class);
127
        $columns->setFieldFormatting($this->setFieldFormatting($config));
0 ignored issues
show
Documentation introduced by
$config is of type object<SilverStripe\Form...d\GridFieldConfig_Base>, but the function expects a object<Symbiote\Advanced...\Admin\GridFieldConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
128
129
        if ($pending->count()) {
130
            $formFieldTop = GridField::create(
131
                $fieldName,
132
                $this->isAdminUser(Security::getCurrentUser()) ?
0 ignored issues
show
Bug introduced by
It seems like \SilverStripe\Security\Security::getCurrentUser() can be null; however, isAdminUser() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
133
                    _t(
134
                        'AdvancedWorkflowAdmin.GridFieldTitleAssignedAll',
135
                        'All pending items'
136
                    ):
137
                    _t(
138
                        'AdvancedWorkflowAdmin.GridFieldTitleAssignedYour',
139
                        'Your pending items'
140
                    ),
141
                $pending,
142
                $config
143
            );
144
145
            $dataColumns = $formFieldTop->getConfig()->getComponentByType(GridFieldDataColumns::class);
146
            $dataColumns->setDisplayFields($displayFields);
147
148
            $formFieldTop->setForm($form);
149
            $form->Fields()->insertBefore($definitionGridFieldName, $formFieldTop);
150
        }
151
152
        // Show items submitted into a workflow by current user
153
        $fieldName = 'SubmittedObjects';
154
        $submitted = $this->userObjects(Security::getCurrentUser(), $fieldName);
0 ignored issues
show
Bug introduced by
It seems like \SilverStripe\Security\Security::getCurrentUser() can be null; however, userObjects() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
155
        if ($submitted->count()) {
156
            $formFieldBottom = GridField::create(
157
                $fieldName,
158
                $this->isAdminUser(Security::getCurrentUser()) ?
0 ignored issues
show
Bug introduced by
It seems like \SilverStripe\Security\Security::getCurrentUser() can be null; however, isAdminUser() does not accept null, maybe add an additional type check?

Unless you are absolutely sure that the expression can never be null because of other conditions, we strongly recommend to add an additional type check to your code:

/** @return stdClass|null */
function mayReturnNull() { }

function doesNotAcceptNull(stdClass $x) { }

// With potential error.
function withoutCheck() {
    $x = mayReturnNull();
    doesNotAcceptNull($x); // Potential error here.
}

// Safe - Alternative 1
function withCheck1() {
    $x = mayReturnNull();
    if ( ! $x instanceof stdClass) {
        throw new \LogicException('$x must be defined.');
    }
    doesNotAcceptNull($x);
}

// Safe - Alternative 2
function withCheck2() {
    $x = mayReturnNull();
    if ($x instanceof stdClass) {
        doesNotAcceptNull($x);
    }
}
Loading history...
159
                    _t(
160
                        'AdvancedWorkflowAdmin.GridFieldTitleSubmittedAll',
161
                        'All submitted items'
162
                    ):
163
                    _t(
164
                        'AdvancedWorkflowAdmin.GridFieldTitleSubmittedYour',
165
                        'Your submitted items'
166
                    ),
167
                $submitted,
168
                $config
169
            );
170
171
            $dataColumns = $formFieldBottom->getConfig()->getComponentByType(GridFieldDataColumns::class);
172
            $dataColumns->setDisplayFields($displayFields);
173
174
            $formFieldBottom->setForm($form);
175
            $formFieldBottom->getConfig()->removeComponentsByType(GridFieldEditButton::class);
176
            $formFieldBottom->getConfig()->addComponent(new GridFieldWorkflowRestrictedEditButton());
177
            $form->Fields()->insertBefore($definitionGridFieldName, $formFieldBottom);
178
        }
179
180
        $grid = $form->Fields()->fieldByName($definitionGridFieldName);
181
        if ($grid) {
182
            $grid->getConfig()->getComponentByType(GridFieldDetailForm::class)
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on SilverStripe\Forms\FormField. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
183
                ->setItemEditFormCallback(function ($form) {
184
                    $record = $form->getRecord();
185
                    if ($record) {
186
                        $record->updateAdminActions($form->Actions());
187
                    }
188
                });
189
190
            $grid->getConfig()->getComponentByType(GridFieldDetailForm::class)
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on SilverStripe\Forms\FormField. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
191
                ->setItemRequestClass(WorkflowDefinitionItemRequestClass::class);
192
            $grid->getConfig()->addComponent(new GridFieldExportAction());
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on SilverStripe\Forms\FormField. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
193
            $grid->getConfig()->removeComponentsByType(GridFieldExportButton::class);
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on SilverStripe\Forms\FormField. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
194
            $grid->getConfig()->removeComponentsByType(GridFieldImportButton::class);
0 ignored issues
show
Bug introduced by
The method getConfig() does not exist on SilverStripe\Forms\FormField. Did you maybe mean config()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
195
        }
196
197
        return $form;
198
    }
199
200
    /*
201
     * @param Member $user
202
     * @return boolean
203
     */
204
    public function isAdminUser(Member $user)
205
    {
206
        if (Permission::checkMember($user, 'ADMIN')) {
207
            return true;
208
        }
209
        return false;
210
    }
211
212
    /*
213
     * By default, we implement GridField_ColumnProvider to allow users to click through to the PagesAdmin.
214
     * We would also like a "Quick View", that allows users to quickly make a decision on a given workflow-bound
215
     * content-object
216
     */
217
    public function columns()
218
    {
219
        $fields = array(
220
            'Title' => array(
221
                'link' => function ($value, $item) {
222
                    $pageAdminLink = singleton(CMSPageEditController::class)->Link('show');
223
                    return sprintf('<a href="%s/%s">%s</a>', $pageAdminLink, $item->Link, $value);
224
                }
225
            ),
226
            'WorkflowStatus' => array(
227
                'text' => function ($value, $item) {
228
                    return $item->WorkflowCurrentAction;
229
                }
230
            )
231
        );
232
        return $fields;
233
    }
234
235
    /*
236
     * Discreet method used by both intro gridfields to format the target object's links and clickable text
237
     *
238
     * @param GridFieldConfig $config
239
     * @return array $fieldFormatting
240
     */
241
    public function setFieldFormatting(&$config)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
242
    {
243
        $fieldFormatting = array();
244
        // Parse the column information
245
        foreach ($this->columns() as $source => $info) {
246
            if (isset($info['link']) && $info['link']) {
247
                $fieldFormatting[$source] = '<a href=\"$ObjectRecordLink\">$value</a>';
248
            }
249
            if (isset($info['text']) && $info['text']) {
250
                $fieldFormatting[$source] = $info['text'];
251
            }
252
        }
253
        return $fieldFormatting;
254
    }
255
256
    /**
257
     * Get WorkflowInstance Target objects to show for users in initial gridfield(s)
258
     *
259
     * @param Member $member
0 ignored issues
show
Bug introduced by
There is no parameter named $member. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
260
     * @param string $fieldName The name of the gridfield that determines which dataset to return
261
     * @return DataList
262
     * @todo Add the ability to see embargo/expiry dates in report-gridfields at-a-glance if QueuedJobs module installed
263
     */
264
    public function userObjects(Member $user, $fieldName)
265
    {
266
        $list = new ArrayList();
267
        $userWorkflowInstances = $this->getFieldDependentData($user, $fieldName);
268
        foreach ($userWorkflowInstances as $instance) {
0 ignored issues
show
Bug introduced by
The expression $userWorkflowInstances of type object<SilverStripe\ORM\DataList>|null is not guaranteed to be traversable. How about adding an additional type check?

There are different options of fixing this problem.

  1. If you want to be on the safe side, you can add an additional type-check:

    $collection = json_decode($data, true);
    if ( ! is_array($collection)) {
        throw new \RuntimeException('$collection must be an array.');
    }
    
    foreach ($collection as $item) { /** ... */ }
    
  2. If you are sure that the expression is traversable, you might want to add a doc comment cast to improve IDE auto-completion and static analysis:

    /** @var array $collection */
    $collection = json_decode($data, true);
    
    foreach ($collection as $item) { /** .. */ }
    
  3. Mark the issue as a false-positive: Just hover the remove button, in the top-right corner of this issue for more options.

Loading history...
269
            if (!$instance->TargetID || !$instance->DefinitionID) {
270
                continue;
271
            }
272
            // @todo can we use $this->getDefinitionFor() to fetch the "Parent" definition of $instance? Maybe
273
            // define $this->workflowParent()
274
            $effectiveWorkflow = DataObject::get_by_id(WorkflowDefinition::class, $instance->DefinitionID);
275
            $target = $instance->getTarget();
276
            if (!is_object($effectiveWorkflow) || !$target) {
277
                continue;
278
            }
279
            $instance->setField('WorkflowTitle', $effectiveWorkflow->getField('Title'));
280
            $instance->setField('WorkflowCurrentAction', $instance->getCurrentAction());
281
            // Note the order of property-setting here, somehow $instance->Title is overwritten by the Target
282
            // Title property..
283
            $instance->setField('Title', $target->getField('Title'));
284
            $instance->setField('LastEdited', $target->getField('LastEdited'));
285
            if (method_exists($target, 'CMSEditLink')) {
286
                $instance->setField('ObjectRecordLink', $target->CMSEditLink());
287
            }
288
289
            $list->push($instance);
290
        }
291
        return $list;
292
    }
293
294
    /*
295
     * Return content-object data depending on which gridfeld is calling for it
296
     *
297
     * @param Member $user
298
     * @param string $fieldName
299
     */
300
    public function getFieldDependentData(Member $user, $fieldName)
301
    {
302
        if ($fieldName == 'PendingObjects') {
303
            return $this->getWorkflowService()->userPendingItems($user);
304
        }
305
        if ($fieldName == 'SubmittedObjects') {
306
            return $this->getWorkflowService()->userSubmittedItems($user);
307
        }
308
    }
309
310
    /**
311
     * Spits out an exported version of the selected WorkflowDefinition for download.
312
     *
313
     * @param HTTPRequest $request
314
     * @return HTTPResponse
315
     */
316
    public function export(HTTPRequest $request)
317
    {
318
        $url = explode('/', $request->getURL());
319
        $definitionID = end($url);
320
        if ($definitionID && is_numeric($definitionID)) {
321
            $exporter = new WorkflowDefinitionExporter($definitionID);
322
            $exportFilename = WorkflowDefinitionExporter::config()
323
                ->get('export_filename_prefix') . '-' . $definitionID . '.yml';
324
            $exportBody = $exporter->export();
325
            $fileData = array(
326
                'name' => $exportFilename,
327
                'mime' => 'text/x-yaml',
328
                'body' => $exportBody,
329
                'size' => $exporter->getExportSize($exportBody)
0 ignored issues
show
Bug introduced by
It seems like $exportBody defined by $exporter->export() on line 324 can also be of type array<integer,string>; however, Symbiote\AdvancedWorkflo...porter::getExportSize() does only seem to accept string, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
330
            );
331
            return $exporter->sendFile($fileData);
332
        }
333
    }
334
335
    /**
336
     * Required so we can simply change the visible label of the "Import" button and lose some redundant form-fields.
337
     *
338
     * @return Form
339
     */
340
    public function ImportForm()
341
    {
342
        $form = parent::ImportForm();
343
        if (!$form) {
344
            return;
345
        }
346
347
        $form->unsetAllActions();
348
        $newActionList = new FieldList(array(
349
            new FormAction('import', _t('AdvancedWorkflowAdmin.IMPORT', 'Import workflow'))
350
        ));
351
        $form->Fields()->fieldByName('_CsvFile')->getValidator()->setAllowedExtensions(array('yml', 'yaml'));
352
        $form->Fields()->removeByName('EmptyBeforeImport');
353
        $form->setActions($newActionList);
354
355
        return $form;
356
    }
357
358
    /**
359
     * @param WorkflowService $workflowService
360
     * @return $this
361
     */
362
    public function setWorkflowService(WorkflowService $workflowService)
363
    {
364
        $this->workflowService = $workflowService;
365
        return $this;
366
    }
367
368
    /**
369
     * @return WorkflowService
370
     */
371
    public function getWorkflowService()
372
    {
373
        return $this->workflowService;
374
    }
375
}
376