Add Image attribute to venue room serializer
Change-Id: I5142a2d0d1a53ae17321e02a697ee0579f307c1e
This commit is contained in:
@@ -11,6 +11,7 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
**/
|
**/
|
||||||
|
use models\summit\SummitVenueRoom;
|
||||||
use ModelSerializers\SerializerRegistry;
|
use ModelSerializers\SerializerRegistry;
|
||||||
/**
|
/**
|
||||||
* Class SummitVenueRoomSerializer
|
* Class SummitVenueRoomSerializer
|
||||||
@@ -28,8 +29,13 @@ class SummitVenueRoomSerializer extends SummitAbstractLocationSerializer
|
|||||||
public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() )
|
public function serialize($expand = null, array $fields = array(), array $relations = array(), array $params = array() )
|
||||||
{
|
{
|
||||||
$room = $this->object;
|
$room = $this->object;
|
||||||
|
if(!$room instanceof SummitVenueRoom) return [];
|
||||||
$values = parent::serialize($expand, $fields, $relations, $params);
|
$values = parent::serialize($expand, $fields, $relations, $params);
|
||||||
|
|
||||||
|
if($room->hasImage()){
|
||||||
|
$values['image'] = SerializerRegistry::getInstance()->getSerializer($room->getImage())->serialize();
|
||||||
|
}
|
||||||
|
|
||||||
if (!empty($expand)) {
|
if (!empty($expand)) {
|
||||||
$exp_expand = explode(',', $expand);
|
$exp_expand = explode(',', $expand);
|
||||||
foreach ($exp_expand as $relation) {
|
foreach ($exp_expand as $relation) {
|
||||||
|
@@ -16,6 +16,8 @@ use App\Models\Foundation\Main\IOrderable;
|
|||||||
use Doctrine\Common\Collections\ArrayCollection;
|
use Doctrine\Common\Collections\ArrayCollection;
|
||||||
use Doctrine\Common\Collections\Criteria;
|
use Doctrine\Common\Collections\Criteria;
|
||||||
use Doctrine\ORM\Mapping AS ORM;
|
use Doctrine\ORM\Mapping AS ORM;
|
||||||
|
use models\main\File;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(name="SummitVenueRoom")
|
* @ORM\Table(name="SummitVenueRoom")
|
||||||
@@ -55,6 +57,48 @@ class SummitVenueRoom extends SummitAbstractLocation implements IOrderable
|
|||||||
*/
|
*/
|
||||||
private $metrics;
|
private $metrics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ORM\ManyToOne(targetEntity="models\main\File", fetch="EAGER", cascade={"persist"})
|
||||||
|
* @ORM\JoinColumn(name="ImageID", referencedColumnName="ID", onDelete="CASCADE")
|
||||||
|
* @var File
|
||||||
|
*/
|
||||||
|
protected $image;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return File
|
||||||
|
*/
|
||||||
|
public function getImage()
|
||||||
|
{
|
||||||
|
return $this->image;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function hasImage(){
|
||||||
|
return $this->getImageId() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function getImageId(){
|
||||||
|
try{
|
||||||
|
return !is_null($this->image) ? $this->image->getId() : 0;
|
||||||
|
}
|
||||||
|
catch(\Exception $ex){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param File $image
|
||||||
|
*/
|
||||||
|
public function setImage($image)
|
||||||
|
{
|
||||||
|
$this->image = $image;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
@@ -160,7 +204,6 @@ class SummitVenueRoom extends SummitAbstractLocation implements IOrderable
|
|||||||
$this->override_blackouts = $override_blackouts;
|
$this->override_blackouts = $override_blackouts;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return ArrayCollection
|
* @return ArrayCollection
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user