1 | <?php |
||
20 | abstract class AbstractDefaultController extends AbstractController implements EnsureSAMLPlugin |
||
21 | { |
||
22 | |||
23 | const TEMPLATE_INDEX = DIRECTORY_SEPARATOR . '_cp' . DIRECTORY_SEPARATOR . 'metadata'; |
||
24 | |||
25 | /** |
||
26 | * @return \yii\web\Response |
||
27 | * @throws \Exception |
||
28 | */ |
||
29 | public function actionIndex() |
||
30 | { |
||
31 | $variables = $this->getBaseVariables(); |
||
32 | $plugin = $this->getPlugin(); |
||
33 | $variables['myProvider'] = null; |
||
34 | $variables['spProviders'] = []; |
||
35 | $variables['idpProviders'] = []; |
||
36 | $variables['idpListInstructions'] = $this->getListInstructions(SettingsInterface::IDP); |
||
37 | $variables['spListInstructions'] = $this->getListInstructions(SettingsInterface::SP); |
||
38 | |||
39 | /** |
||
40 | * Breadcrumbs |
||
41 | */ |
||
42 | $variables['crumbs'] = [ |
||
43 | [ |
||
44 | 'url' => UrlHelper::cpUrl($this->getPlugin()->getHandle()), |
||
45 | 'label' => $this->getPlugin()->name, |
||
46 | ], |
||
47 | [ |
||
48 | 'url' => UrlHelper::cpUrl($this->getPlugin()->getHandle()) . '/metadata', |
||
49 | 'label' => 'Provider List', |
||
50 | ], |
||
51 | ]; |
||
52 | |||
53 | /** |
||
54 | * Get IDPs |
||
55 | */ |
||
56 | foreach ($plugin->getProvider()->findByIdp([ |
||
57 | 'enabled' => [true, false], |
||
58 | ])->all() as $provider) { |
||
59 | $variables['idpProviders'][] = $provider; |
||
60 | if ($provider->getEntityId() == $this->getPlugin()->getSettings()->getEntityId()) { |
||
61 | $variables['myProvider'] = $provider; |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Get SPs |
||
67 | */ |
||
68 | foreach ($plugin->getProvider()->findBySp([ |
||
69 | 'enabled' => [true, false], |
||
70 | ])->all() as $provider) { |
||
71 | $variables['spProviders'][] = $provider; |
||
72 | if ($provider->getEntityId() == $this->getPlugin()->getSettings()->getEntityId()) { |
||
73 | $variables['myProvider'] = $provider; |
||
74 | } |
||
75 | } |
||
76 | |||
77 | $variables['title'] = Craft::t($this->getPlugin()->getHandle(), $this->getPlugin()->name); |
||
78 | return $this->renderTemplate( |
||
79 | $this->getTemplateIndex() . static::TEMPLATE_INDEX . DIRECTORY_SEPARATOR . 'list', |
||
80 | $variables |
||
81 | ); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @param $providerType |
||
86 | * @return string |
||
87 | * @throws \Exception |
||
88 | */ |
||
89 | protected function getListInstructions($providerType) |
||
127 | } |
||
128 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.