質問編集履歴
3
コードの視認性向上
test
CHANGED
File without changes
|
test
CHANGED
@@ -60,19 +60,37 @@
|
|
60
60
|
|
61
61
|
// ArticleSearchType.php
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
63
|
+
|
64
|
+
|
65
|
+
/**
|
66
|
+
|
67
|
+
* 記事検索用のフォームタイプ
|
68
|
+
|
69
|
+
*/
|
70
|
+
|
71
|
+
class ArticleSearchType extends AbstractType
|
72
|
+
|
73
|
+
{
|
74
|
+
|
75
|
+
/**
|
76
|
+
|
77
|
+
* {@inheritdoc}
|
78
|
+
|
79
|
+
*/
|
80
|
+
|
81
|
+
public function buildForm(FormBuilderInterface $builder, array $options)
|
82
|
+
|
83
|
+
{
|
84
|
+
|
85
|
+
$loginStaff = $options['login_staff'];
|
86
|
+
|
87
|
+
$shop = $options['login_staff']->getShop();
|
72
88
|
|
73
89
|
// 詳細検索
|
74
90
|
|
75
|
-
$builder->add("advanced", "hidden", array(
|
91
|
+
$builder->add("advanced", "hidden", array(
|
92
|
+
|
93
|
+
"required" => false,
|
76
94
|
|
77
95
|
));
|
78
96
|
|
@@ -86,7 +104,9 @@
|
|
86
104
|
|
87
105
|
));
|
88
106
|
|
107
|
+
|
108
|
+
|
89
|
-
|
109
|
+
// 記事ステータス
|
90
110
|
|
91
111
|
$builder->add("articleStatus", "hidden", array(
|
92
112
|
|
@@ -244,7 +264,9 @@
|
|
244
264
|
|
245
265
|
"widget" => "single_text",
|
246
266
|
|
267
|
+
"format" => "yyyy/MM/dd HH:mm",
|
268
|
+
|
247
|
-
"
|
269
|
+
"attr" => array("class" => "formDateTime"),
|
248
270
|
|
249
271
|
));
|
250
272
|
|
@@ -256,7 +278,9 @@
|
|
256
278
|
|
257
279
|
"format" => "yyyy/MM/dd HH:mm",
|
258
280
|
|
259
|
-
"attr" => array("class" => "formDateTimeTo"),
|
281
|
+
"attr" => array("class" => "formDateTimeTo"),
|
282
|
+
|
283
|
+
));
|
260
284
|
|
261
285
|
|
262
286
|
|
@@ -270,7 +294,9 @@
|
|
270
294
|
|
271
295
|
"required" => false,
|
272
296
|
|
273
|
-
"search_params" => array("shop" => $shop),
|
297
|
+
"search_params" => array("shop" => $shop),
|
298
|
+
|
299
|
+
));
|
274
300
|
|
275
301
|
|
276
302
|
|
2
該当クラスのコードを追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -32,6 +32,8 @@
|
|
32
32
|
|
33
33
|
```PHP
|
34
34
|
|
35
|
+
//BaseArticleController.php
|
36
|
+
|
35
37
|
protected function indexAction(Request $request)
|
36
38
|
|
37
39
|
{
|
@@ -54,6 +56,464 @@
|
|
54
56
|
|
55
57
|
|
56
58
|
|
59
|
+
```PHP
|
60
|
+
|
61
|
+
// ArticleSearchType.php
|
62
|
+
|
63
|
+
/** * 記事検索用のフォームタイプ
|
64
|
+
|
65
|
+
*/ class ArticleSearchType extends AbstractType
|
66
|
+
|
67
|
+
{ /** * {@inheritdoc}
|
68
|
+
|
69
|
+
*/ public function buildForm(FormBuilderInterface $builder, array $options)
|
70
|
+
|
71
|
+
{ $loginStaff = $options['login_staff']; $shop = $options['login_staff']->getShop();
|
72
|
+
|
73
|
+
// 詳細検索
|
74
|
+
|
75
|
+
$builder->add("advanced", "hidden", array( "required" => false,
|
76
|
+
|
77
|
+
));
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
// 記事種別
|
82
|
+
|
83
|
+
$builder->add("articleType", "hidden", array(
|
84
|
+
|
85
|
+
"required" => false,
|
86
|
+
|
87
|
+
));
|
88
|
+
|
89
|
+
// 記事ステータス
|
90
|
+
|
91
|
+
$builder->add("articleStatus", "hidden", array(
|
92
|
+
|
93
|
+
"required" => false,
|
94
|
+
|
95
|
+
));
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
// 本部スタッフでログインしている場合はブランド、ショップで検索可
|
100
|
+
|
101
|
+
if ($loginStaff->isHq()) {
|
102
|
+
|
103
|
+
// ブランド
|
104
|
+
|
105
|
+
$builder->add("brand", "brandChoice", array(
|
106
|
+
|
107
|
+
"required" => false,
|
108
|
+
|
109
|
+
));
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
// ショップ
|
114
|
+
|
115
|
+
$builder->add("shop", "shopChoice", array(
|
116
|
+
|
117
|
+
"required" => false,
|
118
|
+
|
119
|
+
));
|
120
|
+
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
// 記事ID
|
126
|
+
|
127
|
+
$builder->add("id", "text", array(
|
128
|
+
|
129
|
+
"required" => false,
|
130
|
+
|
131
|
+
));
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
// 検索ワード
|
136
|
+
|
137
|
+
$builder->add("word", "text", array(
|
138
|
+
|
139
|
+
"required" => false,
|
140
|
+
|
141
|
+
"mb_convert_kana_option" => null,
|
142
|
+
|
143
|
+
));
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
// 検索ボタン
|
148
|
+
|
149
|
+
$builder->add('search', 'submit');
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
// サブミットされたデータによりフォームを動的に生成する
|
154
|
+
|
155
|
+
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($shop) {
|
156
|
+
|
157
|
+
$data = $event->getData();
|
158
|
+
|
159
|
+
$form = $event->getForm();
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
// 記事種別
|
164
|
+
|
165
|
+
$articleType = "";
|
166
|
+
|
167
|
+
if (isset($data["articleType"]) && in_array($data["articleType"], Parameters::getArticleTypeKeys())) {
|
168
|
+
|
169
|
+
$articleType = $data["articleType"];
|
170
|
+
|
171
|
+
}
|
172
|
+
|
173
|
+
$data["articleType"] = $articleType;
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
// 記事ステータス
|
178
|
+
|
179
|
+
$articleStatus = "";
|
180
|
+
|
181
|
+
if (isset($data["articleStatus"]) && in_array($data["articleStatus"], Parameters::getArticleStatusKeys())) {
|
182
|
+
|
183
|
+
$articleStatus = $data["articleStatus"];
|
184
|
+
|
185
|
+
}
|
186
|
+
|
187
|
+
$data["articleStatus"] = $articleStatus;
|
188
|
+
|
189
|
+
|
190
|
+
|
191
|
+
$event->setData($data);
|
192
|
+
|
193
|
+
|
194
|
+
|
195
|
+
// 詳細検索のフォームを追加
|
196
|
+
|
197
|
+
if (isset($data["advanced"]) && $data["advanced"]) {
|
198
|
+
|
199
|
+
// 投稿者
|
200
|
+
|
201
|
+
$form->add("author", "staffChoice", array(
|
202
|
+
|
203
|
+
"required" => false,
|
204
|
+
|
205
|
+
"search_params" => array("shop" => $shop),
|
206
|
+
|
207
|
+
));
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
// 投稿日時
|
212
|
+
|
213
|
+
$form->add("publishDateTimeFrom", "datetime", array(
|
214
|
+
|
215
|
+
"required" => false,
|
216
|
+
|
217
|
+
"widget" => "single_text",
|
218
|
+
|
219
|
+
"format" => "yyyy/MM/dd HH:mm",
|
220
|
+
|
221
|
+
"attr" => array("class" => "formDateTime"),
|
222
|
+
|
223
|
+
));
|
224
|
+
|
225
|
+
$form->add("publishDateTimeTo", "datetime", array(
|
226
|
+
|
227
|
+
"required" => false,
|
228
|
+
|
229
|
+
"widget" => "single_text",
|
230
|
+
|
231
|
+
"format" => "yyyy/MM/dd HH:mm",
|
232
|
+
|
233
|
+
"attr" => array("class" => "formDateTimeTo"),
|
234
|
+
|
235
|
+
));
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
// 有効期限
|
240
|
+
|
241
|
+
$form->add("expireDateTimeFrom", "datetime", array(
|
242
|
+
|
243
|
+
"required" => false,
|
244
|
+
|
245
|
+
"widget" => "single_text",
|
246
|
+
|
247
|
+
"format" => "yyyy/MM/dd HH:mm", "attr" => array("class" => "formDateTime"),
|
248
|
+
|
249
|
+
));
|
250
|
+
|
251
|
+
$form->add("expireDateTimeTo", "datetime", array(
|
252
|
+
|
253
|
+
"required" => false,
|
254
|
+
|
255
|
+
"widget" => "single_text",
|
256
|
+
|
257
|
+
"format" => "yyyy/MM/dd HH:mm",
|
258
|
+
|
259
|
+
"attr" => array("class" => "formDateTimeTo"), ));
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
// 記事種別が 全て or コーディネート or レコメンドアイテム の場合
|
264
|
+
|
265
|
+
if (in_array($articleType, array("", "coordinate", "recommend"))) {
|
266
|
+
|
267
|
+
// 着用者
|
268
|
+
|
269
|
+
$form->add("wearer", "staffChoice", array(
|
270
|
+
|
271
|
+
"required" => false,
|
272
|
+
|
273
|
+
"search_params" => array("shop" => $shop), ));
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
// 品番
|
278
|
+
|
279
|
+
$form->add("itemNo", "text", array(
|
280
|
+
|
281
|
+
"required" => false,
|
282
|
+
|
283
|
+
));
|
284
|
+
|
285
|
+
}
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
// 記事種別が 全て or ショップイベント or ブランド共通イベント の場合
|
290
|
+
|
291
|
+
if (in_array($articleType, array("", "shopevent", "brandevent"))) {
|
292
|
+
|
293
|
+
// イベント開始日時
|
294
|
+
|
295
|
+
$form->add("eventStartDateFrom", "datetime", array(
|
296
|
+
|
297
|
+
"required" => false,
|
298
|
+
|
299
|
+
"widget" => "single_text",
|
300
|
+
|
301
|
+
"format" => "yyyy/MM/dd HH:mm",
|
302
|
+
|
303
|
+
"attr" => array("class" => "formDateTime"),
|
304
|
+
|
305
|
+
));
|
306
|
+
|
307
|
+
$form->add("eventStartDateTo", "datetime", array(
|
308
|
+
|
309
|
+
"required" => false,
|
310
|
+
|
311
|
+
"widget" => "single_text",
|
312
|
+
|
313
|
+
"format" => "yyyy/MM/dd HH:mm",
|
314
|
+
|
315
|
+
"attr" => array("class" => "formDateTimeTo"),
|
316
|
+
|
317
|
+
));
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
// イベント終了日時
|
322
|
+
|
323
|
+
$form->add("eventEndDateFrom", "datetime", array(
|
324
|
+
|
325
|
+
"required" => false,
|
326
|
+
|
327
|
+
"widget" => "single_text",
|
328
|
+
|
329
|
+
"format" => "yyyy/MM/dd HH:mm",
|
330
|
+
|
331
|
+
"attr" => array("class" => "formDateTime"),
|
332
|
+
|
333
|
+
));
|
334
|
+
|
335
|
+
$form->add("eventEndDateTo", "datetime", array(
|
336
|
+
|
337
|
+
"required" => false,
|
338
|
+
|
339
|
+
"widget" => "single_text",
|
340
|
+
|
341
|
+
"format" => "yyyy/MM/dd HH:mm",
|
342
|
+
|
343
|
+
"attr" => array("class" => "formDateTimeTo"),
|
344
|
+
|
345
|
+
));
|
346
|
+
|
347
|
+
}
|
348
|
+
|
349
|
+
}
|
350
|
+
|
351
|
+
});
|
352
|
+
|
353
|
+
}
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
/**
|
358
|
+
|
359
|
+
* {@inheritdoc}
|
360
|
+
|
361
|
+
*/
|
362
|
+
|
363
|
+
public function setDefaultOptions(OptionsResolver $resolver)
|
364
|
+
|
365
|
+
{
|
366
|
+
|
367
|
+
$resolver->setDefaults(array(
|
368
|
+
|
369
|
+
"method" => "GET",
|
370
|
+
|
371
|
+
"csrf_protection" => false,
|
372
|
+
|
373
|
+
"validation_groups" => false,
|
374
|
+
|
375
|
+
));
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
$resolver->setRequired(array(
|
380
|
+
|
381
|
+
"login_staff",
|
382
|
+
|
383
|
+
));
|
384
|
+
|
385
|
+
}
|
386
|
+
|
387
|
+
|
388
|
+
|
389
|
+
/**
|
390
|
+
|
391
|
+
* {@inheritdoc}
|
392
|
+
|
393
|
+
*/
|
394
|
+
|
395
|
+
public function buildView(FormView $view, FormInterface $form, array $options)
|
396
|
+
|
397
|
+
{
|
398
|
+
|
399
|
+
$loginStaff = $options['login_staff'];
|
400
|
+
|
401
|
+
$shop = $options['login_staff']->getShop();
|
402
|
+
|
403
|
+
|
404
|
+
|
405
|
+
// 有効な記事種別
|
406
|
+
|
407
|
+
if ($loginStaff->isHq()) {
|
408
|
+
|
409
|
+
// 本部管理画面
|
410
|
+
|
411
|
+
$view->vars['enabledArticleType'] = array(
|
412
|
+
|
413
|
+
"" => "全て",
|
414
|
+
|
415
|
+
"brandevent" => "ブランドイベント",
|
416
|
+
|
417
|
+
"coordinate" => "コーディネート",
|
418
|
+
|
419
|
+
"recommend" => "レコメンドアイテム",
|
420
|
+
|
421
|
+
"diary" => "ダイアリー",
|
422
|
+
|
423
|
+
"shopevent" => "ニュース",
|
424
|
+
|
425
|
+
);
|
426
|
+
|
427
|
+
} else {
|
428
|
+
|
429
|
+
// ショップ管理画面
|
430
|
+
|
431
|
+
$view->vars['enabledArticleType'] = array(
|
432
|
+
|
433
|
+
"" => "全て",
|
434
|
+
|
435
|
+
"coordinate" => "コーディネート",
|
436
|
+
|
437
|
+
"recommend" => "レコメンドアイテム",
|
438
|
+
|
439
|
+
"diary" => "ダイアリー",
|
440
|
+
|
441
|
+
"shopevent" => "ニュース",
|
442
|
+
|
443
|
+
);
|
444
|
+
|
445
|
+
}
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
// 有効な記事ステータス
|
450
|
+
|
451
|
+
if ($loginStaff->isHq() or $shop->getApprovalFlg()) {
|
452
|
+
|
453
|
+
// 本部管理画面 or 承認フラグが有効なショップ管理画面
|
454
|
+
|
455
|
+
$view->vars["enabledArticleStatus"] = array(
|
456
|
+
|
457
|
+
"" => "全て",
|
458
|
+
|
459
|
+
"draft" => "下書き",
|
460
|
+
|
461
|
+
"pending" => "承認待ち",
|
462
|
+
|
463
|
+
"reject" => "非承認",
|
464
|
+
|
465
|
+
"publish" => "公開",
|
466
|
+
|
467
|
+
"hidden" => "非公開",
|
468
|
+
|
469
|
+
);
|
470
|
+
|
471
|
+
} else {
|
472
|
+
|
473
|
+
// 承認フラグが無効なショップ管理画面
|
474
|
+
|
475
|
+
$view->vars["enabledArticleStatus"] = array(
|
476
|
+
|
477
|
+
"" => "全て",
|
478
|
+
|
479
|
+
"draft" => "下書き",
|
480
|
+
|
481
|
+
"publish" => "公開",
|
482
|
+
|
483
|
+
"hidden" => "非公開",
|
484
|
+
|
485
|
+
);
|
486
|
+
|
487
|
+
}
|
488
|
+
|
489
|
+
}
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
/**
|
494
|
+
|
495
|
+
* {@inheritdoc}
|
496
|
+
|
497
|
+
*/
|
498
|
+
|
499
|
+
public function getName()
|
500
|
+
|
501
|
+
{
|
502
|
+
|
503
|
+
return "q";
|
504
|
+
|
505
|
+
}
|
506
|
+
|
507
|
+
}
|
508
|
+
|
509
|
+
|
510
|
+
|
511
|
+
|
512
|
+
|
513
|
+
```
|
514
|
+
|
515
|
+
|
516
|
+
|
57
517
|
### 試したこと
|
58
518
|
|
59
519
|
|
1
エラーの原因となるphpバージョンの説明
test
CHANGED
File without changes
|
test
CHANGED
@@ -58,7 +58,7 @@
|
|
58
58
|
|
59
59
|
|
60
60
|
|
61
|
-
このエラーのよくある原因がphpのバージョンが低いことのようですが、
|
61
|
+
このエラーのよくある原因がphpのバージョンが低い (<5.4)ことのようですが、
|
62
62
|
|
63
63
|
PHPのバージョンは5.6.40であり、```php -v```や```phpinfo();```でもバージョンを確認しております。
|
64
64
|
|