Example #1
0
 /**
  * Create a new INI repository object
  *
  * @param   Config  $ds         The data source to use
  *
  * @throws  ProgrammingError    In case the given data source does not provide a valid key column
  */
 public function __construct(Config $ds)
 {
     parent::__construct($ds);
     // First! Due to init().
     if (!$ds->getConfigObject()->getKeyColumn()) {
         throw new ProgrammingError('INI repositories require their data source to provide a valid key column');
     }
 }
Example #2
0
 /**
  * Apply mode delete on the repository
  *
  * @return  bool
  */
 protected function onDeleteSuccess()
 {
     try {
         $this->repository->delete($this->repository->getBaseTable(), $this->createFilter());
     } catch (Exception $e) {
         Notification::error($this->getDeleteMessage(false));
         $this->error($e->getMessage());
         return false;
     }
     Notification::success($this->getDeleteMessage(true));
     return true;
 }
Example #3
0
 /**
  * Fetch and return the current row of this query's result
  *
  * @return  object
  */
 public function current()
 {
     $row = $this->iterator->current();
     if ($this->repository->providesValueConversion($this->target)) {
         foreach ($this->getColumns() as $alias => $column) {
             if (!is_string($alias)) {
                 $alias = $column;
             }
             $row->{$alias} = $this->repository->retrieveColumn($this->target, $alias, $row->{$alias}, $this);
         }
     }
     return $row;
 }
Example #4
0
 /**
  * {@inheritDoc}
  *
  * @return  Config
  */
 public function getDataSource($table = null)
 {
     if ($this->ds !== null) {
         return parent::getDataSource($table);
     }
     $table = $table ?: $this->getBaseTable();
     $configs = $this->getConfigs();
     if (!isset($configs[$table])) {
         throw new ProgrammingError('Config for table "%s" missing', $table);
     } elseif (!$configs[$table] instanceof Config) {
         $configs[$table] = $this->createConfig($configs[$table], $table);
     }
     if (!$configs[$table]->getConfigObject()->getKeyColumn()) {
         throw new ProgrammingError('INI repositories require their data source to provide a valid key column');
     }
     return $configs[$table];
 }
Example #5
0
 /**
  * Validate that the given column is a valid statement column and return it or the actual name if it's an alias
  *
  * @param   string  $table          The table for which to require the column
  * @param   string  $name           The name or alias of the column to validate
  *
  * @return  string                  The given column's name
  *
  * @throws  StatementException      In case the given column is not a statement column
  */
 public function requireStatementColumn($table, $name)
 {
     if (($column = $this->resolveStatementColumnAlias($table, $name)) !== null) {
         $alias = $name;
     } elseif (($alias = $this->reassembleStatementColumnAlias($table, $name)) !== null) {
         $column = $name;
     } else {
         return parent::requireStatementColumn($table, $name);
     }
     if (!$this->validateStatementColumnAssociation($table, $alias)) {
         throw new StatementException('Statement column "%s" not found in table "%s"', $name, $table);
     }
     return $column;
 }
Example #6
0
 /**
  * Create a new LDAP repository object
  *
  * @param   LdapConnection  $ds     The data source to use
  */
 public function __construct(LdapConnection $ds)
 {
     parent::__construct($ds);
 }
 /**
  * {@inheritdoc}
  */
 public function resolveQueryColumnAlias($table, $alias)
 {
     // TODO: Fixed in the current master. Remove this once a new release of Web 2 is out.
     if (is_int($alias)) {
         $queryColumns = $this->getQueryColumns();
         return $queryColumns[$table][$alias];
     }
     return parent::resolveQueryColumnAlias($table, $alias);
 }