Created
March 21, 2019 11:19
-
-
Save kanian/4f66ffd9e9b49b49318b6b46165c544a to your computer and use it in GitHub Desktop.
A Sample Customer Domain Service
This file contains 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 | |
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