Skip to content

Commit

Permalink
Updating SetItemField code to support multiple values of an entry. Ma…
Browse files Browse the repository at this point in the history
…inly the contact physical address. Still needs cleaning before release
  • Loading branch information
Garethp committed May 10, 2016
1 parent fb1c43d commit 54cc502
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"error":true,"errorClass":"GuzzleHttp\\Exception\\ConnectException","errorMessage":"cURL error 6: Could not resolve host: www.garethp.onmicrosoft.com (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)","request":{"method":"POST","uri":"https:\/\/www.garethp.onmicrosoft.com\/autodiscover\/autodiscover.xml","headers":{"Content-Length":["376"],"User-Agent":["GuzzleHttp\/6.2.0 curl\/7.47.0 PHP\/7.0.4-7ubuntu2"],"Host":["www.garethp.onmicrosoft.com"],"Content-Type":["text\/xml; charset=utf-8"]},"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Autodiscover xmlns=\"http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/requestschema\/2006\">\n <Request>\n <EMailAddress>Garethp@garethp.onmicrosoft.com<\/EMailAddress>\n <AcceptableResponseSchema>http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/responseschema\/2006a<\/AcceptableResponseSchema>\n <\/Request>\n<\/Autodiscover>"}},{"error":true,"errorClass":"GuzzleHttp\\Exception\\ConnectException","errorMessage":"cURL error 7: Failed to connect to autodiscover.garethp.onmicrosoft.com port 443: Connection refused (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)","request":{"method":"POST","uri":"https:\/\/autodiscover.garethp.onmicrosoft.com\/autodiscover\/autodiscover.xml","headers":{"Content-Length":["376"],"User-Agent":["GuzzleHttp\/6.2.0 curl\/7.47.0 PHP\/7.0.4-7ubuntu2"],"Host":["autodiscover.garethp.onmicrosoft.com"],"Content-Type":["text\/xml; charset=utf-8"]},"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Autodiscover xmlns=\"http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/requestschema\/2006\">\n <Request>\n <EMailAddress>Garethp@garethp.onmicrosoft.com<\/EMailAddress>\n <AcceptableResponseSchema>http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/responseschema\/2006a<\/AcceptableResponseSchema>\n <\/Request>\n<\/Autodiscover>"}},{"error":false,"statusCode":302,"headers":{"Cache-Control":["no-cache"],"Pragma":["no-cache"],"Location":["https:\/\/autodiscover-s.outlook.com\/autodiscover\/autodiscover.xml"],"Server":["Microsoft-IIS\/8.0"],"X-FEServer":["DB4PR04CA0014","DB4PR04CA0014"],"X-RequestId":["368e192a-edd5-4498-9685-8bd409312be7"],"X-Powered-By":["ASP.NET"],"Date":["Tue, 10 May 2016 09:03:39 GMT"],"Connection":["close"],"Content-Length":["0"]},"body":""},{"error":false,"statusCode":200,"headers":{"Cache-Control":["private"],"Content-Type":["text\/xml; charset=utf-8"],"Server":["Microsoft-IIS\/8.0"],"request-id":["45541f13-a0e7-497e-8546-643f30a02bcf"],"X-CalculatedBETarget":["db5pr0401mb1877.eurprd04.prod.outlook.com"],"X-DiagInfo":["DB5PR0401MB1877"],"X-BEServer":["DB5PR0401MB1877"],"X-AspNet-Version":["4.0.30319"],"Set-Cookie":["EXOBasicAuth=compactTicket=t%3dEwBIA9P5AwAUo4xeBIbHjhBxWOFekj4Xy2fhaGQAATi%2fzPBlvuKUwMz5g5%2b4WLHg%2f384uZFqMIgBj1gZkL7mfqhB25cTVNAq6wDcKunVGEWU%2bgguR9Msy4jIr1SDtPvW%2fPd%2bMbcDdubv%2bo45cCHS9U5hbYW0e0MJcGg6PqL1PhWEmsdHVO%2ffNIwuvHFKp%2fAAdpdPHh5F%2bYSOu%2f6djao3uVuUVmOolm7DOE9CbWW93jWGilYjm9Njr6WZ5JEH38k5oDMVsXhgeQrDajaFoDgSjewAELgB7%2bSNo2MNAXcy2llP3t%2fRJXUBO%2f94GQBSJNbNqh54bjL4XthkajoXnFxgX7Q4zdYDpPASeNwW2AU%2bk8VnR%2b0YnzxitvMqYGfuVm0DZgAACOWZUcG%2bc8e8GAITXKKVmhUei%2fLYMMmc%2bVqEcuIb8LZHaF40M9MLTWDhDu3vpVUhmiyCKIfQzEY5LavH9aoyQ%2foWoZYFK98IylVt1w%2f6lqBVfERiW6sg2%2bxD8IocESGEJSVWPlC%2flBE%2fgfuCo6sJVQnsM04C6c%2bq48j77zJcqaZKFvbIVIyfzGqA2mg%2f9IhqmyzjfuvOZJNAy53y8uzIvXT7KZa%2byrzmGP%2bz%2fgLABa5mO7o6QGZl0S6QZamtczHKSC6J7ET2dOCQvpJIX8jZY6hJLdgvAtV6xX35SrE8rc1UTCYyLjA%2fHTwP8%2fHHZ%2bO07FeX8uSzOTWftXckC0blx%2f5cMRGDguqSvxDRdMyXHRyYKsdqkxEg87aHbHCZsXduebXPDVlJIcqNS1AOlshHIHvE%2bHqMtyfzsY48uruwH1rS6j6rkndEONyV84UjpD0gd9tcwQ12PmxeRYRyd2MlS%2fAv7WS4RbhTeRFOf0V%2bBgkQblJiaZKQmRXj6RneSn%2fjnpTSyHmkdi9Q0dtRnZO4I%2f3gKjeFN%2fj3503PByv4huTwu9o709T9d%2baL2IyyfhqCjhEsLkQv9ja6EepMB5NqUKQrcKizqU%2fPtvbKQVj%2bjYhyyidwqtYNycy8q02%2f2A2Ma8g9iiV9usx%2f0y1Ccg7NxQh3aatx%2bqdibIaW%2bIurh6wmM5%2fQ4S65isdIntch63Jhy1mxSOLSGiTZ%2bjHpO8XY5LY%2fS38C%26amp%3bp%3d&key=garethp%40garethp.onmicrosoft.com+microsoft.exchange.autodiscover+87.233.232.233+&signature=nzbUXU8K2IsrIQXSaGs9BSXFb\/6g19IYNZSHzOJcqNFspRedixAU9bLL2N9UI8jV6e0qop4Jc9N6InuNHViegL06p5T4XtPauHaAr4xN1B13Y+a5HqGUHMdnJsinZ8CVUBrQ9fCjPvefV8zhKfi1WYevP9ZTeaNAPnbVPGT3r7+QlMafzPNIIJ4E5ZwlIHJk+iXw5LShQ2u1VmOO8CzvMCDd+ecEvRbzubF2KTi9Zt+reAG9HV+q5A8TT76631nKD5J06sgnuEqPzzJfKlsKwvQqDlnzwD+Pm8ZiCUNIipWDNLC47BE5l3AxJDeMIDz\/RQupEB+Ppd32W30l0isZOg==&puid=10030000968CF53F&expireTime=635984966200000000&membername=Garethp%40garethp.onmicrosoft.com&flags=False&userType=ManagedBusiness; expires=Tue, 10-May-2016 17:03:40 GMT; path=\/autodiscover; secure; HttpOnly","X-BackEndCookie2=Garethp@garethp.onmicrosoft.com=u56Lnp2ejJqBx8ibx5zJxsjSy8\/PnNLLnsad0p7HzcvSy53NzZ3HysrMysjKgZiejZqLl4\/RkJGSlpyNkIyQmYvRnJCSgc3PzsnSz8nSz8arz8bFz8zFy86BmoqNj42bz8vRj42Qm9GQiouTkJCU0ZyQkoHP; expires=Thu, 09-Jun-2016 09:03:41 GMT; path=\/autodiscover; secure; HttpOnly","X-BackEndCookie=Garethp@garethp.onmicrosoft.com=u56Lnp2ejJqBx8ibx5zJxsjSy8\/PnNLLnsad0p7HzcvSy53NzZ3HysrMysjKgZiejZqLl4\/RkJGSlpyNkIyQmYvRnJCSgc3PzsnSz8nSz8arz8bFz8zFy86BmoqNj42bz8vRj42Qm9GQiouTkJCU0ZyQkoHP; expires=Thu, 09-Jun-2016 09:03:41 GMT; path=\/autodiscover; secure; HttpOnly"],"X-Powered-By":["ASP.NET"],"X-FEServer":["AM3PR04CA0033"],"Date":["Tue, 10 May 2016 09:03:40 GMT"],"Content-Length":["6618"]},"body":"<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Autodiscover xmlns=\"http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/responseschema\/2006\">\r\n <Response xmlns=\"http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/responseschema\/2006a\">\r\n <User>\r\n <DisplayName>Gareth Parker<\/DisplayName>\r\n <LegacyDN>\/o=ExchangeLabs\/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)\/cn=Recipients\/cn=862d5f54a80745f0a5a03c4bf6da1a69-Garethp<\/LegacyDN>\r\n <AutoDiscoverSMTPAddress>Garethp@garethp.onmicrosoft.com<\/AutoDiscoverSMTPAddress>\r\n <DeploymentId>bddca944-897a-4555-a83f-73ab13c75fd9<\/DeploymentId>\r\n <\/User>\r\n <Account>\r\n <AccountType>email<\/AccountType>\r\n <Action>settings<\/Action>\r\n <MicrosoftOnline>True<\/MicrosoftOnline>\r\n <Protocol>\r\n <Type>EXCH<\/Type>\r\n <Server>df8bce74-d4ee-49bd-ab45-9283561a0b37@garethp.onmicrosoft.com<\/Server>\r\n <ServerDN>\/o=ExchangeLabs\/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)\/cn=Configuration\/cn=Servers\/cn=df8bce74-d4ee-49bd-ab45-9283561a0b37@garethp.onmicrosoft.com<\/ServerDN>\r\n <ServerVersion>73C181EC<\/ServerVersion>\r\n <MdbDN>\/o=ExchangeLabs\/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)\/cn=Configuration\/cn=Servers\/cn=df8bce74-d4ee-49bd-ab45-9283561a0b37@garethp.onmicrosoft.com\/cn=Microsoft Private MDB<\/MdbDN>\r\n <PublicFolderServer>outlook.office365.com<\/PublicFolderServer>\r\n <AuthPackage>Anonymous<\/AuthPackage>\r\n <ASUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/ASUrl>\r\n <EwsUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/EwsUrl>\r\n <EmwsUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/EmwsUrl>\r\n <SharingUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/SharingUrl>\r\n <EcpUrl>https:\/\/outlook.office365.com\/owa\/<\/EcpUrl>\r\n <EcpUrl-um>?path=\/options\/callanswering<\/EcpUrl-um>\r\n <EcpUrl-aggr>?path=\/options\/connectedaccounts<\/EcpUrl-aggr>\r\n <EcpUrl-mt>options\/ecp\/PersonalSettings\/DeliveryReport.aspx?rfr=olk&amp;exsvurl=1&amp;IsOWA=&lt;IsOWA&gt;&amp;MsgID=&lt;MsgID&gt;&amp;Mbx=&lt;Mbx&gt;&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-mt>\r\n <EcpUrl-ret>?path=\/options\/retentionpolicies<\/EcpUrl-ret>\r\n <EcpUrl-sms>?path=\/options\/textmessaging<\/EcpUrl-sms>\r\n <EcpUrl-publish>?path=\/options\/calendarpublishing\/id\/&lt;FldID&gt;<\/EcpUrl-publish>\r\n <EcpUrl-photo>?path=\/options\/myaccount\/action\/photo<\/EcpUrl-photo>\r\n <EcpUrl-connect>?path=\/options\/socialnetworks&amp;ignore1=&lt;Action&gt;&amp;ignore2=&lt;Provider&gt;<\/EcpUrl-connect>\r\n <EcpUrl-tm>options\/ecp\/?rfr=olk&amp;ftr=TeamMailbox&amp;exsvurl=1&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-tm>\r\n <EcpUrl-tmCreating>options\/ecp\/?rfr=olk&amp;ftr=TeamMailboxCreating&amp;SPUrl=&lt;SPUrl&gt;&amp;Title=&lt;Title&gt;&amp;SPTMAppUrl=&lt;SPTMAppUrl&gt;&amp;exsvurl=1&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-tmCreating>\r\n <EcpUrl-tmEditing>options\/ecp\/?rfr=olk&amp;ftr=TeamMailboxEditing&amp;Id=&lt;Id&gt;&amp;exsvurl=1&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-tmEditing>\r\n <EcpUrl-extinstall>?path=\/options\/manageapps<\/EcpUrl-extinstall>\r\n <OOFUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/OOFUrl>\r\n <UMUrl>https:\/\/outlook.office365.com\/EWS\/UM2007Legacy.asmx<\/UMUrl>\r\n <OABUrl>https:\/\/outlook.office365.com\/OAB\/f323e4dc-7f29-40ae-8218-772603102937\/<\/OABUrl>\r\n <ServerExclusiveConnect>off<\/ServerExclusiveConnect>\r\n <\/Protocol>\r\n <Protocol>\r\n <Type>EXPR<\/Type>\r\n <Server>outlook.office365.com<\/Server>\r\n <SSL>On<\/SSL>\r\n <AuthPackage>Basic<\/AuthPackage>\r\n <ASUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/ASUrl>\r\n <EwsUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/EwsUrl>\r\n <EmwsUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/EmwsUrl>\r\n <SharingUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/SharingUrl>\r\n <EcpUrl>https:\/\/outlook.office365.com\/owa\/<\/EcpUrl>\r\n <EcpUrl-um>?path=\/options\/callanswering<\/EcpUrl-um>\r\n <EcpUrl-aggr>?path=\/options\/connectedaccounts<\/EcpUrl-aggr>\r\n <EcpUrl-mt>options\/ecp\/PersonalSettings\/DeliveryReport.aspx?rfr=olk&amp;exsvurl=1&amp;IsOWA=&lt;IsOWA&gt;&amp;MsgID=&lt;MsgID&gt;&amp;Mbx=&lt;Mbx&gt;&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-mt>\r\n <EcpUrl-ret>?path=\/options\/retentionpolicies<\/EcpUrl-ret>\r\n <EcpUrl-sms>?path=\/options\/textmessaging<\/EcpUrl-sms>\r\n <EcpUrl-publish>?path=\/options\/calendarpublishing\/id\/&lt;FldID&gt;<\/EcpUrl-publish>\r\n <EcpUrl-photo>?path=\/options\/myaccount\/action\/photo<\/EcpUrl-photo>\r\n <EcpUrl-connect>?path=\/options\/socialnetworks&amp;ignore1=&lt;Action&gt;&amp;ignore2=&lt;Provider&gt;<\/EcpUrl-connect>\r\n <EcpUrl-tm>options\/ecp\/?rfr=olk&amp;ftr=TeamMailbox&amp;exsvurl=1&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-tm>\r\n <EcpUrl-tmCreating>options\/ecp\/?rfr=olk&amp;ftr=TeamMailboxCreating&amp;SPUrl=&lt;SPUrl&gt;&amp;Title=&lt;Title&gt;&amp;SPTMAppUrl=&lt;SPTMAppUrl&gt;&amp;exsvurl=1&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-tmCreating>\r\n <EcpUrl-tmEditing>options\/ecp\/?rfr=olk&amp;ftr=TeamMailboxEditing&amp;Id=&lt;Id&gt;&amp;exsvurl=1&amp;realm=garethp.onmicrosoft.com<\/EcpUrl-tmEditing>\r\n <EcpUrl-extinstall>?path=\/options\/manageapps<\/EcpUrl-extinstall>\r\n <OOFUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/OOFUrl>\r\n <UMUrl>https:\/\/outlook.office365.com\/EWS\/UM2007Legacy.asmx<\/UMUrl>\r\n <OABUrl>https:\/\/outlook.office365.com\/OAB\/f323e4dc-7f29-40ae-8218-772603102937\/<\/OABUrl>\r\n <ServerExclusiveConnect>on<\/ServerExclusiveConnect>\r\n <CertPrincipalName>msstd:outlook.com<\/CertPrincipalName>\r\n <EwsPartnerUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/EwsPartnerUrl>\r\n <GroupingInformation>DB5PR0401<\/GroupingInformation>\r\n <\/Protocol>\r\n <Protocol>\r\n <Type>WEB<\/Type>\r\n <Internal>\r\n <OWAUrl AuthenticationMethod=\"LiveIdFba, OAuth\">https:\/\/outlook.office365.com\/owa\/<\/OWAUrl>\r\n <Protocol>\r\n <Type>EXCH<\/Type>\r\n <ASUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/ASUrl>\r\n <\/Protocol>\r\n <\/Internal>\r\n <External>\r\n <OWAUrl AuthenticationMethod=\"Fba\">https:\/\/outlook.office365.com\/owa\/garethp.onmicrosoft.com\/<\/OWAUrl>\r\n <Protocol>\r\n <Type>EXPR<\/Type>\r\n <ASUrl>https:\/\/outlook.office365.com\/EWS\/Exchange.asmx<\/ASUrl>\r\n <\/Protocol>\r\n <\/External>\r\n <\/Protocol>\r\n <\/Account>\r\n <\/Response>\r\n<\/Autodiscover>"}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"error":true,"errorClass":"GuzzleHttp\\Exception\\ConnectException","errorMessage":"cURL error 6: Could not resolve host: www.falsey.com (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)","request":{"method":"POST","uri":"https:\/\/www.falsey.com\/autodiscover\/autodiscover.xml","headers":{"Content-Length":["361"],"User-Agent":["GuzzleHttp\/6.2.0 curl\/7.47.0 PHP\/7.0.4-7ubuntu2"],"Host":["www.falsey.com"],"Content-Type":["text\/xml; charset=utf-8"]},"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Autodiscover xmlns=\"http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/requestschema\/2006\">\n <Request>\n <EMailAddress>false@falsey.com<\/EMailAddress>\n <AcceptableResponseSchema>http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/responseschema\/2006a<\/AcceptableResponseSchema>\n <\/Request>\n<\/Autodiscover>"}},{"error":true,"errorClass":"GuzzleHttp\\Exception\\ConnectException","errorMessage":"cURL error 6: Could not resolve host: autodiscover.falsey.com (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)","request":{"method":"POST","uri":"https:\/\/autodiscover.falsey.com\/autodiscover\/autodiscover.xml","headers":{"Content-Length":["361"],"User-Agent":["GuzzleHttp\/6.2.0 curl\/7.47.0 PHP\/7.0.4-7ubuntu2"],"Host":["autodiscover.falsey.com"],"Content-Type":["text\/xml; charset=utf-8"]},"body":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Autodiscover xmlns=\"http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/requestschema\/2006\">\n <Request>\n <EMailAddress>false@falsey.com<\/EMailAddress>\n <AcceptableResponseSchema>http:\/\/schemas.microsoft.com\/exchange\/autodiscover\/outlook\/responseschema\/2006a<\/AcceptableResponseSchema>\n <\/Request>\n<\/Autodiscover>"}},{"error":true,"errorClass":"GuzzleHttp\\Exception\\ConnectException","errorMessage":"cURL error 6: Could not resolve host: autodiscover.falsey.com (see http:\/\/curl.haxx.se\/libcurl\/c\/libcurl-errors.html)","request":{"method":"GET","uri":"http:\/\/autodiscover.falsey.com\/autodiscover\/autodiscover.xml","headers":{"User-Agent":["GuzzleHttp\/6.2.0 curl\/7.47.0 PHP\/7.0.4-7ubuntu2"],"Host":["autodiscover.falsey.com"],"Content-Type":["text\/xml; charset=utf-8"]},"body":""}}]
69 changes: 60 additions & 9 deletions src/API.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,16 @@ public function getFieldUrisFromClass($className)
if (!isset($constantsFound[$name])) {
$constantsFound[$name] = array();
}
$constantsFound[$name][$category] = $constant;
if (count($exploded) == 3) {
$entry = strtolower($exploded[2]);
if (!isset($constantsFound[$name])) {
$constantsFound[$name][$category] = array();
}

$constantsFound[$name][$category][$entry] = $constant;
} else {
$constantsFound[$name][$category] = $constant;
}
}

