Joywork/import/document/target/TargetFactory.php

32 lines
836 B
PHP
Raw Permalink Normal View History

2026-05-22 20:21:54 +02:00
<?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;
}
}