Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

bug fixes #19

Merged
merged 3 commits into from

2 participants

@mgrandi

fixed bootstrap.php not mapping all of the classes

fixed printing out BinaryData by making it encode it in base64 before printing it out

fixed me not using spaces in the first commit

mgrandi added some commits
@mgrandi mgrandi fixed bootstrap.php to map the classes Boolean, Regex, BinaryData, In…
…teger32 and Integer64
146e665
@mgrandi mgrandi Added a __toString method to BinaryData.php so it prints out a base64…
… encoded version of the binary data, because before json_encode was throwing a 'invalid utf8 argument' when you tried to print out a binary data property
410b2ee
@mgrandi mgrandi fixed me using tabs instead of spaces in bootstrap.php
282ce03
@a-musing-moose a-musing-moose merged commit 572382a into from
@a-musing-moose

Thanks Mark!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 31, 2011
  1. @mgrandi
Commits on Jun 1, 2011
  1. @mgrandi

    Added a __toString method to BinaryData.php so it prints out a base64…

    mgrandi authored
    … encoded version of the binary data, because before json_encode was throwing a 'invalid utf8 argument' when you tried to print out a binary data property
  2. @mgrandi
This page is out of date. Refresh to see the latest.
View
7 src/bootstrap.php
@@ -41,6 +41,11 @@ class MorphAutoloader
'morph\\property\\ComposeOne' => 'phar://Morph/property/ComposeOne.php',
'morph\\property\\String' => 'phar://Morph/property/String.php',
'morph\\property\\Generic' => 'phar://Morph/property/Generic.php',
+ 'morph\\property\\Boolean' => 'phar://Morph/property/Boolean.php',
+ 'morph\\property\\BinaryData' => 'phar://Morph/property/BinaryData.php',
+ 'morph\\property\\Integer32' => 'phar://Morph/property/Integer32.php',
+ 'morph\\property\\Integer64' => 'phar://Morph/property/Integer64.php',
+ 'morph\\property\\Regex' => 'phar://Morph/property/Regex.php',
'morph\\query\\Property' => 'phar://Morph/query/Property.php',
'morph\\format\\Collection' => 'phar://Morph/format/Collection.php',
'morph\\exception\\ObjectNotFound' => 'phar://Morph/exception/ObjectNotFound.php',
@@ -67,4 +72,4 @@ public static function load($className)
//register the autoloader
spl_autoload_register(array('MorphAutoloader', 'load'));
-__HALT_COMPILER();
+__HALT_COMPILER();
View
8 src/morph/Object.php
@@ -286,13 +286,19 @@ public function delete()
*/
public function __toString()
{
+ // create the array that we will be encoding and returning
+ // also put inside the array the mongodb ID and the 'state'
$data = array(
'Id' => $this->id(),
'State' => $this->state()
);
+
+ // iterate through all the properties this object has and print them out
foreach ($this->propertySet as $name => $property) {
+
$data[$name] = (string)$property;
- }
+ }
+
return \json_encode($data);
}
View
15 src/morph/property/BinaryData.php
@@ -86,4 +86,19 @@ public function __setRawValue($value)
return $this;
}
+
+ /**
+ * Returns the base64 encoding of the binary data
+ *
+ * @return String
+ */
+ public function __toString()
+ {
+
+ // we return the base64 encoding of the binary data because
+ // json does not have a native way to represent binary data
+ return base64_encode($this->value);
+
+ }
+
}
Something went wrong with that request. Please try again.