32 lines
836 B
PHP
32 lines
836 B
PHP
<?php
|
|
|
|
class TargetFactory
|
|
{
|
|
|
|
/**
|
|
* @param $id
|
|
* @param $type
|
|
* @return DocTarget
|
|
* @throws TargetNotFoundException
|
|
*/
|
|
public function getTarget($id, $type)
|
|
{
|
|
switch ($type) {
|
|
case DocTarget::TYPE_APARTMENT:
|
|
return Apartment::findOne($id);
|
|
case DocTarget::TYPE_BLOCK:
|
|
return Block::findOne($id);
|
|
case DocTarget::TYPE_BLOCK_PROGRESS:
|
|
if ($model = Block::findOne($id)) {
|
|
return new BlockProgressImageFacade($model);
|
|
}
|
|
case DocTarget::TYPE_BLOCK_PLUS:
|
|
if ($model = Block::findOne($id)) {
|
|
return new BlockPlusFacade($model);
|
|
}
|
|
break;
|
|
}
|
|
|
|
throw new TargetNotFoundException;
|
|
}
|
|
} |