Permalink
Browse files

Merge branch 'dev'

  • Loading branch information...
2 parents fcf34d8 + 7f6da57 commit 505c15800b8d8a8143950115f176a298df71b8bb @nateabele nateabele committed Dec 28, 2012
View
@@ -1,38 +0,0 @@
-You asked for a better framework. Here it is.
----------------------------------------------
-
-Lithium is the fast, flexible and most RAD development framework for PHP 5.3 and up.
-
-A framework of firsts
----------------------
-
-Lithium is the first and only major PHP framework built from the ground up for PHP 5.3+, and the first to break ground into major new technologies, including bridging the gap between relational and non-relational databases through a single, unified API.
-
-Promiscuously opinionated
--------------------------
-
-Some frameworks give you a solid set of classes, but little or no default project organization, leaving you to fend for yourself on each project you create, and spend time wiring up framework classes that should just work together. Others provide you with great organizational conventions, but no way to break out of those conventions if you need to, and too often, no way to override or replace core framework classes.
-
-Lithium is the first framework to give you the best of both worlds, without compromising either. In fact, Lithium's API is intentionally designed to allow you to "grow out of" the framework and into your own custom code over the course of your application's lifecycle, if your needs require.
-
-Technology
-----------
-
-Lithium takes full advantage of the latest PHP 5.3 features, including namespaces, late static binding and closures. Lithium's innovative [method filter system](http://lithify.me/docs/lithium/util/collection/Filters) makes extensive use of closures and anonymous functions to allow application developers to "wrap" framework method calls, intercepting parameters before, and return values after.
-
-Lithium also complies with the PHP 5.3 namespacing standard, allowing you to easily integrate other PHP 5.3 standard libraries and frameworks with Lithium applications, and vice-versa.
-
-Lithium integrates the latest storage technologies, including MongoDB, CouchDB and Redis, with plugin support for Cassandra, ElasticSearch and others.
-
-Flexibility
------------
-
-Lithium gives you full control over your application, from filters to dynamically modify framework internals, to dynamic dependencies to extend and replace core classes with application or plugin classes, to heavy use of adapter-oriented configurations, to make it seamless to move between different technologies and options.
-
-Every component of the Lithium framework stack is replaceable through the robust plugin architecture. Swap out the default ORM / ODM implementation for [Doctrine 2](https://github.com/mariano/li3_doctrine2/) or [PHP ActiveRecord](http://dev.lithify.me/li3_activerecord). Don't like the templating? Use [ Twig](http://dev.lithify.me/li3_twig), [ Mustache](https://github.com/bobthecow/mustache.php), or roll your own.
-
-If you don't even need to write a full application, build a micro-app in a single file using the routing system, without giving up the maintainability of the framework's structure.
-
-Build status
------------
-[![Build Status](https://secure.travis-ci.org/UnionOfRAD/lithium.png?branch=master)](http://travis-ci.org/UnionOfRAD/lithium)
View
@@ -74,6 +74,10 @@ public static function tokenize($code, array $options = array()) {
}
}
$tokens[] = array('id' => $id, 'name' => $name, 'content' => $content, 'line' => $line);
+
+ if ($id === T_WHITESPACE) {
+ $line += count(preg_split('/\r\n|\r|\n/', $content)) - 1;
+ }
}
if ($options['wrap'] && empty($options['include'])) {
View
@@ -11,6 +11,7 @@
use lithium\util\Set;
use lithium\data\Source;
use lithium\core\ConfigException;
+use InvalidArgumentException;
/**
* The `Query` class acts as a container for all information necessary to perform a particular
@@ -107,15 +108,6 @@ class Query extends \lithium\core\Object {
protected $_paths = array();
/**
- * Map beetween relation paths and their corresponding fieldname paths
- *
- * @see lithium\data\model\Query::alias()
- *
- * @var array
- */
- protected $_relationNames = array();
-
- /**
* Map beetween generated aliases and corresponding models.
*
* @see lithium\data\model\Query::alias()
@@ -518,11 +510,15 @@ public function data($data = array()) {
* @param array $config the config array to set.
* @return mixed The relationships array or a relationship array if `$relpath` is set. Returns
* `null` if a join doesn't exist.
+ * @throws InvalidArgumentException
*/
public function relationships($relpath = null, $config = null) {
if ($config) {
if (!$relpath) {
- throw new ConfigException("The relation dotted path is empty.");
+ throw new InvalidArgumentException("The relation dotted path is empty.");
+ }
+ if (isset($config['model']) && isset($config['alias'])) {
+ $this->_models[$config['alias']] = $config['model'];
}
$this->_config['relationships'][$relpath] = $config;
return $this;
@@ -699,26 +695,20 @@ public function alias($alias = true, $relpath = null) {
return $return ?: null;
}
- if ($relpath) {
- $oldAlias = array_search($relpath, $this->_paths);
- } else {
- $oldAlias = array_search('', $this->_paths);
+ if ($relpath === null) {
+ $this->_config['alias'] = $alias;
}
- unset($this->_models[$oldAlias]);
- unset($this->_paths[$oldAlias]);
-
- $model = $this->_config['model'];
- if (!$relpath) {
- $this->_alias[$alias] = 1;
+ if ($relpath === null && ($model = $this->_config['model'])) {
$this->_models[$alias] = $model;
- $this->_paths[$alias] = '';
- return $this->_config['alias'] = $alias;
}
- $paths = explode('.', $relpath);
- if (!$alias) {
- $alias = end($paths);
+ $relpath = (string) $relpath;
+ unset($this->_paths[array_search($relpath, $this->_paths)]);
+
+ if (!$alias && $relpath) {
+ $last = strrpos($relpath, '.');
+ $alias = $last ? substr($relpath, $last + 1) : $relpath;
}
if (isset($this->_alias[$alias])) {
@@ -729,35 +719,10 @@ public function alias($alias = true, $relpath = null) {
}
$this->_paths[$alias] = $relpath;
- $fieldname = array();
- foreach ($paths as $path) {
- if (!$relation = $model::relations($path)) {
- $model = null;
- break;
- }
- $fieldname[] = $relation->fieldName();
- $model = $relation->to();
- }
- $this->_models[$alias] = $model;
- $this->_relationNames[$relpath] = join('.', $fieldname);
return $alias;
}
/**
- * Return the relation paths mapped to their corredponding fieldname paths.
- *
- * @param object $source Instance of the data source (`lithium\data\Source`) to use for
- * conversion.
- * @return array Map between relation paths and their corresponding fieldname paths.
- */
- public function relationNames(Source $source = null) {
- if ($source) {
- $this->applyStrategy($source);
- }
- return $this->_relationNames;
- }
-
- /**
* Return the generated aliases mapped to their relation path
*
* @param object $source Instance of the data source (`lithium\data\Source`) to use for
View
@@ -213,8 +213,7 @@ public function __construct(array $config = array()) {
'type' => $rel->type(),
'model' => $rel->to(),
'fieldName' => $rel->fieldName(),
- 'fromAlias' => $from,
- 'toAlias' => $to
+ 'alias' => $to
));
$self->join($context, $rel, $from, $to, $constraints);
}
@@ -473,11 +472,10 @@ public function read($query, array $options = array()) {
case 'array':
$columns = $args['schema'] ?: $self->schema($query, $result);
- if (!isset($columns['']) || !is_array($columns[''])) {
+ if (!is_array(reset($columns))) {
$columns = array('' => $columns);
}
- $relationNames = is_object($query) ? $query->relationNames($self) : array();
$i = 0;
$records = array();
foreach ($result as $data) {
@@ -487,7 +485,7 @@ public function read($query, array $options = array()) {
$len = count($cols);
$values = array_combine($cols, array_slice($data, $offset, $len));
if ($path) {
- $records[$i][$relationNames[$path]] = $values;
+ $records[$i][$path] = $values;
} else {
$records[$i] += $values;
}
Oops, something went wrong.

0 comments on commit 505c158

Please sign in to comment.