Created
August 20, 2014 23:49
-
-
Save viniciusss/78d11eaf4b8552624ce4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Chamado { | |
private $id; | |
private $descricao; | |
private $status; | |
} | |
class Chamdo_Builder { | |
public function build(array $dados){ | |
$chamado = new Chamado(); | |
$chamado->setId($dados['id']); | |
} | |
public function populate(Chamado $chamado, array $dados) { | |
} | |
} | |
class Chamdao_Service { | |
/** | |
* Local onde serão armazenados os dados | |
* @var Repository | |
*/ | |
private $repository; | |
/** | |
* @var Chamado_Builder | |
*/ | |
private $builder; | |
public function __construct(Repository $repository, Builder $builder){ | |
$this->repository = $repository; | |
} | |
public function buscarPendentes(){ | |
$pendentes = $this->repository->findByAreaAtuacaoStatus($_SESSION['areas_responsaveis']); | |
foreach($pendentes as $pendente) { | |
yeld $this->builder->build($pendente); | |
} | |
} | |
public function save(array $dados, Chamado $chamado = null){ | |
if(is_null($chamado)) { | |
$chamado = new Chamado(); | |
} | |
$this->builder->populate($chamado, $dados); | |
$this->repository->save($chamado); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment