nanasess /
ec-cube
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | * This file is part of EC-CUBE |
||
| 4 | * |
||
| 5 | * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved. |
||
| 6 | * |
||
| 7 | * http://www.lockon.co.jp/ |
||
| 8 | * |
||
| 9 | * This program is free software; you can redistribute it and/or |
||
| 10 | * modify it under the terms of the GNU General Public License |
||
| 11 | * as published by the Free Software Foundation; either version 2 |
||
| 12 | * of the License, or (at your option) any later version. |
||
| 13 | * |
||
| 14 | * This program is distributed in the hope that it will be useful, |
||
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
||
| 17 | * GNU General Public License for more details. |
||
| 18 | * |
||
| 19 | * You should have received a copy of the GNU General Public License |
||
| 20 | * along with this program; if not, write to the Free Software |
||
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
||
| 22 | */ |
||
| 23 | |||
| 24 | |||
| 25 | namespace Eccube\Event; |
||
| 26 | |||
| 27 | use Symfony\Component\Form\FormEvent; |
||
| 28 | use Symfony\Component\Form\FormEvents; |
||
| 29 | use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
||
| 30 | use Symfony\Component\Finder\Finder; |
||
| 31 | use Symfony\Component\Yaml\Yaml; |
||
| 32 | use Monolog\Logger; |
||
| 33 | |||
| 34 | class FormEventSubscriber implements EventSubscriberInterface |
||
| 35 | { |
||
| 36 | public static function getEvents() |
||
| 37 | { |
||
| 38 | $events = array(); |
||
| 39 | // YamlでParseしてがんばる |
||
| 40 | $basePath = __DIR__ . '/../../../app/Plugin'; |
||
| 41 | $finder = Finder::create() |
||
| 42 | ->in($basePath) |
||
| 43 | ->directories() |
||
| 44 | ->depth(0); |
||
| 45 | |||
| 46 | $app = \Eccube\Application::getInstance(); |
||
| 47 | |||
| 48 | foreach ($finder as $dir) { |
||
| 49 | $config = Yaml::parse(file_get_contents($dir->getRealPath() . '/config.yml')); |
||
|
0 ignored issues
–
show
|
|||
| 50 | try { |
||
| 51 | $app['eccube.service.plugin']->checkPluginArchiveContent($dir->getRealPath()); |
||
| 52 | } catch(\Eccube\Exception\PluginException $e) { |
||
|
0 ignored issues
–
show
|
|||
| 53 | $app['monolog']->warning($e->getMessage()); |
||
| 54 | continue; |
||
| 55 | } |
||
| 56 | $config = $app['eccube.service.plugin']->readYml($dir->getRealPath() . '/config.yml'); |
||
|
0 ignored issues
–
show
|
|||
| 57 | |||
| 58 | if (isset($config['form'])) { |
||
| 59 | foreach ($config['form'] as $event => $class) { |
||
| 60 | $events[$event][] = '\\Plugin\\' . $config['code'] . '\\' . $class; |
||
| 61 | } |
||
| 62 | } |
||
| 63 | } |
||
| 64 | |||
| 65 | return $events; |
||
| 66 | } |
||
| 67 | |||
| 68 | 214 | public static function getSubscribedEvents() |
|
| 69 | { |
||
| 70 | return array( |
||
| 71 | 214 | FormEvents::PRE_SET_DATA => 'onPreSetData', |
|
| 72 | 214 | FormEvents::POST_SET_DATA => 'onPostSetData', |
|
| 73 | 214 | FormEvents::PRE_SUBMIT => 'onPreSubmit', |
|
| 74 | 214 | FormEvents::SUBMIT => 'onSubmit', |
|
| 75 | 214 | FormEvents::POST_SUBMIT => 'onPostSubmit', |
|
| 76 | ); |
||
| 77 | } |
||
| 78 | |||
| 79 | 254 | View Code Duplication | public function onPreSetData(FormEvent $event) |
| 80 | { |
||
| 81 | $events = self::getEvents(); |
||
| 82 | |||
| 83 | 254 | if (isset($events['onPreSetData'])) { |
|
| 84 | foreach($events['onPreSetData'] as $formEventClass) { |
||
| 85 | $formEvent = new $formEventClass(); |
||
| 86 | $formEvent->onPreSetData($event); |
||
| 87 | } |
||
| 88 | } |
||
| 89 | } |
||
| 90 | |||
| 91 | 254 | View Code Duplication | public function onPostSetData(FormEvent $event) |
| 92 | { |
||
| 93 | $events = self::getEvents(); |
||
| 94 | |||
| 95 | 254 | if (isset($events['onPostSetData'])) { |
|
| 96 | foreach($events['onPostSetData'] as $formEventClass) { |
||
| 97 | $formEvent = new $formEventClass(); |
||
| 98 | $formEvent->onPostSetData($event); |
||
| 99 | } |
||
| 100 | } |
||
| 101 | } |
||
| 102 | |||
| 103 | 193 | View Code Duplication | public function onPreSubmit(FormEvent $event) |
| 104 | { |
||
| 105 | $events = self::getEvents(); |
||
| 106 | |||
| 107 | 193 | if (isset($events['onPreSubmit'])) { |
|
| 108 | foreach($events['onPreSubmit'] as $formEventClass) { |
||
| 109 | $formEvent = new $formEventClass(); |
||
| 110 | $formEvent->onPreSubmit($event); |
||
| 111 | } |
||
| 112 | } |
||
| 113 | } |
||
| 114 | |||
| 115 | 238 | View Code Duplication | public function onSubmit(FormEvent $event) |
| 116 | { |
||
| 117 | $events = self::getEvents(); |
||
| 118 | |||
| 119 | 238 | if (isset($events['onSubmit'])) { |
|
| 120 | foreach($events['onSubmit'] as $formEventClass) { |
||
| 121 | $formEvent = new $formEventClass(); |
||
| 122 | $formEvent->onSubmit($event); |
||
| 123 | } |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | 193 | View Code Duplication | public function onPostSubmit(FormEvent $event) |
| 128 | { |
||
| 129 | $events = self::getEvents(); |
||
| 130 | |||
| 131 | 193 | if (isset($events['onPostSubmit'])) { |
|
| 132 | foreach($events['onPostSubmit'] as $formEventClass) { |
||
| 133 | $formEvent = new $formEventClass(); |
||
| 134 | $formEvent->onPostSubmit($event); |
||
| 135 | } |
||
| 136 | } |
||
| 137 | } |
||
| 138 | } |
||
| 139 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.