Ejemplo n.º 1
0
 /**
  * Return the name of the conversion method for the given alias or column name and context
  *
  * @param   array|string    $table      The datasource's table
  * @param   string          $name       The alias or column name for which to return a conversion method
  * @param   string          $context    The context of the conversion: persist or retrieve
  *
  * @return  string
  *
  * @throws  ProgrammingError    In case a conversion rule is found but not any conversion method
  */
 protected function getConverter($table, $name, $context)
 {
     if ($this->validateQueryColumnAssociation($table, $name) || $this->validateStatementColumnAssociation($table, $name)) {
         $table = $this->removeTablePrefix($this->clearTableAlias($table));
     } else {
         $table = $this->findTableName($name);
         if (!$table) {
             throw new ProgrammingError('Column name validation seems to have failed. Did you require the column?');
         }
     }
     return parent::getConverter($table, $name, $context);
 }
Ejemplo n.º 2
0
 /**
  * Return the name of the conversion method for the given alias or column name and context
  *
  * If a query column or a filter column, which is part of a query filter, needs to be converted,
  * you'll need to pass $query, otherwise the column is considered a statement column.
  *
  * @param   string              $table      The datasource's table
  * @param   string              $name       The alias or column name for which to return a conversion method
  * @param   string              $context    The context of the conversion: persist or retrieve
  * @param   RepositoryQuery     $query      If given the column is considered a query column,
  *                                          statement column otherwise
  *
  * @return  string
  *
  * @throws  ProgrammingError    In case a conversion rule is found but not any conversion method
  */
 protected function getConverter($table, $name, $context, RepositoryQuery $query = null)
 {
     if ($name instanceof Zend_Db_Expr) {
         return;
     }
     if (!($query !== null && $this->validateQueryColumnAssociation($table, $name)) && !($query === null && $this->validateStatementColumnAssociation($table, $name))) {
         $table = $this->findTableName($name);
         if (!$table) {
             if ($query !== null) {
                 // It may be an aliased Zend_Db_Expr
                 $desiredColumns = $query->getColumns();
                 if (isset($desiredColumns[$name]) && $desiredColumns[$name] instanceof Zend_Db_Expr) {
                     return;
                 }
             }
             throw new ProgrammingError('Column name validation seems to have failed. Did you require the column?');
         }
     }
     return parent::getConverter($table, $name, $context, $query);
 }
Ejemplo n.º 3
0
 /**
  * Return the name of the conversion method for the given alias or column name and context
  *
  * If a query column or a filter column, which is part of a query filter, needs to be converted,
  * you'll need to pass $query, otherwise the column is considered a statement column.
  *
  * @param   string              $table      The datasource's table
  * @param   string              $name       The alias or column name for which to return a conversion method
  * @param   string              $context    The context of the conversion: persist or retrieve
  * @param   RepositoryQuery     $query      If given the column is considered a query column,
  *                                          statement column otherwise
  *
  * @return  string
  *
  * @throws  ProgrammingError    In case a conversion rule is found but not any conversion method
  */
 protected function getConverter($table, $name, $context, RepositoryQuery $query = null)
 {
     if (!($query !== null && $this->validateQueryColumnAssociation($table, $name)) && !($query === null && $this->validateStatementColumnAssociation($table, $name))) {
         $table = $this->findTableName($name);
         if (!$table) {
             throw new ProgrammingError('Column name validation seems to have failed. Did you require the column?');
         }
     }
     return parent::getConverter($table, $name, $context, $query);
 }