return $constantsFound;
Expand Down Expand Up @@ -111,7 +120,7 @@ public function getFieldUriByName($fieldName, $preference = 'item')
return $this->unIndexedFieldUris[$fieldName][$preference];
}

public function getIndexedFieldUriByName($fieldName, $preference = 'item')
public function getIndexedFieldUriByName($fieldName, $preference = 'item', $entryKey = false)
{
$fieldName = strtolower($fieldName);
$preference = strtolower($preference);
Expand All @@ -132,7 +141,21 @@ public function getIndexedFieldUriByName($fieldName, $preference = 'item')
throw new ExchangeException("Could not find uri $preference:$fieldName");
}

return $this->dictionaryFieldUris[$fieldName][$preference];
$fieldUri = $this->dictionaryFieldUris[$fieldName][$preference];
if (is_array($fieldUri)) {
if (!$entryKey) {
throw new ExchangeException("Please enter a specific entry key for this fieldURI");
}

$entryKey = strtolower($entryKey);
if (!isset($fieldUri[$entryKey])) {
throw new ExchangeException("Could not find uri $preference:$fieldName:$entryKey");
}

$fieldUri = $fieldUri[$entryKey];
}

return $fieldUri;
}

/**
Expand Down Expand Up @@ -288,7 +311,7 @@ protected function getFieldURI($uriType, $key = null, $value = null)
{
if (strpos($key, ':') !== false) {
try {
$fieldUri = $this->getIndexedFieldUriByName(substr($key, 0, strpos($key, ':')), $uriType);
$fieldUriValue = substr($key, 0, strpos($key, ':'));

list ($key, $index) = explode(':', $key);

Expand All @@ -297,6 +320,18 @@ protected function getFieldURI($uriType, $key = null, $value = null)
$value = $value[$key];
}

if (is_array($value) && !empty($value['Entry']) && is_array($value['Entry'])) {
$entryKey = $value['Entry']['Key'];
unset($value['Entry']['Key']);
reset($value['Entry']);

$fieldKey = key($value['Entry']);
$value['Entry']['Key'] = $entryKey;
$fieldUri = $this->getIndexedFieldUriByName($fieldUriValue, $uriType, $fieldKey);
} else {
$fieldUri = $this->getIndexedFieldUriByName($fieldUriValue, $uriType);
}

return ['IndexedFieldURI', ['FieldURI' => $fieldUri, 'FieldIndex' => $index], $key, $value];
} catch (\Exception $e) {
}
Expand All @@ -322,11 +357,27 @@ protected function buildUpdateItemChanges($itemType, $uriType, $changes)

//Add each property to a setItemField
foreach ($changes as $key => $value) {
list ($fieldUriType, $fieldKey, $valueKey, $value) = $this->getFieldURI($uriType, $key, $value);
$setItemFields[] = array(
$fieldUriType => $fieldKey,
$itemType => [$valueKey => $value]
);
$originalValue = $value;
list ($fieldUriType, $fieldKey, $valueKey, $value) = $this->getFieldURI($uriType, $key, $originalValue);

if (is_array($value) && !empty($value['Entry']) && is_array($value['Entry'])) {
$temporaryEntryKey = $value['Entry']['Key'];
unset($value['Entry']['Key']);
foreach ($value['Entry'] as $entryKey => $entryValue) {
list ($fieldUriType, $fieldKey, $valueKey, $value) =
$this->getFieldURI($uriType, $key, $originalValue);
$setItemFields[] = array(
$fieldUriType => $fieldKey,
$itemType => [$valueKey => ['Entry' => ['Key' => $temporaryEntryKey, $entryKey => $entryValue]]]
);
unset($originalValue[$valueKey]['Entry'][$entryKey]);
}
} else {
$setItemFields[] = array(
$fieldUriType => $fieldKey,
$itemType => [$valueKey => $value]
);
}
}

return array('SetItemField' => $setItemFields, 'DeleteItemField' => $deleteItemFields);
Expand Down

0 comments on commit 54cc502

Please sign in to comment.