Stinger-Soft /
EntitySearchBundle
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | declare(strict_types=1); |
||
| 3 | |||
| 4 | /* |
||
| 5 | * This file is part of the Stinger Entity Search package. |
||
| 6 | * |
||
| 7 | * (c) Oliver Kotte <[email protected]> |
||
| 8 | * (c) Florian Meyer <[email protected]> |
||
| 9 | * |
||
| 10 | * For the full copyright and license information, please view the LICENSE |
||
| 11 | * file that was distributed with this source code. |
||
| 12 | */ |
||
| 13 | namespace StingerSoft\EntitySearchBundle\DependencyInjection; |
||
| 14 | |||
| 15 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||
| 16 | use Symfony\Component\Config\Definition\ConfigurationInterface; |
||
| 17 | use Symfony\Component\HttpKernel\Kernel; |
||
| 18 | |||
| 19 | |||
| 20 | /** |
||
| 21 | * This is the class that validates and merges configuration from your app/config files |
||
| 22 | * |
||
| 23 | * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class} |
||
| 24 | */ |
||
| 25 | class Configuration implements ConfigurationInterface { |
||
| 26 | |||
| 27 | /** |
||
| 28 | * |
||
| 29 | * {@inheritDoc} |
||
| 30 | * |
||
| 31 | */ |
||
| 32 | public function getConfigTreeBuilder() { |
||
| 33 | $treeBuilder = new TreeBuilder('stinger_soft_entity_search'); |
||
| 34 | // @formatter:off |
||
| 35 | $treeBuilder->getRootNode()->children() |
||
|
0 ignored issues
–
show
|
|||
| 36 | ->booleanNode('enable_indexing')->defaultFalse()->end() |
||
| 37 | ->booleanNode('enable_search')->defaultFalse()->end() |
||
| 38 | ->scalarNode('search_service')->defaultValue('stinger_soft.entity_search.dummy_search_service')->end() |
||
| 39 | ->arrayNode('results')->addDefaultsIfNotSet() |
||
| 40 | ->children() |
||
| 41 | ->integerNode('max_choice_group_count')->defaultValue(10)->end() |
||
| 42 | ->arrayNode('preferred_type_choices') |
||
| 43 | ->prototype('scalar')->end() |
||
| 44 | ->end() |
||
| 45 | ->arrayNode('preferred_filetype_choices') |
||
| 46 | ->prototype('scalar')->end() |
||
| 47 | ->end() |
||
| 48 | ->arrayNode('ingore_patterns') |
||
| 49 | ->prototype('scalar')->end() |
||
| 50 | ->end() |
||
| 51 | ->end() |
||
| 52 | ->end() |
||
| 53 | ->arrayNode('facets')->defaultValue(array('stinger_soft_entity_search.facets.author', 'stinger_soft_entity_search.facets.editors', 'stinger_soft_entity_search.facets.type')) |
||
| 54 | ->prototype('scalar')->end() |
||
| 55 | ->end() |
||
| 56 | ->arrayNode('types') |
||
| 57 | ->useAttributeAsKey('name') |
||
| 58 | ->prototype('array') |
||
| 59 | ->children() |
||
| 60 | ->arrayNode('mappings') |
||
| 61 | ->useAttributeAsKey('name') |
||
| 62 | ->cannotBeEmpty() |
||
| 63 | ->prototype('array') |
||
| 64 | ->children() |
||
| 65 | ->scalarNode('propertyPath')->defaultValue(false)->end() |
||
| 66 | ->end() |
||
| 67 | ->end() |
||
| 68 | ->end() |
||
| 69 | ->arrayNode('persistence') |
||
| 70 | ->children() |
||
| 71 | ->scalarNode('model')->end() |
||
| 72 | ->end() |
||
| 73 | ->end() |
||
| 74 | ->end() |
||
| 75 | ->end() |
||
| 76 | ->end(); |
||
| 77 | // @formatter:on |
||
| 78 | |||
| 79 | return $treeBuilder; |
||
| 80 | } |
||
| 81 | } |
||
| 82 |
Let’s take a look at an example:
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 sub-classes of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the parent class: