mirror of
https://github.com/bdnugget/magento2.git
synced 2026-11-08 01:37:36 +00:00
59 lines
1.3 KiB
PHP
59 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* Copyright © Magento, Inc. All rights reserved.
|
|
* See COPYING.txt for license details.
|
|
*/
|
|
|
|
namespace Magento\Sales\Model\ResourceModel\Order;
|
|
|
|
/**
|
|
* Class CollectionFactory
|
|
*
|
|
* @api
|
|
*/
|
|
class CollectionFactory implements CollectionFactoryInterface
|
|
{
|
|
/**
|
|
* Object Manager instance
|
|
*
|
|
* @var \Magento\Framework\ObjectManagerInterface
|
|
*/
|
|
private $objectManager = null;
|
|
|
|
/**
|
|
* Instance name to create
|
|
*
|
|
* @var string
|
|
*/
|
|
private $instanceName = null;
|
|
|
|
/**
|
|
* Factory constructor
|
|
*
|
|
* @param \Magento\Framework\ObjectManagerInterface $objectManager
|
|
* @param string $instanceName
|
|
*/
|
|
public function __construct(
|
|
\Magento\Framework\ObjectManagerInterface $objectManager,
|
|
$instanceName = \Magento\Sales\Model\ResourceModel\Order\Collection::class
|
|
) {
|
|
$this->objectManager = $objectManager;
|
|
$this->instanceName = $instanceName;
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function create($customerId = null)
|
|
{
|
|
/** @var \Magento\Sales\Model\ResourceModel\Order\Collection $collection */
|
|
$collection = $this->objectManager->create($this->instanceName);
|
|
|
|
if ($customerId) {
|
|
$collection->addFieldToFilter('customer_id', $customerId);
|
|
}
|
|
|
|
return $collection;
|
|
}
|
|
}
|