Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CustomerPersistence.php
Go to the documentation of this file.
1 <?php
7 
10 use Magento\Customer\Api\Data\CustomerInterfaceFactory;
11 
13 {
17  private $entityManager;
18 
22  private $customerDataFactory;
23 
24  public function __construct(
25  EntityManager $entityManager,
26  CustomerInterfaceFactory $customerDataFactory
27  ) {
28  $this->entityManager = $entityManager;
29  $this->customerDataFactory = $customerDataFactory;
30  }
31 
35  public function save(\Magento\Customer\Api\Data\CustomerInterface $customer)
36  {
37  return $this->entityManager->save($customer);
38  }
39 
43  public function get($email, $websiteId = null)
44  {
45  }
46 
50  public function getById($id, $websiteId = null)
51  {
53  $customer = $this->customerDataFactory->create();
54  $entity = $this->entityManager->load($customer, $id);
55  return $entity;
56  }
57 
61  public function delete($id)
62  {
64  $customer = $this->customerDataFactory->create();
65  $customer = $this->entityManager->load($customer, $id);
66  try {
67  $this->entityManager->delete($customer);
68  } catch (\Exception $e) {
69  return false;
70  }
71  return true;
72  }
73 }
$customer
Definition: customers.php:11
$email
Definition: details.phtml:13
$id
Definition: fieldset.phtml:14
save(\Magento\Customer\Api\Data\CustomerInterface $customer)
__construct(EntityManager $entityManager, CustomerInterfaceFactory $customerDataFactory)
$entity
Definition: element.phtml:22