Ejemplo n.º 1
0
 /**
  * PropelChoiceListLoader constructor.
  *
  * @param ChoiceListFactoryInterface $factory
  * @param string                     $class
  */
 public function __construct(ChoiceListFactoryInterface $factory, $class, ModelCriteria $queryObject, $useAsIdentifier = null)
 {
     $this->factory = $factory;
     $this->class = $class;
     $this->query = $queryObject;
     if ($useAsIdentifier) {
         $this->identifier = array($this->query->getTableMap()->getColumn($useAsIdentifier));
     } else {
         $this->identifier = $this->query->getTableMap()->getPrimaryKeys();
     }
     if (1 === count($this->identifier) && $this->isScalar(current($this->identifier))) {
         $this->identifierAsIndex = true;
     }
 }
Ejemplo n.º 2
0
 public static function getBackEndI18n(ModelCriteria &$search, $requestedLocale, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID')
 {
     if ($foreignTable === null) {
         $foreignTable = $search->getTableMap()->getName();
         $aliasPrefix = '';
     } else {
         $aliasPrefix = $foreignTable . '_';
     }
     $requestedLocaleI18nAlias = $aliasPrefix . 'requested_locale_i18n';
     $requestedLocaleJoin = new Join();
     $requestedLocaleJoin->addExplicitCondition($search->getTableMap()->getName(), $foreignKey, null, $foreignTable . '_i18n', 'ID', $requestedLocaleI18nAlias);
     $requestedLocaleJoin->setJoinType(Criteria::LEFT_JOIN);
     $search->addJoinObject($requestedLocaleJoin, $requestedLocaleI18nAlias)->addJoinCondition($requestedLocaleI18nAlias, '`' . $requestedLocaleI18nAlias . '`.LOCALE = ?', $requestedLocale, null, \PDO::PARAM_STR);
     $search->withColumn('NOT ISNULL(`' . $requestedLocaleI18nAlias . '`.`ID`)', $aliasPrefix . 'IS_TRANSLATED');
     foreach ($columns as $column) {
         $search->withColumn('`' . $requestedLocaleI18nAlias . '`.`' . $column . '`', $aliasPrefix . 'i18n_' . $column);
     }
 }
Ejemplo n.º 3
0
 public function paginate(ModelCriteria $query, $page = 1, $maxPerPage = 25)
 {
     $queryMd5 = md5($query->toString());
     $key = $query->getTableMap()->getName() . '_query_' . $queryMd5 . '_' . $page . '_' . $maxPerPage;
     $records = GlobalCache::get($key);
     if (empty($records) === true) {
         $records = $query->paginate($page, $maxPerPage);
         if ($records->isEmpty() === false) {
             GlobalCache::set($key, $records);
         }
     }
     return $records;
 }
Ejemplo n.º 4
0
 /**
  * @param \Propel\Runtime\ActiveQuery\ModelCriteria $query
  * @param \Spryker\Zed\Gui\Communication\Table\TableConfiguration $config
  *
  * @return array
  */
 protected function getColumnsList(ModelCriteria $query, TableConfiguration $config)
 {
     if ($config->getHeader()) {
         return array_keys($config->getHeader());
     }
     return array_keys($query->getTableMap()->getColumns());
 }