This document summarizes Joshua Warren's presentation on Magento 2 at the Northeast PHP 2015 conference. It provides an overview of Magento 2 including its history, technologies used, technical architecture, design patterns, and how to extend Magento 2 modules. Key points include Magento 2's use of Composer, dependency injection, interceptors/plugins, service contracts and how these improve on Magento 1. The presentation also discusses Magento 2's layered architecture and introduces concepts like repositories, management interfaces and metadata interfaces.
81. JoshuaWarren.com #NEPHP
CustomerRepositoryInterface.php
namespace MagentoCustomerApi;
/**
* Customer CRUD interface.
*/
interface CustomerRepositoryInterface
{
/**
* Create customer.
*
* @api
* @param MagentoCustomerApiDataCustomerInterface $customer
* @param string $passwordHash
* @return MagentoCustomerApiDataCustomerInterface
* @throws MagentoFrameworkExceptionInputException If bad input is provided
* @throws MagentoFrameworkExceptionStateInputMismatchException If the provided email is already used
* @throws MagentoFrameworkExceptionLocalizedException
*/
public function save(MagentoCustomerApiDataCustomerInterface $customer, $passwordHash = null);
82. JoshuaWarren.com #NEPHP
CustomerRepositoryInterface.php
/**
* Retrieve customer.
*
* @api
* @param string $email
* @param int|null $websiteId
* @return MagentoCustomerApiDataCustomerInterface
* @throws MagentoFrameworkExceptionNoSuchEntityException If customer with the specified email does not exist.
* @throws MagentoFrameworkExceptionLocalizedException
*/
public function get($email, $websiteId = null);
/**
* Retrieve customer.
*
* @api
* @param int $customerId
* @return MagentoCustomerApiDataCustomerInterface
* @throws MagentoFrameworkExceptionNoSuchEntityException If customer with the specified ID does not exist.
* @throws MagentoFrameworkExceptionLocalizedException
*/
public function getById($customerId);
122. JoshuaWarren.com #NEPHP
Model/Carrier.php
namespace MagentoSampleShippingProviderModel;
use PsrLogLoggerInterface;
use MagentoFrameworkAppConfigScopeConfigInterface;
use MagentoStoreModelScopeInterface;
use MagentoShippingModelCarrierAbstractCarrier;
use MagentoShippingModelCarrierCarrierInterface;
use MagentoShippingModelConfig;
use MagentoShippingModelRateResultFactory;
use MagentoQuoteModelQuoteAddressRateResultMethodFactory;
use MagentoQuoteModelQuoteAddressRateResultErrorFactory;
/**
* In-Store Pickup shipping model
*/
class Carrier extends AbstractCarrier implements CarrierInterface
{
/**
* @var string
*/
protected $_code = 'storepickup';
/**
* @var bool
*/
protected $_isFixed = true;
… see https://github.com/magento/magento2-samples/blob/master/sample-module-shipping-provider/Model/Carrier.php