Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 70db54d

Browse files
author
Jens Schulze
committed
Merge branch 'release/v1.0.0-RC5'
2 parents 74fe559 + 234446d commit 70db54d

File tree

78 files changed

+812
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+812
-218
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
<a name="1.0.0-RC5"></a>
2+
# [1.0.0-RC5](https://github.com/sphereio/commercetools-php-sdk/compare/v1.0.0-RC4...v1.0.0-RC5) (2015-10-07)
3+
4+
5+
### Features
6+
7+
* **LineItems:** add update actions for custom types on line items ([c64fad0](https://github.com/sphereio/commercetools-php-sdk/commit/c64fad0))
8+
* **Payment:** add payment update actions for cart ([13e1860](https://github.com/sphereio/commercetools-php-sdk/commit/13e1860))
9+
10+
11+
112
<a name="1.0.0-RC4"></a>
213
# [1.0.0-RC4](https://github.com/sphereio/commercetools-php-sdk/compare/v1.0.0-RC3...v1.0.0-RC4) (2015-10-05)
314

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# <img src="build/theme/resources/CT_cube_200px.png" width="40" align="center"></img> commercetools PHP SDK
22

3-
> STATUS: Release Candidate 3. We ask you to really use this API thoroughly now, especially the API design and object structure. Thank you very much!
3+
> STATUS: Release Candidate 5. We ask you to really use this API thoroughly now, especially the API design and object structure. Thank you very much!
44
>
55
> See the [Milestone Plan](https://github.com/sphereio/commercetools-php-sdk/milestones?direction=desc&sort=completeness&state=open) for details of what's planned in detail. We love feedback and [Issue reports](https://github.com/sphereio/commercetools-php-sdk/issues?q=is%3Aopen+is%3Aissue+sort%3Acreated-asc)!
66
> Up-to-Date planning status can be found on this [Waffle Board](https://waffle.io/sphereio/commercetools-php-sdk)

src/AbstractHttpClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
abstract class AbstractHttpClient
1616
{
1717

18-
const VERSION = '1.0.0-RC4';
18+
const VERSION = '1.0.0-RC5';
1919

2020
/**
2121
* @var AdapterInterface

src/Client.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Commercetools\Core;
88

9-
109
use Psr\Http\Message\RequestInterface;
1110
use Psr\Http\Message\ResponseInterface;
1211
use Psr\Log\LoggerInterface;

src/Config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,11 @@ class Config implements ContextAwareInterface
102102

103103
/**
104104
* @param array $configValues
105-
* @return Config
105+
* @return static
106106
*/
107107
public static function fromArray(array $configValues)
108108
{
109-
$config = Config::of();
109+
$config = static::of();
110110
array_walk(
111111
$configValues,
112112
function ($value, $key) use ($config) {

src/Helper/Annotate/ClassAnnotator.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ protected function annotate()
209209
{
210210
$classHead = [];
211211
$classHead[] = 'namespace ' . $this->class->getNamespace() . ';';
212-
$classHead[] = '';
212+
213+
if (count($this->class->getUses()) > 0) {
214+
$classHead[] = '';
215+
}
213216

214217
foreach ($this->class->getUses() as $use) {
215218
$classHead[] = 'use ' . $use['class'] . (isset($use['alias']) ? ' as ' . $use['alias'] : '') . ';';

src/Model/Common/AbstractJsonDeserializeObject.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,7 @@ protected function hasInterface($type, $interfaceName)
5858
$cacheKey = $interfaceName . '-' . $type;
5959
if (!isset(static::$interfaces[$cacheKey])) {
6060
$interface = false;
61-
if (
62-
$this->isPrimitive($type) === false
61+
if ($this->isPrimitive($type) === false
6362
&& isset(class_implements($type)[$interfaceName])
6463
) {
6564
$interface = true;

src/Model/Common/Address.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
namespace Commercetools\Core\Model\Common;
88

9-
109
/**
1110
* @package Commercetools\Core\Model\Common
1211
* @apidoc http://dev.sphere.io/http-api-types.html#address

src/Model/Common/AddressCollection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
namespace Commercetools\Core\Model\Common;
77

8-
98
/**
109
* @package Commercetools\Core\Model\Common
1110
* @method Address current()

src/Model/Common/Attribute.php

Lines changed: 22 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,6 @@ class Attribute extends JsonObject
2121
{
2222
// identifiers for the Api Product Attribute Types:
2323
const T_UNKNOWN = 'unknown'; // zero, should evaluate to false
24-
const T_TEXTLIKE = 'string'; //includes date, datetime, time as these are JSON Strings, too
25-
const T_LTEXT = '\Commercetools\Core\Model\Common\LocalizedString';
26-
const T_NUMBER = 'float';
27-
const T_BOOLEAN = 'bool';
28-
const T_ENUM = '\Commercetools\Core\Model\Common\Enum';
29-
const T_LENUM = '\Commercetools\Core\Model\Common\LocalizedEnum';
30-
const T_MONEY = '\Commercetools\Core\Model\Common\Money';
31-
const T_SET = '\Commercetools\Core\Model\Common\Set';
32-
const T_NESTED = '\Commercetools\Core\Model\Common\AttributeCollection';
33-
const T_REFERENCE = '\Commercetools\Core\Model\Common\Reference';
34-
const T_DATETIME = '\DateTime';
35-
const T_DATETIME_DECORATOR = '\Commercetools\Core\Model\Common\DateTimeDecorator';
36-
3724

3825
const PROP_VALUE = "value";
3926
const PROP_KEY = "key";
@@ -60,24 +47,33 @@ class Attribute extends JsonObject
6047

6148
protected static $types = [];
6249

63-
protected $attributeDefinition;
64-
protected $valueType;
65-
protected $valueElementType;
66-
protected $valueDecorator;
67-
6850
public function fieldDefinitions()
6951
{
7052
return [
7153
static::PROP_NAME => [self::TYPE => 'string'],
72-
static::PROP_VALUE => [
73-
self::TYPE => $this->valueType,
74-
self::DECORATOR => $this->valueDecorator,
75-
self::ELEMENT_TYPE => $this->valueElementType,
76-
self::OPTIONAL => true
77-
],
54+
static::PROP_VALUE => [],
7855
];
7956
}
8057

58+
public function fieldDefinition($field)
59+
{
60+
if ($field == static::PROP_VALUE) {
61+
if (isset(static::$types[$this->getName()])) {
62+
$fieldDefinition = static::$types[$this->getName()];
63+
if (!$fieldDefinition instanceof AttributeDefinition) {
64+
return null;
65+
}
66+
$fieldType = $fieldDefinition->getType();
67+
if (!$fieldType instanceof AttributeType) {
68+
return null;
69+
}
70+
return $fieldType->fieldTypeDefinition();
71+
}
72+
return null;
73+
}
74+
return parent::fieldDefinition($field);
75+
}
76+
8177
/**
8278
* @param $attributeName
8379
* @param $value
@@ -86,71 +82,29 @@ public function fieldDefinitions()
8682
protected function getApiType($attributeName, $value)
8783
{
8884
if (isset(static::$types[$attributeName])) {
89-
$this->setAttributeDefinition(static::$types[$attributeName]);
9085
return static::$types[$attributeName];
9186
}
9287

9388
$apiType = $this->guessApiType($value);
9489
$definition = AttributeDefinition::of($this->getContextCallback());
9590
$definition->setName($attributeName);
96-
$definition->setType(AttributeType::of()->setName($apiType));
91+
$definition->setType(AttributeType::fromArray(['name' => $apiType]));
9792

9893
if ($apiType == static::API_SET) {
9994
$elementType = $this->guessApiType(current($value));
100-
$definition->getType()->setElementType(AttributeType::of()->setName($elementType));
95+
$definition->getType()->setElementType(AttributeType::fromArray(['name' => $elementType]));
10196
}
10297
$this->setAttributeDefinition($definition);
103-
static::$types[$attributeName] = $definition;
104-
10598
return static::$types[$attributeName];
10699
}
107100

108-
public static function getTypeByApiType($apiType)
109-
{
110-
$typeMapping = [
111-
static::API_BOOL => static::T_BOOLEAN,
112-
static::API_NUMBER => static::T_NUMBER,
113-
static::API_TEXT => static::T_TEXTLIKE,
114-
static::API_LTEXT => static::T_LTEXT,
115-
static::API_LENUM => static::T_LENUM,
116-
static::API_ENUM => static::T_ENUM,
117-
static::API_MONEY => static::T_MONEY,
118-
static::API_DATE => static::T_DATETIME,
119-
static::API_TIME => static::T_DATETIME,
120-
static::API_DATETIME => static::T_DATETIME,
121-
static::API_SET => static::T_SET,
122-
static::API_NESTED => static::T_NESTED,
123-
static::API_REFERENCE => static::T_REFERENCE
124-
];
125-
126-
127-
return isset($typeMapping[$apiType]) ? $typeMapping[$apiType] : null;
128-
}
129-
130101
/**
131102
* @param AttributeDefinition $definition
132103
* @return $this
133104
*/
134105
public function setAttributeDefinition(AttributeDefinition $definition)
135106
{
136107
static::$types[$definition->getName()] = $definition;
137-
$this->attributeDefinition = $definition;
138-
$apiType = $definition->getType()->getName();
139-
$this->valueType = static::getTypeByApiType($apiType);
140-
$this->valueElementType = null;
141-
$this->valueDecorator = null;
142-
143-
switch ($apiType) {
144-
case static::API_SET:
145-
$this->valueElementType = static::getTypeByApiType(
146-
$definition->getType()->getElementType()->getName()
147-
);
148-
break;
149-
case static::API_TIME:
150-
case static::API_DATETIME:
151-
case static::API_DATE:
152-
$this->valueDecorator = static::T_DATETIME_DECORATOR;
153-
}
154108

155109
return $this;
156110
}

0 commit comments

Comments
 (0)