merged branch willdurand/woodspire-master (PR #6199)
This PR was merged into the master branch. Commits -------a3a832c
Fix CS in the whole Propel1 bridge86ab4b3
Add typehint to isInteger(), fix testsa26a690
remove useless ColumnMapffd8759
fix some formatting issue6fb9536
fix indentation probleme5e3341
oups. It seems that here, we need \PDO36d6c40
fix indentation problem6f8cd9d
Removed the PropelColumnTypes.php copy8125163
removed the TODO mention. Will keep the Propel code here so it can work with older version of Propel0e4419b
I found the error in my latest commit. This pass the test suite.cf8a6c0
Fix my code and also fix the test suite.737b596
Merge remote-tracking branch 'upstream/master'972e503
Fix problem when 1 column identifier in propel is a string. Discussion ---------- Fix ModelChoiceList problem with string key Replaces #6150 --------------------------------------------------------------------------- by willdurand at 2012-12-05T20:51:44Z Note that 5f54ed1 is a "CS fix" commit. I don't want to open a PR just for that. Let me know if I should to remove it. Also, I'm 👍 on this PR. Review has been made already, so it seems mergeable.
This commit is contained in:
commit
bf6d9be27d
@ -63,7 +63,7 @@ class PropelDataCollector extends DataCollector
|
||||
/**
|
||||
* Returns the collector name.
|
||||
*
|
||||
* @return string The collector name.
|
||||
* @return string The collector name.
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
@ -73,7 +73,7 @@ class PropelDataCollector extends DataCollector
|
||||
/**
|
||||
* Returns queries.
|
||||
*
|
||||
* @return array Queries
|
||||
* @return array Queries
|
||||
*/
|
||||
public function getQueries()
|
||||
{
|
||||
@ -83,7 +83,7 @@ class PropelDataCollector extends DataCollector
|
||||
/**
|
||||
* Returns the query count.
|
||||
*
|
||||
* @return int The query count
|
||||
* @return int The query count
|
||||
*/
|
||||
public function getQueryCount()
|
||||
{
|
||||
@ -93,7 +93,7 @@ class PropelDataCollector extends DataCollector
|
||||
/**
|
||||
* Returns the total time of queries.
|
||||
*
|
||||
* @return float The total time of queries
|
||||
* @return float The total time of queries
|
||||
*/
|
||||
public function getTime()
|
||||
{
|
||||
@ -108,7 +108,7 @@ class PropelDataCollector extends DataCollector
|
||||
/**
|
||||
* Creates an array of Build objects.
|
||||
*
|
||||
* @return array An array of Build objects
|
||||
* @return array An array of Build objects
|
||||
*/
|
||||
private function buildQueries()
|
||||
{
|
||||
@ -138,7 +138,7 @@ class PropelDataCollector extends DataCollector
|
||||
/**
|
||||
* Count queries.
|
||||
*
|
||||
* @return int The number of queries.
|
||||
* @return int The number of queries.
|
||||
*/
|
||||
private function countQueries()
|
||||
{
|
||||
|
@ -45,6 +45,13 @@ class ModelChoiceList extends ObjectChoiceList
|
||||
*/
|
||||
private $loaded = false;
|
||||
|
||||
/**
|
||||
* Whether to use the identifier for index generation
|
||||
*
|
||||
* @var Boolean
|
||||
*/
|
||||
private $identifierAsIndex = false;
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
* @param string $labelPath
|
||||
@ -69,6 +76,10 @@ class ModelChoiceList extends ObjectChoiceList
|
||||
$choices = array();
|
||||
}
|
||||
|
||||
if (1 === count($this->identifier) && $this->isInteger(current($this->identifier))) {
|
||||
$this->identifierAsIndex = true;
|
||||
}
|
||||
|
||||
parent::__construct($choices, $labelPath, array(), $groupPath);
|
||||
}
|
||||
|
||||
@ -224,7 +235,7 @@ class ModelChoiceList extends ObjectChoiceList
|
||||
// know that the IDs are used as indices
|
||||
|
||||
// Attention: This optimization does not check choices for existence
|
||||
if (1 === count($this->identifier)) {
|
||||
if ($this->identifierAsIndex) {
|
||||
$indices = array();
|
||||
|
||||
foreach ($models as $model) {
|
||||
@ -259,7 +270,7 @@ class ModelChoiceList extends ObjectChoiceList
|
||||
// know that the IDs are used as indices and values
|
||||
|
||||
// Attention: This optimization does not check values for existence
|
||||
if (1 === count($this->identifier)) {
|
||||
if ($this->identifierAsIndex) {
|
||||
return $this->fixIndices($values);
|
||||
}
|
||||
|
||||
@ -283,7 +294,7 @@ class ModelChoiceList extends ObjectChoiceList
|
||||
*/
|
||||
protected function createIndex($model)
|
||||
{
|
||||
if (1 === count($this->identifier)) {
|
||||
if ($this->identifierAsIndex) {
|
||||
return current($this->getIdentifierValues($model));
|
||||
}
|
||||
|
||||
@ -336,7 +347,8 @@ class ModelChoiceList extends ObjectChoiceList
|
||||
* exception is thrown.
|
||||
*
|
||||
* @param object $model The model for which to get the identifier
|
||||
* @throws FormException If the model does not exist
|
||||
*
|
||||
* @throws FormException If the model does not exist
|
||||
*/
|
||||
private function getIdentifierValues($model)
|
||||
{
|
||||
@ -351,4 +363,16 @@ class ModelChoiceList extends ObjectChoiceList
|
||||
|
||||
return $model->getPrimaryKeys();
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this column in an integer
|
||||
*
|
||||
* @param ColumnMap $column
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
private function isInteger(\ColumnMap $column)
|
||||
{
|
||||
return $column->getPdoType() === \PDO::PARAM_INT;
|
||||
}
|
||||
}
|
||||
|
@ -89,7 +89,7 @@ class TranslationCollectionFormListener implements EventSubscriberInterface
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!$foundData) {
|
||||
if (!$foundData) {
|
||||
throw new UnexpectedTypeException($rootData, 'Propel i18n object');
|
||||
}
|
||||
|
||||
|
@ -161,7 +161,7 @@ class PropelLogger
|
||||
/**
|
||||
* Returns queries.
|
||||
*
|
||||
* @return array Queries
|
||||
* @return array Queries
|
||||
*/
|
||||
public function getQueries()
|
||||
{
|
||||
|
@ -31,7 +31,10 @@ class ItemQuery
|
||||
|
||||
public function getPrimaryKeys()
|
||||
{
|
||||
return array('id');
|
||||
$cm = new \ColumnMap('id', new \TableMap());
|
||||
$cm->setType('INTEGER');
|
||||
|
||||
return array('id' => $cm);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,6 +22,9 @@ class ReadOnlyItemQuery
|
||||
|
||||
public function getPrimaryKeys()
|
||||
{
|
||||
return array('id');
|
||||
$cm = new \ColumnMap('id', new \TableMap());
|
||||
$cm->setType('INTEGER');
|
||||
|
||||
return array('id' => $cm);
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +112,7 @@ class TranslatableItem implements \Persistent
|
||||
|
||||
public function addTranslatableItemI18n(TranslatableItemI18n $i)
|
||||
{
|
||||
if(!in_array($i, $this->currentTranslations))
|
||||
{
|
||||
if (!in_array($i, $this->currentTranslations)) {
|
||||
$this->currentTranslations[$i->getLocale()] = $i;
|
||||
$i->setItem($this);
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace Symfony\Bridge\Propel1\Tests\Fixtures;
|
||||
|
||||
use PropelPDO;
|
||||
|
||||
class TranslatableItemI18n implements \Persistent {
|
||||
|
||||
class TranslatableItemI18n implements \Persistent
|
||||
{
|
||||
private $id;
|
||||
|
||||
private $locale;
|
||||
@ -100,7 +100,6 @@ class TranslatableItemI18n implements \Persistent {
|
||||
|
||||
public function getLocale()
|
||||
{
|
||||
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
@ -122,7 +121,6 @@ class TranslatableItemI18n implements \Persistent {
|
||||
|
||||
public function getValue()
|
||||
{
|
||||
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
@ -134,7 +132,6 @@ class TranslatableItemI18n implements \Persistent {
|
||||
|
||||
public function getValue2()
|
||||
{
|
||||
|
||||
return $this->value2;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user