Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

sortable behavior: improved shiftRank() to not require $first node pa…

…rameter
  • Loading branch information...
commit 4c3cf042943161f79fd700c402957209feaa459c 1 parent 924839c
@rozwell rozwell authored
View
14 generator/lib/behavior/sortable/SortableBehaviorPeerBuilderModifier.php
@@ -50,6 +50,7 @@ protected function setBuilder($builder)
$this->builder = $builder;
$this->objectClassname = $builder->getStubObjectBuilder()->getClassname();
$this->peerClassname = $builder->getStubPeerBuilder()->getClassname();
+ $this->queryClassname = $builder->getStubQueryBuilder()->getClassname();
}
public function staticAttributes($builder)
@@ -338,18 +339,19 @@ protected function addShiftRank(&$script)
$script .= "
* @param PropelPDO \$con Connection to use.
*/
-public static function shiftRank(\$delta, \$first, \$last = null, " . ($useScope ? "\$scope = null, " : "") . "PropelPDO \$con = null)
+public static function shiftRank(\$delta, \$first = null, \$last = null, " . ($useScope ? "\$scope = null, " : "") . "PropelPDO \$con = null)
{
if (\$con === null) {
\$con = Propel::getConnection($peerClassname::DATABASE_NAME, Propel::CONNECTION_WRITE);
}
- \$whereCriteria = new Criteria($peerClassname::DATABASE_NAME);
- \$criterion = \$whereCriteria->getNewCriterion($peerClassname::RANK_COL, \$first, Criteria::GREATER_EQUAL);
- if (null !== \$last) {
- \$criterion->addAnd(\$whereCriteria->getNewCriterion($peerClassname::RANK_COL, \$last, Criteria::LESS_EQUAL));
+ \$whereCriteria = {$this->queryClassname}::create();

When we use namespaces the {$this->queryClassname} does not build the full namesapce class and the use for this class is not added on the top of the file. So i've a fatal when i try to delete my object

@willdurand Owner

weird because there is:

$builder->declareClassFromBuilder($builder->getStubQueryBuilder());
@jaugustin Collaborator

@cedriclombardot could you give us more information and create an issue ?

could you provide the stacktrace, schema, ... to reproduce your issue ?

Well I ve :

 <table name="tool">
        <column name="id" type="integer" primaryKey="true" required="true" autoIncrement="true" description="id, primary key" />
        <column name="category_id" type="integer" required="true" description="the tool category" />
        <column name="name" type="varchar" size="300" required="false" description="The tool title" />
        <column name="small_description" type="varchar" size="500" required="false" description="The tool small description" />
        <column name="description" type="longvarchar" required="false" description="The tool description" />
        <column name="type" type="enum" required="true" valueSet="active, add, soon, vote" default="vote" description="The tool type" />
        <column name="image" type="varchar" required="false" description="The tool picture thumb" />
        <column name="image_thumb" type="varchar" required="false" description="The tool picture" />
        <column name="functionalities" type="array" required="false" description="The functionnalities" />
        <column name="price" type="float" required="false" description="The tool price" />
        <column name="website_poll" type="varchar" required="false" description="The tool poll website" />
        <column name="note" type="float" required="true" default="3.5" description="The tool note" />

        <foreign-key foreignTable="tool_category" onUpdate="cascade" onDelete="cascade" phpName="Category">
            <reference local="category_id" foreign="id" />
        </foreign-key>

        <behavior name="sortable" />

        <behavior name="sluggable">
            <parameter name="slug_pattern" value="{Name}" />
            <parameter name="permanent" value="true" />
        </behavior>
    </table>

And it generate BaseToolPeer

public static function shiftRank($delta, $first = null, $last = null, PropelPDO $con = null)
{
.....
$whereCriteria = ToolQuery::create();
.....

But not add ToolQuery in use statements

Any news ?

@jaugustin Collaborator

@cedriclombardot no news, sorry, could you create an issue for this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ if (null !== \$first) {
+ \$whereCriteria->add($peerClassname::RANK_COL, \$first, Criteria::GREATER_EQUAL);
}
- \$whereCriteria->add(\$criterion);";
+ if (null !== \$last) {
+ \$whereCriteria->add($peerClassname::RANK_COL, \$last, Criteria::LESS_EQUAL);
+ }";
if ($useScope) {
$script .= "
\$whereCriteria->add($peerClassname::SCOPE_COL, \$scope, Criteria::EQUAL);";
@cedriclombardot

When we use namespaces the {$this->queryClassname} does not build the full namesapce class and the use for this class is not added on the top of the file. So i've a fatal when i try to delete my object

@willdurand

weird because there is:

$builder->declareClassFromBuilder($builder->getStubQueryBuilder());
@jaugustin

@cedriclombardot could you give us more information and create an issue ?

could you provide the stacktrace, schema, ... to reproduce your issue ?

@cedriclombardot

Well I ve :

 <table name="tool">
        <column name="id" type="integer" primaryKey="true" required="true" autoIncrement="true" description="id, primary key" />
        <column name="category_id" type="integer" required="true" description="the tool category" />
        <column name="name" type="varchar" size="300" required="false" description="The tool title" />
        <column name="small_description" type="varchar" size="500" required="false" description="The tool small description" />
        <column name="description" type="longvarchar" required="false" description="The tool description" />
        <column name="type" type="enum" required="true" valueSet="active, add, soon, vote" default="vote" description="The tool type" />
        <column name="image" type="varchar" required="false" description="The tool picture thumb" />
        <column name="image_thumb" type="varchar" required="false" description="The tool picture" />
        <column name="functionalities" type="array" required="false" description="The functionnalities" />
        <column name="price" type="float" required="false" description="The tool price" />
        <column name="website_poll" type="varchar" required="false" description="The tool poll website" />
        <column name="note" type="float" required="true" default="3.5" description="The tool note" />

        <foreign-key foreignTable="tool_category" onUpdate="cascade" onDelete="cascade" phpName="Category">
            <reference local="category_id" foreign="id" />
        </foreign-key>

        <behavior name="sortable" />

        <behavior name="sluggable">
            <parameter name="slug_pattern" value="{Name}" />
            <parameter name="permanent" value="true" />
        </behavior>
    </table>

And it generate BaseToolPeer

public static function shiftRank($delta, $first = null, $last = null, PropelPDO $con = null)
{
.....
$whereCriteria = ToolQuery::create();
.....

But not add ToolQuery in use statements

@jaugustin

@cedriclombardot no news, sorry, could you create an issue for this ?

Please sign in to comment.
Something went wrong with that request. Please try again.