Skip to content
Browse files

Add __toString() to abstract entity.

  • Loading branch information...
1 parent b2945da commit c0de83d0384d954df5dfdcec5384cf582e63e412 @jeremiahsmall jeremiahsmall committed
Showing with 23 additions and 14 deletions.
  1. +23 −14 library/Soliant/SimpleFM/ZF2/Entity/AbstractEntity.php
View
37 library/Soliant/SimpleFM/ZF2/Entity/AbstractEntity.php
@@ -34,7 +34,7 @@
* @var boolean
*/
protected $isSerializable;
-
+
/**
* @param array $simpleFMAdapterRow
*/
@@ -44,7 +44,16 @@ public function __construct($simpleFMAdapterRow = array())
$this->isSerializable = TRUE;
if (!empty($this->simpleFMAdapterRow)) $this->unserialize();
}
-
+
+ /**
+ * @return the name value for the object
+ */
+
+ public function __toString()
+ {
+ return (string) $this->getName();
+ }
+
/**
* @note FileMaker internal recid
* @return the $recid
@@ -80,13 +89,13 @@ public function setModid ($modid)
$this->modid = $modid;
return $this;
}
-
+
/**
* @note Can be a concrete field e.g. $this->name,
* or return derived value based on business logic
*/
abstract public function getName();
-
+
/**
* @return the $isSerializable
*/
@@ -108,13 +117,13 @@ public function setIsSerializable ($isSerializable)
* Default FileMaker layout for the Entity which should include all the writable fields
*/
abstract public static function getDefaultWriteLayoutName();
-
+
/**
* The route segment for the entity controller.
* Example: MyEntity route segment is normally my-entity
*/
abstract public static function getDefaultControllerRouteSegment();
-
+
/**
* Maps a SimpleFM\Adapter row onto the Entity.
* @see $this->unserializeField()
@@ -124,21 +133,21 @@ public function unserialize()
$this->unserializeField('recid', 'recid');
$this->unserializeField('modid', 'modid');
}
-
+
/**
- * Maps the Entity onto a SimpleFM\Adapter row. The array association should be a
+ * Maps the Entity onto a SimpleFM\Adapter row. The array association should be a
* fully qualified field name, with the exception of pseudo-fields recid and modid.
* @see $this->serializeField()
*/
public function serialize()
{
$this->simpleFMAdapterRow = array();
-
+
$this->serializeField('-recid', 'getRecid');
$this->serializeField('-modid', 'getModid');
}
-
-
+
+
/**
* For unserialize, optimized layouts are permitted to omit fields defined by the entity.
* If a required field is omitted, $this->isSerializable is marked FALSE
@@ -157,7 +166,7 @@ protected function unserializeField($propertyName, $fileMakerFieldName, $isWrita
$this->isSerializable = FALSE;
}
}
-
+
/**
* For serialize, all isRequired fields are required except the pseudo-fields recid and modid
* which are always optional to handle force edit (blank modid) and new (blank recid).
@@ -191,6 +200,6 @@ protected function serializeField($fileMakerFieldName, $getterName)
}
}
}
-
-
+
+
}

0 comments on commit c0de83d

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