Permalink
Browse files

fixed filterBy/findBy methods

added extra empty lines
  • Loading branch information...
1 parent 246b872 commit 0e25af20251a99035b2111f71078d613a5f70a0a @elvenpath committed Jul 31, 2012
@@ -4,3 +4,5 @@
return $this->getCurrentTranslation()->get<?php echo $columnPhpName ?>(<?php echo $params ?>);
}
+
+
@@ -5,3 +5,4 @@
return $this;
}
+
@@ -1,3 +1,4 @@
+
/**
* Filter the query on the slug column
*
@@ -8,9 +9,9 @@
*/
public function filterBySlug($slug, $culture = '<?php echo $defaultCulture ?>')
{
- return $this
- ->useI18nQuery($culture, '<?php echo $i18nRelationName?>')
- ->filterBy('<?php echo $cultureColumn ?>', $culture)
- ->filterBy('<?php echo $slugColumn?>', $slug)
- ->endUse();
-}
+ $this->joinI18n($culture, '<?php echo $i18nRelationName?>')
+ ->where('<?php echo $i18nRelationName?>.<?php echo $slugColumn?> = ?', $slug);
+
+ return $this;
+}
+
@@ -1,18 +1,17 @@
+
/**
* Find one object based on its slug
*
* @param string $slug The value to use as filter.
-* @param string $culture Cu;ture to use, e.g. 'en_GB'
+* @param string $culture Culture to use, e.g. 'en_GB'
* @param PropelPDO $con The optional connection object
*
* @return <?php echo $objectClassname?> the result, formatted by the current formatter
*/
public function findOneBySlug($slug, $culture = '<?php echo $defaultCulture ?>', $con = null)
{
- return $this
- ->useI18nQuery($culture, '<?php echo $i18nRelationName?>')
- ->filterBy('<?php echo $cultureColumn ?>', $culture)
- ->filterBy('<?php echo $slugColumn?>', $slug)
- ->endUse()
- ->findOne($con);
+ $this->joinI18n($culture, '<?php echo $i18nRelationName?>')
+ ->where('<?php echo $i18nRelationName?>.<?php echo $slugColumn?> = ?', $slug);
+
+ return $this->findOne($con);
}
@@ -8,10 +8,22 @@
*
* @return <?php echo $queryClass ?> The current query, for fluid interface
*/
-public function joinI18n($culture = '<?php echo $defaultCulture ?>', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+public function joinI18n($culture = null, $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
+ if (is_null($culture))
+ {
+ if (sfContext::hasInstance())
+ {
+ $culture = sfContext::getInstance()->getUser()->getCulture();
+ }
+ else
+ {
+ $culture = '<?php echo $defaultCulture ?>';
+ }
+ }
+
$relationName = $relationAlias ? $relationAlias : '<?php echo $i18nRelationName ?>';
- return $this
- ->join<?php echo $i18nRelationName ?>($relationAlias, $joinType)
+
+ return $this->join<?php echo $i18nRelationName ?>($relationAlias, $joinType)
->addJoinCondition($relationName, $relationName . '.<?php echo $cultureColumn ?> = ?', $culture);
}
@@ -8,11 +8,11 @@
*
* @return <?php echo $queryClass ?> The current query, for fluid interface
*/
-public function joinWithI18n($culture = '<?php echo $defaultCulture ?>', $joinType = Criteria::LEFT_JOIN)
+public function joinWithI18n($culture = null, $relationAlias = '<?php echo $i18nRelationName ?>', $joinType = Criteria::LEFT_JOIN)
{
- $this
- ->joinI18n($culture, null, $joinType)
- ->with('<?php echo $i18nRelationName ?>');
- $this->with['<?php echo $i18nRelationName ?>']->setIsWithOneToMany(false);
+ $this->joinI18n($culture, $relationAlias, $joinType)->with($relationAlias);
+
+ $this->with[$relationAlias]->setIsWithOneToMany(false);
+
return $this;
}
@@ -10,9 +10,12 @@
*
* @return <?php echo $queryClass ?> A secondary query class using the current class as primary query
*/
-public function useI18nQuery($culture = '<?php echo $defaultCulture ?>', $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
+public function useI18nQuery($culture = null, $relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
+ $relationAlias = $relationAlias ? $relationAlias : '<?php echo $i18nRelationName ?>';
+
return $this
->joinI18n($culture, $relationAlias, $joinType)
- ->useQuery($relationAlias ? $relationAlias : '<?php echo $i18nRelationName ?>', '<?php echo $namespacedQueryClass ?>');
+ ->useQuery($relationAlias, '<?php echo $namespacedQueryClass ?>');
}
+

0 comments on commit 0e25af2

Please sign in to comment.