Skip to content

Instantly share code, notes, and snippets.

@kanian
Created March 21, 2019 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanian/4f66ffd9e9b49b49318b6b46165c544a to your computer and use it in GitHub Desktop.
Save kanian/4f66ffd9e9b49b49318b6b46165c544a to your computer and use it in GitHub Desktop.
A Sample Customer Domain Service
<?php
namespace Assoa\DomainServices\Services;
use Assoa\Models\Customer;
use Assoa\Persistence\Repositories\Interfaces\CustomerRepositoryInterface;
use Assoa\DomainServices\Services\Interfaces\CustomerDomainServiceInterface;
class CustomerService implements CustomerDomainServiceInterface
{
private $customerFactory;
private $customerRepository;
public function __construct(CustomerRepositoryInterface $customerRepository) {
$this->customerRepository = $customerRepository;
}
public function create(...$args)
{
//...
return $customer;
}
public function getCustomerByEmail(string $email)
{
return $this->customerRepository->getBy("`email` = '".$email."'");
}
public function getById(int $id)
{
$customer = $this->customerRepository->getById($id);
return $customer;
}
public function save($model){
return $this->customerRepository->save($model);
}
public function delete(int $id){
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment