Skip to content

Commit 6d9d460

Browse files
author
Hugo Hamon
committed
[Bridge] [Propel] minor improvements to the Propel bridge.
1 parent ff52a9f commit 6d9d460

File tree

14 files changed

+78
-67
lines changed

14 files changed

+78
-67
lines changed

src/Symfony/Bridge/Propel1/DataCollector/PropelDataCollector.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class PropelDataCollector extends DataCollector
2626
/**
2727
* Propel logger
2828
*
29-
* @var \Symfony\Bridge\Propel1\Logger\PropelLogger
29+
* @var PropelLogger
3030
*/
3131
private $logger;
3232

@@ -38,7 +38,7 @@ class PropelDataCollector extends DataCollector
3838
protected $propelConfiguration;
3939

4040
/**
41-
* Constructor
41+
* Constructor.
4242
*
4343
* @param PropelLogger $logger A Propel logger.
4444
* @param \PropelConfiguration $propelConfiguration The Propel configuration object.
@@ -63,17 +63,17 @@ public function collect(Request $request, Response $response, \Exception $except
6363
/**
6464
* Returns the collector name.
6565
*
66-
* @return string The collector name.
66+
* @return string
6767
*/
6868
public function getName()
6969
{
7070
return 'propel';
7171
}
7272

7373
/**
74-
* Returns queries.
74+
* Returns the collected stats for all executed SQL queries.
7575
*
76-
* @return array Queries
76+
* @return array
7777
*/
7878
public function getQueries()
7979
{
@@ -83,17 +83,17 @@ public function getQueries()
8383
/**
8484
* Returns the query count.
8585
*
86-
* @return int The query count
86+
* @return int
8787
*/
8888
public function getQueryCount()
8989
{
9090
return $this->data['querycount'];
9191
}
9292

9393
/**
94-
* Returns the total time of queries.
94+
* Returns the total time spent on running all queries.
9595
*
96-
* @return float The total time of queries
96+
* @return float
9797
*/
9898
public function getTime()
9999
{
@@ -106,9 +106,9 @@ public function getTime()
106106
}
107107

108108
/**
109-
* Creates an array of Build objects.
109+
* Computes the stats of all executed SQL queries.
110110
*
111-
* @return array An array of Build objects
111+
* @return array
112112
*/
113113
private function buildQueries()
114114
{
@@ -136,9 +136,9 @@ private function buildQueries()
136136
}
137137

138138
/**
139-
* Count queries.
139+
* Returns the total count of SQL queries.
140140
*
141-
* @return int The number of queries.
141+
* @return int
142142
*/
143143
private function countQueries()
144144
{

src/Symfony/Bridge/Propel1/DependencyInjection/Security/UserProvider/PropelFactory.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ class PropelFactory implements UserProviderFactoryInterface
2626
private $key;
2727
private $providerId;
2828

29+
/**
30+
* Constructor.
31+
*
32+
* @param string $key
33+
* @param string $providerId
34+
*/
2935
public function __construct($key, $providerId)
3036
{
3137
$this->key = $key;
@@ -38,7 +44,7 @@ public function create(ContainerBuilder $container, $id, $config)
3844
->setDefinition($id, new DefinitionDecorator($this->providerId))
3945
->addArgument($config['class'])
4046
->addArgument($config['property'])
41-
;
47+
;
4248
}
4349

4450
public function getKey()
@@ -50,9 +56,14 @@ public function addConfiguration(NodeDefinition $node)
5056
{
5157
$node
5258
->children()
53-
->scalarNode('class')->isRequired()->cannotBeEmpty()->end()
54-
->scalarNode('property')->defaultNull()->end()
59+
->scalarNode('class')
60+
->isRequired()
61+
->cannotBeEmpty()
62+
->end()
63+
->scalarNode('property')
64+
->defaultNull()
65+
->end()
5566
->end()
56-
;
67+
;
5768
}
5869
}

src/Symfony/Bridge/Propel1/Form/Type/ModelType.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,29 @@ class ModelType extends AbstractType
5555
*/
5656
private $propertyAccessor;
5757

58+
/**
59+
* Constructor.
60+
*
61+
* @param PropertyAccessorInterface|null $propertyAccessor
62+
*/
5863
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
5964
{
6065
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();
6166
}
6267

68+
/**
69+
* {@inheritdoc}
70+
*/
6371
public function buildForm(FormBuilderInterface $builder, array $options)
6472
{
6573
if ($options['multiple']) {
6674
$builder->addViewTransformer(new CollectionToArrayTransformer(), true);
6775
}
6876
}
6977

78+
/**
79+
* {@inheritdoc}
80+
*/
7081
public function setDefaultOptions(OptionsResolverInterface $resolver)
7182
{
7283
$propertyAccessor = $this->propertyAccessor;
@@ -97,11 +108,17 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
97108
));
98109
}
99110

111+
/**
112+
* {@inheritdoc}
113+
*/
100114
public function getParent()
101115
{
102116
return 'choice';
103117
}
104118

119+
/**
120+
* {@inheritdoc}
121+
*/
105122
public function getName()
106123
{
107124
return 'model';

src/Symfony/Bridge/Propel1/Form/Type/TranslationCollectionType.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Bridge\Propel1\Form\EventListener\TranslationCollectionFormListener;
1919

2020
/**
21-
* form type for i18n-columns in propel
21+
* Form type for i18n-columns in propel
2222
*
2323
* @author Patrick Kaufmann
2424
*/
@@ -40,6 +40,9 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4040
$builder->addEventSubscriber($listener);
4141
}
4242

