Skip to content

Commit

Permalink
Merge pull request #1 from cakephp/3.0
Browse files Browse the repository at this point in the history
3.0
  • Loading branch information
cameri committed Oct 28, 2013
2 parents f8bcdfc + 6468c55 commit 1521dad
Show file tree
Hide file tree
Showing 62 changed files with 2,770 additions and 5,205 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,11 @@ Check the [cakephp-codesniffer](https://github.com/cakephp/cakephp-codesniffer)
repository to setup the CakePHP standard. The README contains installation info
for the sniff and phpcs.


# Additional Resources

* [CakePHP coding standards](http://book.cakephp.org/2.0/en/contributing/cakephp-coding-conventions.html)
* [Existing issues](https://github.com/cakephp/cakephp/issues)
* [Development Roadmap](https://github.com/cakephp/cakephp/wiki/3.0-Roadmap)
* [General GitHub documentation](https://help.github.com/)
* [GitHub pull request documentation](https://help.github.com/send-pull-requests/)
* #cakephp IRC channel on freenode.org
2 changes: 1 addition & 1 deletion Cake/Cache/Engine/MemcachedEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function init($settings = array()) {
/**
* Settings the memcached instance
*
* @throws CacheException when the Memcached extension is not built with the desired serializer engine
* @throws Cake\Error\Exception when the Memcached extension is not built with the desired serializer engine
*/
protected function _setOptions() {
$this->_Memcached->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
Expand Down
225 changes: 0 additions & 225 deletions Cake/Console/Command/ApiShell.php

This file was deleted.

2 changes: 1 addition & 1 deletion Cake/Core/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* You can inspect the currently loaded paths using `App::path('Controller')` for example to see loaded
* controller paths.
*
* It is also possible to inspect paths for plugin classes, for instance, to get
* It is also possible to inspect paths for plugin classes, for instance, to get
* the path to a plugin's helpers you would call `App::path('View/Helper', 'MyPlugin')`
*
* ### Locating plugins and themes
Expand Down
56 changes: 54 additions & 2 deletions Cake/Database/ConnectionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ class ConnectionManager {
*/
protected static $_config = [];

/**
* A map of connection aliases.
*
* @var array
*/
protected static $_aliasMap = [];

/**
* The ConnectionRegistry used by the manager.
*
Expand All @@ -71,17 +78,62 @@ public static function config($key, $config = null) {
return static::_config($key, $config);
}

/**
* Set one or more connection aliases.
*
* Connection aliases allow you to rename active connections without overwriting
* the aliased connection. This is most useful in the testsuite for replacing
* connections with their test variant.
*
* Defined aliases will take precedence over normal connection names. For example,
* if you alias 'default' to 'test', fetching 'default' will always return the 'test'
* connection as long as the alias is defined.
*
* You can remove aliases with ConnectionManager::dropAlias().
*
* @param string $from The connection to add an alias to.
* @param string $to The alias to create. $from should return when loaded with get().
* @return void
* @throws Cake\Error\MissingDatasourceConfigException When aliasing a connection that does not exist.
*/
public static function alias($from, $to) {
if (empty(static::$_config[$to]) && empty(static::$_config[$from])) {
throw new Error\MissingDatasourceConfigException(
__d('cake_dev', 'Cannot create alias of "%s" as it does not exist.', $from)
);
}
static::$_aliasMap[$to] = $from;
}

/**
* Drop an alias.
*
* Removes an alias from ConnectionManager. Fetching the aliased
* connection may fail if there is no other connection with that name.
*
* @param string $name The connection name to remove aliases for.
* @return void
*/
public static function dropAlias($name) {
unset(static::$_aliasMap[$name]);
}

/**
* Get a connection.
*
* If the connection has not been constructed an instance will be added
* to the registry.
* to the registry. This method will use any aliases that have been
* defined. If you want the original unaliased connections use getOriginal()
*
* @param string $name The connection name.
* @param boolean $useAliases Set to false to not use aliased connections.
* @return Connection A connection object.
* @throws Cake\Error\MissingDatasourceConfigException When config data is missing.
*/
public static function get($name) {
public static function get($name, $useAliases = true) {
if ($useAliases && isset(static::$_aliasMap[$name])) {
$name = static::$_aliasMap[$name];
}
if (empty(static::$_config[$name])) {
throw new Error\MissingDatasourceConfigException(['name' => $name]);
}
Expand Down
48 changes: 0 additions & 48 deletions Cake/Database/Dialect/PostgresDialectTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,57 +52,9 @@ trait PostgresDialectTrait {
* @return Cake\Database\Query
*/
protected function _selectQueryTranslator($query) {
$limit = $query->clause('limit');
$offset = $query->clause('offset');
$order = $query->clause('order');

if ($limit || $offset) {
$query = clone $query;
$field = '_cake_paging_._cake_page_rownum_';
$outer = (new Query($query->connection()))
->select('*')
->from(['_cake_paging_' => $query]);

if ($offset) {
$outer->where(["$field >" => $offset]);
}
if ($limit) {
$outer->where(["$field <=" => (int)$offset + (int)$limit]);
}

if ($order === null) {
$order = new OrderByExpression('NULL');
}

$query
->select(['_cake_page_rownum_' => new UnaryExpression($order, [], 'ROW_NUMBER() OVER')])
->limit(null)
->offset(null)
->order([], true);
return $outer->decorateResults($this->_rowNumberRemover());
}

return $query;
}

/**
* Returns a function that will be used as a callback for a results decorator.
* this function is responsible for deleting the artificial column in results
* used for paginating the query.
*
* @return \Closure
*/
protected function _rowNumberRemover() {
return function($row) {
if (isset($row['_cake_page_rownum_'])) {
unset($row['_cake_page_rownum_']);
} else {
array_pop($row);
}
return $row;
};
}

/**
* Returns an dictionary of expressions to be transformed when compiling a Query
* to SQL. Array keys are method names to be called in this class
Expand Down

0 comments on commit 1521dad

Please sign in to comment.