mediapart /
lapresselibre-bundle
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * This file is part of the Mediapart LaPresseLibre Bundle. |
||
| 5 | * |
||
| 6 | * CC BY-NC-SA <https://github.com/mediapart/lapresselibre-bundle> |
||
| 7 | * |
||
| 8 | * For the full license information, please view the LICENSE |
||
| 9 | * file that was distributed with this source code. |
||
| 10 | */ |
||
| 11 | |||
| 12 | namespace Mediapart\Bundle\LaPresseLibreBundle\DependencyInjection; |
||
| 13 | |||
| 14 | use Symfony\Component\DependencyInjection\Definition; |
||
| 15 | use Symfony\Component\DependencyInjection\Reference; |
||
| 16 | use Symfony\Component\DependencyInjection\ContainerBuilder; |
||
| 17 | use Symfony\Component\HttpKernel\DependencyInjection\Extension; |
||
| 18 | use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory; |
||
| 19 | use Mediapart\LaPresseLibre\Transaction; |
||
| 20 | use Mediapart\LaPresseLibre\Registration; |
||
| 21 | use Mediapart\LaPresseLibre\Account\Link; |
||
| 22 | use Mediapart\LaPresseLibre\Security\Encryption; |
||
| 23 | use Mediapart\LaPresseLibre\Security\Identity; |
||
| 24 | use Mediapart\Bundle\LaPresseLibreBundle\Controller; |
||
| 25 | use Mediapart\Bundle\LaPresseLibreBundle\Handler; |
||
| 26 | use Mediapart\Bundle\LaPresseLibreBundle\Factory; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * This is the class that loads and manages your bundle configuration |
||
| 30 | * |
||
| 31 | * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html} |
||
| 32 | */ |
||
| 33 | class MediapartLaPresseLibreExtension extends Extension |
||
| 34 | { |
||
| 35 | const PUBLIC_SERVICE = true; |
||
| 36 | const PRIVATE_SERVICE = false; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * {@inheritDoc} |
||
| 40 | */ |
||
| 41 | public function load(array $configs, ContainerBuilder $container) |
||
| 42 | { |
||
| 43 | $config = $this->processConfiguration( |
||
| 44 | new Configuration(), |
||
| 45 | $configs |
||
| 46 | ); |
||
| 47 | $this |
||
| 48 | ->loadIdentity($config, $container) |
||
| 49 | ->loadEncryption($config, $container) |
||
| 50 | ->loadTransactionFactory($config, $container) |
||
| 51 | ->loadRedirectionFactory($config, $container) |
||
| 52 | ->loadEndpointFactory($container) |
||
| 53 | ->loadPsr7Factory($container) |
||
| 54 | ->loadHandler($container) |
||
| 55 | ->loadWebServicesController($container) |
||
| 56 | ->loadLinkAccountController($config, $container) |
||
| 57 | ->loadRegistration($config, $container) |
||
| 58 | ->loadLink($config, $container) |
||
| 59 | ; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * @param array $config |
||
| 64 | * @param ContainerBuilder $container |
||
| 65 | * |
||
| 66 | * @return self |
||
| 67 | */ |
||
| 68 | private function loadIdentity(array $config, ContainerBuilder $container) |
||
| 69 | { |
||
| 70 | return $this->setDefinition( |
||
| 71 | $container, |
||
| 72 | 'mediapart_lapresselibre.identity', |
||
| 73 | Identity::class, |
||
| 74 | [ |
||
| 75 | $config['secret_key'], |
||
| 76 | ] |
||
| 77 | ); |
||
| 78 | } |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @param array $config |
||
| 82 | * @param ContainerBuilder $container |
||
| 83 | * |
||
| 84 | * @return self |
||
| 85 | */ |
||
| 86 | private function loadEncryption(array $config, ContainerBuilder $container) |
||
| 87 | { |
||
| 88 | return $this->setDefinition( |
||
| 89 | $container, |
||
| 90 | 'mediapart_lapresselibre.encryption', |
||
| 91 | Encryption::class, |
||
| 92 | [ |
||
| 93 | $config['aes_password'], |
||
| 94 | $config['aes_iv'], |
||
| 95 | $config['aes_options'], |
||
| 96 | ] |
||
| 97 | ); |
||
| 98 | } |
||
| 99 | |||
| 100 | /** |
||
| 101 | * @param array $config |
||
| 102 | * @param ContainerBuilder $container |
||
| 103 | * |
||
| 104 | * @return self |
||
| 105 | */ |
||
| 106 | private function loadTransactionFactory(array $config, ContainerBuilder $container) |
||
| 107 | { |
||
| 108 | return $this->setDefinition( |
||
| 109 | $container, |
||
| 110 | 'mediapart_lapresselibre.transaction_factory', |
||
| 111 | Factory\TransactionFactory::class, |
||
| 112 | [ |
||
| 113 | $config['public_key'], |
||
| 114 | new Reference('mediapart_lapresselibre.identity'), |
||
| 115 | new Reference('mediapart_lapresselibre.encryption'), |
||
| 116 | ], |
||
| 117 | self::PRIVATE_SERVICE |
||
| 118 | ); |
||
| 119 | } |
||
| 120 | |||
| 121 | /** |
||
| 122 | * @param ContainerBuilder $container |
||
| 123 | * |
||
| 124 | * @return self |
||
| 125 | */ |
||
| 126 | private function loadEndpointFactory(ContainerBuilder $container) |
||
| 127 | { |
||
| 128 | return $this->setDefinition( |
||
| 129 | $container, |
||
| 130 | 'mediapart_lapresselibre.endpoint_factory', |
||
| 131 | Factory\EndpointFactory::class, |
||
| 132 | [], |
||
| 133 | self::PRIVATE_SERVICE |
||
| 134 | ); |
||
| 135 | } |
||
| 136 | |||
| 137 | /** |
||
| 138 | * @param array $config |
||
| 139 | * @param ContainerBuilder $container |
||
| 140 | * |
||
| 141 | * @return self |
||
| 142 | */ |
||
| 143 | private function loadRedirectionFactory(array $config, ContainerBuilder $container) |
||
| 144 | { |
||
| 145 | return $this->setDefinition( |
||
| 146 | $container, |
||
| 147 | 'mediapart_lapresselibre.redirection_factory', |
||
| 148 | Factory\RedirectionFactory::class, |
||
| 149 | [ |
||
| 150 | new Reference('mediapart_lapresselibre.link'), |
||
| 151 | new Reference($config['account']['provider']) |
||
| 152 | ], |
||
| 153 | self::PRIVATE_SERVICE |
||
| 154 | ); |
||
| 155 | } |
||
| 156 | |||
| 157 | /** |
||
| 158 | * @param ContainerBuilder $container |
||
| 159 | * |
||
| 160 | * @return self |
||
| 161 | */ |
||
| 162 | private function loadPsr7Factory(ContainerBuilder $container) |
||
| 163 | { |
||
| 164 | return $this->setDefinition( |
||
| 165 | $container, |
||
| 166 | 'mediapart_lapresselibre.psr7_factory', |
||
| 167 | DiactorosFactory::class, |
||
| 168 | [], |
||
| 169 | self::PRIVATE_SERVICE |
||
| 170 | ); |
||
| 171 | } |
||
| 172 | |||
| 173 | /** |
||
| 174 | * @param ContainerBuilder $container |
||
| 175 | * |
||
| 176 | * @return self |
||
| 177 | */ |
||
| 178 | private function loadHandler(ContainerBuilder $container) |
||
| 179 | { |
||
| 180 | return $this->setDefinition( |
||
| 181 | $container, |
||
| 182 | 'mediapart_lapresselibre.handler', |
||
| 183 | Handler::class, |
||
| 184 | [ |
||
| 185 | new Reference('mediapart_lapresselibre.endpoint_factory'), |
||
| 186 | new Reference('mediapart_lapresselibre.transaction_factory'), |
||
| 187 | new Reference('mediapart_lapresselibre.psr7_factory'), |
||
| 188 | ], |
||
| 189 | self::PRIVATE_SERVICE |
||
| 190 | ); |
||
| 191 | } |
||
| 192 | |||
| 193 | /** |
||
| 194 | * @param ContainerBuilder $container |
||
| 195 | * |
||
| 196 | * @return self |
||
| 197 | */ |
||
| 198 | private function loadWebServicesController(ContainerBuilder $container) |
||
| 199 | { |
||
| 200 | return $this->setDefinition( |
||
| 201 | $container, |
||
| 202 | 'mediapart_lapresselibre.webservices_controller', |
||
| 203 | Controller\WebServicesController::class, |
||
| 204 | [ |
||
| 205 | new Reference('mediapart_lapresselibre.handler'), |
||
| 206 | ] |
||
| 207 | ); |
||
| 208 | } |
||
| 209 | |||
| 210 | /** |
||
| 211 | * @param array $config |
||
| 212 | * @param ContainerBuilder $container |
||
| 213 | * |
||
| 214 | * @return self |
||
| 215 | */ |
||
| 216 | private function loadLinkAccountController(array $config, ContainerBuilder $container) |
||
|
0 ignored issues
–
show
|
|||
| 217 | { |
||
| 218 | return $this->setDefinition( |
||
| 219 | $container, |
||
| 220 | 'mediapart_lapresselibre.linkaccount_controller', |
||
| 221 | Controller\LinkAccountController::class, |
||
| 222 | [ |
||
| 223 | new Reference('mediapart_lapresselibre.redirection_factory'), |
||
| 224 | ] |
||
| 225 | ); |
||
| 226 | } |
||
| 227 | |||
| 228 | /** |
||
| 229 | * @param array $config |
||
| 230 | * @param ContainerBuilder $container |
||
| 231 | * |
||
| 232 | * @return self |
||
| 233 | */ |
||
| 234 | private function loadRegistration(array $config, ContainerBuilder $container) |
||
| 235 | { |
||
| 236 | return $this->setDefinition( |
||
| 237 | $container, |
||
| 238 | 'mediapart_lapresselibre.registration', |
||
| 239 | Registration::class, |
||
| 240 | [ |
||
| 241 | $config['public_key'], |
||
| 242 | new Reference('mediapart_lapresselibre.encryption'), |
||
| 243 | ] |
||
| 244 | ); |
||
| 245 | } |
||
| 246 | |||
| 247 | private function loadLink(array $config, ContainerBuilder $container) |
||
| 248 | { |
||
| 249 | return $this->setDefinition( |
||
| 250 | $container, |
||
| 251 | 'mediapart_lapresselibre.link', |
||
| 252 | Link::class, |
||
| 253 | [ |
||
| 254 | new Reference('mediapart_lapresselibre.encryption'), |
||
| 255 | new Reference($config['account']['repository']), |
||
| 256 | $config['public_key'], |
||
| 257 | ] |
||
| 258 | ); |
||
| 259 | } |
||
| 260 | |||
| 261 | /** |
||
| 262 | * @param ContainerBuilder $container |
||
| 263 | * @param string $id |
||
| 264 | * @param string $class |
||
| 265 | * @param array $arguments |
||
| 266 | * @param boolean $private |
||
| 267 | * |
||
| 268 | * @return self |
||
| 269 | */ |
||
| 270 | private function setDefinition(ContainerBuilder $container, $id, $class, $arguments = [], $public = self::PUBLIC_SERVICE) |
||
| 271 | { |
||
| 272 | $definition = new Definition($class, $arguments); |
||
| 273 | $definition->setPublic($public); |
||
| 274 | $container->setDefinition($id, $definition); |
||
| 275 | return $this; |
||
| 276 | } |
||
| 277 | } |
||
| 278 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.