43+
/**
44+
* {@inheritdoc}
45+
*/
4346
public function getParent()
4447
{
4548
return 'collection';

src/Symfony/Bridge/Propel1/Form/Type/TranslationType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Symfony\Bridge\Propel1\Form\EventListener\TranslationFormListener;
1818

1919
/**
20-
* Translation type class
20+
* Translation type class.
2121
*
2222
* @author Patrick Kaufmann
2323
*/

src/Symfony/Bridge/Propel1/Tests/DataCollector/PropelDataCollectorTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,19 @@ public function testCollectWithMultipleData()
9292
private function createCollector($queries)
9393
{
9494
$config = $this->getMock('\PropelConfiguration');
95+
9596
$config
9697
->expects($this->any())
9798
->method('getParameter')
9899
->will($this->returnArgument(1))
99-
;
100+
;
100101

101102
$logger = $this->getMock('\Symfony\Bridge\Propel1\Logger\PropelLogger');
102103
$logger
103104
->expects($this->any())
104105
->method('getQueries')
105106
->will($this->returnValue($queries))
106-
;
107+
;
107108

108109
return new PropelDataCollector($logger, $config);
109110
}

src/Symfony/Bridge/Propel1/Tests/Fixtures/Column.php

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
class Column
1515
{
1616
private $name;
17-
1817
private $type;
1918

2019
public function __construct($name, $type)
@@ -35,13 +34,13 @@ public function isText()
3534
}
3635

3736
switch ($this->type) {
38-
case \PropelColumnTypes::CHAR:
39-
case \PropelColumnTypes::VARCHAR:
40-
case \PropelColumnTypes::LONGVARCHAR:
41-
case \PropelColumnTypes::BLOB:
42-
case \PropelColumnTypes::CLOB:
43-
case \PropelColumnTypes::CLOB_EMU:
44-
return true;
37+
case \PropelColumnTypes::CHAR:
38+
case \PropelColumnTypes::VARCHAR:
39+
case \PropelColumnTypes::LONGVARCHAR:
40+
case \PropelColumnTypes::BLOB:
41+
case \PropelColumnTypes::CLOB:
42+
case \PropelColumnTypes::CLOB_EMU:
43+
return true;
4544
}
4645

4746
return false;
@@ -54,6 +53,6 @@ public function getSize()
5453

5554
public function isNotNull()
5655
{
57-
return ('id' === $this->name);
56+
return 'id' === $this->name;
5857
}
5958
}

src/Symfony/Bridge/Propel1/Tests/Fixtures/Item.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@
1111

1212
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
1313

14-
use PropelPDO;
15-
1614
class Item implements \Persistent
1715
{
1816
private $id;
19-
2017
private $value;
21-
2218
private $groupName;
23-
2419
private $price;
2520

2621
public function __construct($id = null, $value = null, $groupName = null, $price = null)
@@ -98,11 +93,11 @@ public function setDeleted($b)
9893
{
9994
}
10095

101-
public function delete(PropelPDO $con = null)
96+
public function delete(\PropelPDO $con = null)
10297
{
10398
}
10499

105-
public function save(PropelPDO $con = null)
100+
public function save(\PropelPDO $con = null)
106101
{
107102
}
108103
}

src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItem.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,11 @@
1111

1212
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
1313

14-
use PropelPDO;
15-
1614
class TranslatableItem implements \Persistent
1715
{
1816
private $id;
19-
2017
private $currentTranslations;
21-
2218
private $groupName;
23-
2419
private $price;
2520

2621
public function __construct($id = null, $translations = array())
@@ -91,15 +86,15 @@ public function setDeleted($b)
9186
{
9287
}
9388

94-
public function delete(PropelPDO $con = null)
89+
public function delete(\PropelPDO $con = null)
9590
{
9691
}
9792

98-
public function save(PropelPDO $con = null)
93+
public function save(\PropelPDO $con = null)
9994
{
10095
}
10196

102-
public function getTranslation($locale = 'de', PropelPDO $con = null)
97+
public function getTranslation($locale = 'de', \PropelPDO $con = null)
10398
{
10499
if (!isset($this->currentTranslations[$locale])) {
105100
$translation = new TranslatableItemI18n();

src/Symfony/Bridge/Propel1/Tests/Fixtures/TranslatableItemI18n.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,12 @@
1111

1212
namespace Symfony\Bridge\Propel1\Tests\Fixtures;
1313

14-
use PropelPDO;
15-
1614
class TranslatableItemI18n implements \Persistent
1715
{
1816
private $id;
19-
2017
private $locale;
21-
2218
private $value;
23-
2419
private $value2;
25-
2620
private $item;
2721

2822
public function __construct($id = null, $locale = null, $value = null)
@@ -84,11 +78,11 @@ public function setDeleted($b)
8478
{
8579
}
8680

87-
public function delete(PropelPDO $con = null)
81+
public function delete(\PropelPDO $con = null)
8882
{
8983
}
9084

91-
public function save(PropelPDO $con = null)
85+
public function save(\PropelPDO $con = null)
9286
{
9387
}
9488

0 commit comments

Comments
 (0)