Skip to content
Browse files

Merge pull request #1 from EHER/master

Wrong variable at StandartResponseTransformer
  • Loading branch information...
2 parents 9f6205c + 2a6228a commit 38824c00ca877cef39a3348116d961901d7498a0 @jwage jwage committed
View
4 lib/Doctrine/REST/Client/ResponseTransformer/StandardResponseTransformer.php
@@ -77,6 +77,6 @@ public function xmlToArray($object, &$array = array())
public function jsonToArray($json)
{
- return (array) json_decode($data);
+ return (array) json_decode($json);
}
-}
+}
View
46 lib/Doctrine/REST/Client/URLGenerator/ApontadorURLGenerator.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Doctrine\REST\Client\URLGenerator;
+
+/**
+ * Apontador REST request URL generator
+ *
+ * @author Alexandre Eher <alexandre@eher.com.br>
+ */
+class ApontadorURLGenerator extends AbstractURLGenerator
+{
+ public function generate(array $options)
+ {
+ $id = isset($options['id']) ? $options['id'] : null;
+ $action = isset($options['action']) ? $options['action'] : null;
+ $parameters = isset($options['parameters']) ? $options['parameters'] : array();
+
+ $parameters['type'] = $this->_entityConfiguration->getResponseType();
+ if ($id)
+ {
+ if ($action !== null)
+ {
+ $path = sprintf('/%s/%s', $id, $action);
+ } else {
+ $path = sprintf('/%s', $id);
+ }
+ } else {
+ if ($action !== null)
+ {
+ $path = sprintf('/%s', $action);
+ } else {
+ $path = '';
+ }
+ }
+ $url = $this->_entityConfiguration->getUrl() . '/' . $this->_entityConfiguration->getName() . $path;
+ if (is_array($parameters) && $parameters) {
+ foreach ($this->_entityConfiguration->getProperties() as $field) {
+ unset($parameters[$field]);
+ }
+ if ($parameters) {
+ $url .= '?' . http_build_query($parameters);
+ }
+ }
+ return $url;
+ }
+}

0 comments on commit 38824c0

Please sign in to comment.
Something went wrong with that request. Please try again.