These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace Kunstmaan\NodeSearchBundle\Helper\FormWidgets; |
||
4 | |||
5 | use Doctrine\ORM\EntityManager; |
||
6 | use Kunstmaan\AdminBundle\Helper\FormWidgets\FormWidget; |
||
7 | use Kunstmaan\NodeBundle\Entity\Node; |
||
8 | use Kunstmaan\NodeSearchBundle\Entity\NodeSearch; |
||
9 | use Symfony\Component\Form\FormBuilderInterface; |
||
10 | use Symfony\Component\HttpFoundation\Request; |
||
11 | |||
12 | class SearchFormWidget extends FormWidget |
||
13 | { |
||
14 | /** @var Node */ |
||
15 | private $node; |
||
16 | |||
17 | /** @var NodeSearch */ |
||
18 | private $nodeSearch; |
||
19 | |||
20 | /** |
||
21 | * @param Node $node |
||
22 | * @param EntityManager $em |
||
23 | */ |
||
24 | public function __construct(Node $node, EntityManager $em) |
||
25 | { |
||
26 | $this->node = $node; |
||
27 | $this->nodeSearch = $em->getRepository('KunstmaanNodeSearchBundle:NodeSearch')->findOneByNode($this->node); |
||
0 ignored issues
–
show
|
|||
28 | } |
||
29 | |||
30 | /** |
||
31 | * @param FormBuilderInterface $builder The form builder |
||
32 | */ |
||
33 | public function buildForm(FormBuilderInterface $builder) |
||
34 | { |
||
35 | parent::buildForm($builder); |
||
36 | $data = $builder->getData(); |
||
37 | $data['node_search'] = $this->nodeSearch; |
||
38 | $builder->setData($data); |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * @param Request $request |
||
43 | */ |
||
44 | public function bindRequest(Request $request) |
||
45 | { |
||
46 | $form = $request->request->get('form'); |
||
47 | $this->data['node_search'] = $form['node_search']['boost']; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @param EntityManager $em |
||
52 | */ |
||
53 | public function persist(EntityManager $em) |
||
54 | { |
||
55 | $nodeSearch = $em->getRepository('KunstmaanNodeSearchBundle:NodeSearch')->findOneByNode($this->node); |
||
0 ignored issues
–
show
The method
findOneByNode() does not exist on Doctrine\Persistence\ObjectRepository . Did you maybe mean findOneBy() ?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise.
Loading history...
|
|||
56 | |||
57 | if ($this->data['node_search'] !== null) { |
||
58 | if ($nodeSearch === null) { |
||
59 | $nodeSearch = new NodeSearch(); |
||
60 | $nodeSearch->setNode($this->node); |
||
61 | } |
||
62 | $nodeSearch->setBoost($this->data['node_search']); |
||
63 | $em->persist($nodeSearch); |
||
64 | } |
||
65 | } |
||
66 | } |
||
67 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.