1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @author Boudewijn Schoon <[email protected]> |
4
|
|
|
* @copyright Zicht Online <http://zicht.nl> |
5
|
|
|
*/ |
6
|
|
|
|
7
|
|
|
namespace Zicht\Bundle\UrlBundle\Admin; |
8
|
|
|
|
9
|
|
|
use Symfony\Bridge\Doctrine\RegistryInterface; |
10
|
|
|
use Symfony\Component\Form\AbstractType; |
11
|
|
|
use Symfony\Component\Form\FormInterface; |
12
|
|
|
use Symfony\Component\Form\FormView; |
13
|
|
|
use Symfony\Component\OptionsResolver\OptionsResolver; |
14
|
|
|
use Zicht\Bundle\UrlBundle\Exception\UnsupportedException; |
15
|
|
|
use Zicht\Bundle\UrlBundle\Url\Provider; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Form type to render all available url aliases |
19
|
|
|
*/ |
20
|
|
|
class AliasOverviewType extends AbstractType |
21
|
|
|
{ |
22
|
|
|
/** @var Provider */ |
23
|
|
|
protected $provider; |
24
|
|
|
|
25
|
|
|
/** @var RegistryInterface */ |
26
|
|
|
protected $doctrine; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* AliasOverviewType constructor. |
30
|
|
|
* |
31
|
|
|
* @param Provider $provider |
32
|
|
|
* @param RegistryInterface $doctrine |
33
|
|
|
*/ |
34
|
|
|
public function __construct(Provider $provider, RegistryInterface $doctrine) |
35
|
|
|
{ |
36
|
|
|
$this->provider = $provider; |
37
|
|
|
$this->doctrine = $doctrine; |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @{inheritDoc} |
42
|
|
|
*/ |
43
|
|
|
public function configureOptions(OptionsResolver $resolver) |
44
|
|
|
{ |
45
|
|
|
parent::configureOptions($resolver); |
46
|
|
|
$resolver->setRequired('record'); |
47
|
|
|
$resolver->setDefaults( |
48
|
|
|
[ |
49
|
|
|
'translation_domain' => 'admin', |
50
|
|
|
'label' => 'admin.alias_overview_admin.label', |
51
|
|
|
'required' => false, |
52
|
|
|
'virtual' => true, |
53
|
|
|
] |
54
|
|
|
); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @{inheritDoc} |
59
|
|
|
*/ |
60
|
|
|
public function buildView(FormView $view, FormInterface $form, array $options) |
61
|
|
|
{ |
62
|
|
|
parent::buildView($view, $form, $options); |
63
|
|
|
$view->vars['record'] = $options['record']; |
64
|
|
|
$view->vars['url_aliases'] = $this->getUrlAliases($options['record']); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* Returns all UrlAlias entities associated to an object |
69
|
|
|
* |
70
|
|
|
* @param mixed $object |
71
|
|
|
*/ |
72
|
|
|
protected function getUrlAliases($object) |
73
|
|
|
{ |
74
|
|
|
try { |
75
|
|
|
$internalUrl = $this->provider->url($object); |
76
|
|
|
} catch (UnsupportedException $exception) { |
77
|
|
|
return []; |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
return $this->doctrine->getRepository('ZichtUrlBundle:UrlAlias') |
81
|
|
|
->findAllByInternalUrl($internalUrl); |
|
|
|
|
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* @{inheritDoc} |
86
|
|
|
*/ |
87
|
|
|
public function getName() |
88
|
|
|
{ |
89
|
|
|
return 'alias_overview_type'; |
90
|
|
|
} |
91
|
|
|
} |
92
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.