public function staticAttributes($builder)
 {
     $tableName = $this->table->getName();
     $col = '';
     if ($this->behavior->useScope()) {
         if ($this->behavior->hasMultipleScopes()) {
             foreach ($this->behavior->getScopes() as $scope) {
                 $col[] = "{$tableName}." . strtoupper($scope);
             }
             $col = json_encode($col);
             $col = "'{$col}'";
         } else {
             $colNames = $this->getColumnConstant('scope_column');
             $col = "'{$tableName}.{$colNames}'";
         }
     }
     return $this->behavior->renderTemplate('tableMapSortable', array('rankColumn' => $this->getColumnConstant('rank_column'), 'multiScope' => $this->behavior->hasMultipleScopes(), 'scope' => $col, 'tableName' => $this->table->getName(), 'useScope' => $this->behavior->useScope()));
 }
 public function addSortableApplyScopeCriteria(&$script)
 {
     $script .= "\n/**\n * Applies all scope fields to the given criteria.\n *\n * @param  Criteria \$criteria Applies the values directly to this criteria.\n * @param  mixed    \$scope    The scope value as scalar type or array(\$value1, ...).\n * @param  string   \$method   The method we use to apply the values.\n *\n */\npublic static function sortableApplyScopeCriteria(Criteria \$criteria, \$scope, \$method = 'add')\n{\n";
     if ($this->behavior->hasMultipleScopes()) {
         foreach ($this->behavior->getScopes() as $idx => $scope) {
             $script .= "\n    \$criteria->\$method({$this->peerClassname}::" . strtoupper($scope) . ", \$scope[{$idx}], Criteria::EQUAL);\n";
         }
     } else {
         $script .= "\n    \$criteria->\$method({$this->peerClassname}::" . strtoupper(current($this->behavior->getScopes())) . ", \$scope, Criteria::EQUAL);\n";
     }
     $script .= "\n}\n";
 }
 /**
  * Get the wraps for getter/setter, if the scope column has not the default name
  *
  * @return string
  */
 protected function addScopeAccessors(&$script)
 {
     $script .= "\n/**\n * Wrap the getter for scope value\n *\n * @param boolean \$returnNulls If true and all scope values are null, this will return null instead of a array full with nulls\n *\n * @return    mixed A array or a native type\n */\npublic function getScopeValue(\$returnNulls = true)\n{\n";
     if ($this->behavior->hasMultipleScopes()) {
         $script .= "\n    \$result = array();\n    \$onlyNulls = true;\n";
         foreach ($this->behavior->getScopes() as $scopeField) {
             $script .= "\n    \$onlyNulls &= null === (\$result[] = \$this->{$this->behavior->getColumnGetter($scopeField)}());\n";
         }
         $script .= "\n\n    return \$onlyNulls && \$returnNulls ? null : \$result;\n";
     } else {
         $script .= "\n\n    return \$this->{$this->getColumnGetter('scope_column')}();\n";
     }
     $script .= "\n}\n\n/**\n * Wrap the setter for scope value\n *\n * @param     mixed A array or a native type\n * @return    {$this->objectClassName}\n */\npublic function setScopeValue(\$v)\n{\n";
     if ($this->behavior->hasMultipleScopes()) {
         foreach ($this->behavior->getScopes() as $idx => $scopeField) {
             $script .= "\n    \$this->{$this->behavior->getColumnSetter($scopeField)}(\$v === null ? null : \$v[{$idx}]);\n";
         }
     } else {
         $script .= "\n\n    return \$this->{$this->getColumnSetter('scope_column')}(\$v);\n";
     }
     $script .= "\n}\n";
 }