Floor Serializer bug
fixed bug on expand condition Change-Id: I95a19420b9f746e8b996377dae05d5f598dd25ff
This commit is contained in:
parent
17ac603b38
commit
923c919bc8
@ -11,25 +11,22 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use ModelSerializers\SerializerRegistry;
|
||||
use ModelSerializers\SilverStripeSerializer;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
|
||||
/**
|
||||
* Class SummitVenueFloorSerializer
|
||||
* @package ModelSerializers\Locations
|
||||
*/
|
||||
final class SummitVenueFloorSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = array
|
||||
(
|
||||
protected static $array_mappings =
|
||||
[
|
||||
'Name' => 'name:json_string',
|
||||
'Description' => 'description:json_string',
|
||||
'Number' => 'number:json_int',
|
||||
'VenueId' => 'venue_id:json_int',
|
||||
);
|
||||
];
|
||||
|
||||
/**
|
||||
* @param null $expand
|
||||
@ -38,22 +35,23 @@ final class SummitVenueFloorSerializer extends SilverStripeSerializer
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() )
|
||||
public function serialize($expand = null, array $fields = [], array $relations = [], array $params = [] )
|
||||
{
|
||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||
$floor = $this->object;
|
||||
// floor image
|
||||
$values['image'] = ($floor->getImage() !== null) ?
|
||||
$values['image']= ($floor->getImage() !== null) ?
|
||||
Config::get("server.assets_base_url", 'https://www.openstack.org/').$floor->getImage()->getFilename()
|
||||
: null;
|
||||
// rooms
|
||||
$rooms = array();
|
||||
|
||||
$rooms = [];
|
||||
$expand_rooms = !empty($expand) && strstr('rooms',$expand) !== false;
|
||||
foreach($floor->getRooms() as $room)
|
||||
{
|
||||
|
||||
$rooms[] = strstr('rooms',$expand) === false ? intval($room->getId()) :
|
||||
SerializerRegistry::getInstance()->getSerializer($room)->serialize($expand, $fields, $relations, $params);
|
||||
$rooms[] = $expand_rooms ?SerializerRegistry::getInstance()->getSerializer($room)->serialize($expand, $fields, $relations, $params) :
|
||||
intval($room->getId());
|
||||
|
||||
}
|
||||
|
||||
if(count($rooms) > 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user