mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 11:06:15 +00:00
Merge branch '2.0' into 2.0-console
This commit is contained in:
commit
84a8dbd85a
3 changed files with 58 additions and 25 deletions
|
@ -831,8 +831,13 @@ class Model extends Object {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (is_object($one)) {
|
if (is_object($one)) {
|
||||||
|
if ($one instanceof SimpleXMLElement || $one instanceof DOMNode) {
|
||||||
|
App::import('Core', 'Xml');
|
||||||
|
$one = $this->_normalizeXmlData(Xml::toArray($one));
|
||||||
|
} else {
|
||||||
$one = Set::reverse($one);
|
$one = Set::reverse($one);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (is_array($one)) {
|
if (is_array($one)) {
|
||||||
$data = $one;
|
$data = $one;
|
||||||
|
@ -868,6 +873,26 @@ class Model extends Object {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalize Xml::toArray() to use in Model::save()
|
||||||
|
*
|
||||||
|
* @param array $xml XML as array
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function _normalizeXmlData(array $xml) {
|
||||||
|
$return = array();
|
||||||
|
foreach ($xml as $key => $value) {
|
||||||
|
if (is_array($value)) {
|
||||||
|
$return[Inflector::camelize($key)] = $this->_normalizeXmlData($value);
|
||||||
|
} elseif ($key[0] === '@') {
|
||||||
|
$return[substr($key, 1)] = $value;
|
||||||
|
} else {
|
||||||
|
$return[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $return;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deconstructs a complex data type (array or object) into a single field value.
|
* Deconstructs a complex data type (array or object) into a single field value.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1019,12 +1019,20 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
App::import('Core', 'Xml');
|
App::import('Core', 'Xml');
|
||||||
|
|
||||||
$Article = new Article();
|
$Article = new Article();
|
||||||
$Article->save(new Xml('<article title="test xml" user_id="5" />'));
|
$result = $Article->save(Xml::build('<article title="test xml" user_id="5" />'));
|
||||||
$result = $Article->save(new Xml('<article title="test xml" user_id="5" />'));
|
|
||||||
$this->assertFalse(empty($result));
|
$this->assertFalse(empty($result));
|
||||||
|
|
||||||
$results = $Article->find(array('Article.title' => 'test xml'));
|
$results = $Article->find(array('Article.title' => 'test xml'));
|
||||||
$this->assertFalse(empty($results));
|
$this->assertFalse(empty($results));
|
||||||
|
|
||||||
|
$result = $Article->save(Xml::build('<article><title>testing</title><user_id>6</user_id></article>'));
|
||||||
|
$this->assertFalse(empty($result));
|
||||||
|
$results = $Article->find(array('Article.title' => 'testing'));
|
||||||
|
$this->assertFalse(empty($results));
|
||||||
|
|
||||||
|
$result = $Article->save(Xml::build('<article><title>testing with DOMDocument</title><user_id>7</user_id></article>', array('return' => 'domdocument')));
|
||||||
|
$this->assertFalse(empty($result));
|
||||||
|
$results = $Article->find(array('Article.title' => 'testing with DOMDocument'));
|
||||||
|
$this->assertFalse(empty($results));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2731,7 +2731,7 @@ class SetTest extends CakeTestCase {
|
||||||
$xml = Xml::build($string);
|
$xml = Xml::build($string);
|
||||||
$result = Set::reverse($xml);
|
$result = Set::reverse($xml);
|
||||||
$expected = array('rss' => array(
|
$expected = array('rss' => array(
|
||||||
'version' => '2.0',
|
'@version' => '2.0',
|
||||||
'channel' => array(
|
'channel' => array(
|
||||||
'title' => 'Cake PHP Google Group',
|
'title' => 'Cake PHP Google Group',
|
||||||
'link' => 'http://groups.google.com/group/cake-php',
|
'link' => 'http://groups.google.com/group/cake-php',
|
||||||
|
@ -2742,7 +2742,7 @@ class SetTest extends CakeTestCase {
|
||||||
'title' => 'constructng result array when using findall',
|
'title' => 'constructng result array when using findall',
|
||||||
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
||||||
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] => Array(",
|
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] => Array(",
|
||||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
||||||
'author' => 'bmil...@gmail.com(bpscrugs)',
|
'author' => 'bmil...@gmail.com(bpscrugs)',
|
||||||
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
||||||
),
|
),
|
||||||
|
@ -2750,7 +2750,7 @@ class SetTest extends CakeTestCase {
|
||||||
'title' => 'Re: share views between actions?',
|
'title' => 'Re: share views between actions?',
|
||||||
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
||||||
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
||||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
||||||
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
||||||
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
||||||
)
|
)
|
||||||
|
@ -2762,7 +2762,7 @@ class SetTest extends CakeTestCase {
|
||||||
|
|
||||||
$xml = Xml::build($string);
|
$xml = Xml::build($string);
|
||||||
$result = Set::reverse($xml);
|
$result = Set::reverse($xml);
|
||||||
$expected = array('data' => array('post' => array('title' => 'Title of this post', 'description' => 'cool')));
|
$expected = array('data' => array('post' => array('@title' => 'Title of this post', '@description' => 'cool')));
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
|
|
||||||
$xml = Xml::build('<example><item><title>An example of a correctly reversed SimpleXMLElement</title><desc/></item></example>');
|
$xml = Xml::build('<example><item><title>An example of a correctly reversed SimpleXMLElement</title><desc/></item></example>');
|
||||||
|
@ -2782,7 +2782,7 @@ class SetTest extends CakeTestCase {
|
||||||
$expected =
|
$expected =
|
||||||
array('example' => array(
|
array('example' => array(
|
||||||
'item' => array(
|
'item' => array(
|
||||||
'attr' => '123',
|
'@attr' => '123',
|
||||||
'titles' => array(
|
'titles' => array(
|
||||||
'title' => array('title1', 'title2')
|
'title' => array('title1', 'title2')
|
||||||
)
|
)
|
||||||
|
@ -2795,11 +2795,11 @@ class SetTest extends CakeTestCase {
|
||||||
$result = Set::reverse($xml);
|
$result = Set::reverse($xml);
|
||||||
$expected =
|
$expected =
|
||||||
array('example' => array(
|
array('example' => array(
|
||||||
'attr' => 'ex_attr',
|
'@attr' => 'ex_attr',
|
||||||
'item' => array(
|
'item' => array(
|
||||||
'attr' => '123',
|
'@attr' => '123',
|
||||||
'titles' => 'list',
|
'titles' => 'list',
|
||||||
'value' => 'textforitems'
|
'@' => 'textforitems'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -2841,7 +2841,7 @@ class SetTest extends CakeTestCase {
|
||||||
$result = Set::reverse($xml);
|
$result = Set::reverse($xml);
|
||||||
|
|
||||||
$expected = array('rss' => array(
|
$expected = array('rss' => array(
|
||||||
'version' => '2.0',
|
'@version' => '2.0',
|
||||||
'channel' => array(
|
'channel' => array(
|
||||||
'title' => 'Cake PHP Google Group',
|
'title' => 'Cake PHP Google Group',
|
||||||
'link' => 'http://groups.google.com/group/cake-php',
|
'link' => 'http://groups.google.com/group/cake-php',
|
||||||
|
@ -2852,9 +2852,9 @@ class SetTest extends CakeTestCase {
|
||||||
'title' => 'constructng result array when using findall',
|
'title' => 'constructng result array when using findall',
|
||||||
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
'link' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f',
|
||||||
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] => Array(",
|
'description' => "i'm using cakephp to construct a logical data model array that will be <br> passed to a flex app. I have the following model association: <br> ServiceDay->(hasMany)ServiceTi me->(hasMany)ServiceTimePrice. So what <br> the current output from my findall is something like this example: <br> <p>Array( <br> [0] => Array(",
|
||||||
'creator' => 'cakephp',
|
'dc:creator' => 'cakephp',
|
||||||
'category' => array('cakephp', 'model'),
|
'category' => array('cakephp', 'model'),
|
||||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/49bc00f3bc651b4f'),
|
||||||
'author' => 'bmil...@gmail.com(bpscrugs)',
|
'author' => 'bmil...@gmail.com(bpscrugs)',
|
||||||
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
'pubDate' => 'Fri, 28 Dec 2007 00:44:14 UT',
|
||||||
),
|
),
|
||||||
|
@ -2862,9 +2862,9 @@ class SetTest extends CakeTestCase {
|
||||||
'title' => 'Re: share views between actions?',
|
'title' => 'Re: share views between actions?',
|
||||||
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
'link' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8',
|
||||||
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
'description' => 'Then perhaps you might do us all a favour and refrain from replying to <br> things you do not understand. That goes especially for asinine comments. <br> Indeed. <br> To sum up: <br> No comment. <br> In my day, a simple "RTFM" would suffice. I\'ll keep in mind to ignore any <br> further responses from you. <br> You (and I) were referring to the *online documentation*, not other',
|
||||||
'creator' => 'cakephp',
|
'dc:creator' => 'cakephp',
|
||||||
'category' => array('cakephp', 'model'),
|
'category' => array('cakephp', 'model'),
|
||||||
'guid' => array('isPermaLink' => 'true', 'value' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
'guid' => array('@isPermaLink' => 'true', '@' => 'http://groups.google.com/group/cake-php/msg/8b350d898707dad8'),
|
||||||
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
'author' => 'subtropolis.z...@gmail.com(subtropolis zijn)',
|
||||||
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
'pubDate' => 'Fri, 28 Dec 2007 00:45:01 UT'
|
||||||
)
|
)
|
||||||
|
@ -2901,8 +2901,8 @@ class SetTest extends CakeTestCase {
|
||||||
$expected = array('XRDS' => array(
|
$expected = array('XRDS' => array(
|
||||||
'XRD' => array(
|
'XRD' => array(
|
||||||
array(
|
array(
|
||||||
'id' => 'oauth',
|
'@xml:id' => 'oauth',
|
||||||
'version' => '2.0',
|
'@version' => '2.0',
|
||||||
'Type' => 'xri://$xrds*simple',
|
'Type' => 'xri://$xrds*simple',
|
||||||
'Expires' => '2008-04-13T07:34:58Z',
|
'Expires' => '2008-04-13T07:34:58Z',
|
||||||
'Service' => array(
|
'Service' => array(
|
||||||
|
@ -2913,21 +2913,21 @@ class SetTest extends CakeTestCase {
|
||||||
),
|
),
|
||||||
'URI' => array(
|
'URI' => array(
|
||||||
array(
|
array(
|
||||||
'value' => 'https://ma.gnolia.com/oauth/authorize',
|
'@' => 'https://ma.gnolia.com/oauth/authorize',
|
||||||
'priority' => '10',
|
'@priority' => '10',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'value' => 'http://ma.gnolia.com/oauth/authorize',
|
'@' => 'http://ma.gnolia.com/oauth/authorize',
|
||||||
'priority' => '20'
|
'@priority' => '20'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'version' => '2.0',
|
'@version' => '2.0',
|
||||||
'Type' => 'xri://$xrds*simple',
|
'Type' => 'xri://$xrds*simple',
|
||||||
'Service' => array(
|
'Service' => array(
|
||||||
'priority' => '10',
|
'@priority' => '10',
|
||||||
'Type' => 'http://oauth.net/discovery/1.0',
|
'Type' => 'http://oauth.net/discovery/1.0',
|
||||||
'URI' => '#oauth'
|
'URI' => '#oauth'
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue