protected function addGetPrevious(&$script) { $useScope = $this->behavior->useScope(); // The generateScopePhp() method below contains the following list of variables: // list($methodSignature, $paramsDoc, $buildScope, $buildScopeVars) list($methodSignature, , , $buildScopeVars) = $this->behavior->generateScopePhp(); $script .= "\n/**\n * Get the previous item in the list, i.e. the one for which rank is immediately lower\n *\n * @param ConnectionInterface \$con optional connection\n *\n * @return {$this->objectClassName}\n */\npublic function getPrevious(ConnectionInterface \$con = null)\n{"; $script .= "\n\n \$query = {$this->queryClassName}::create();\n"; if ($useScope) { $methodSignature = str_replace(' = null', '', $methodSignature); $script .= "\n \$scope = \$this->getScopeValue();\n {$buildScopeVars}\n \$query->filterByRank(\$this->{$this->getColumnGetter()}() - 1, {$methodSignature});\n"; } else { $script .= "\n \$query->filterByRank(\$this->{$this->getColumnGetter()}() - 1);\n"; } $script .= "\n\n return \$query->findOne(\$con);\n}\n"; }