本文整理汇总了PHP中Magento\Framework\Filesystem类的典型用法代码示例。如果您正苦于以下问题:PHP Filesystem类的具体用法?PHP Filesystem怎么用?PHP Filesystem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filesystem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* @param Context $context
* @param StoreManagerInterface $storeManager
* @param Filesystem $filesystem
* @param string $imageDir
*/
public function __construct(Context $context, StoreManagerInterface $storeManager, Filesystem $filesystem, $imageDir = 'design/image')
{
parent::__construct($context);
$this->storeManager = $storeManager;
$this->mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->imageDir = $imageDir;
}
示例2: __construct
/**
* Constructor
*
* @param MagentoComposerApplicationFactory $applicationFactory
* @param \Magento\Framework\Filesystem $filesystem
* @param ComposerInformation $composerInformation
* @param ObjectManagerProvider $objectManagerProvider
* @throws \Exception
*/
public function __construct(MagentoComposerApplicationFactory $applicationFactory, Filesystem $filesystem, ComposerInformation $composerInformation, ObjectManagerProvider $objectManagerProvider)
{
$this->application = $applicationFactory->create();
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->objectManager = $objectManagerProvider->get();
$this->composerInformation = $composerInformation;
}
示例3: __construct
/**
* Constructor
* @param Filesystem $filesystem
* @param string $logFile
*/
public function __construct(Filesystem $filesystem, $logFile = null)
{
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::LOG);
if ($logFile) {
$this->logFile = $logFile;
}
}
示例4: __construct
/**
* Constructor
*
* @param \Magento\Framework\Filesystem $filesystem
* @param ComponentRegistrarInterface $componentRegistrar
* @param string $filename
*/
public function __construct(\Magento\Framework\Filesystem $filesystem, ComponentRegistrarInterface $componentRegistrar, $filename = \Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME)
{
$this->filesystem = $filesystem;
$this->filename = $filename;
$this->mediaDirectoryRead = $this->filesystem->getDirectoryRead(DirectoryList::MEDIA);
$this->componentRegistrar = $componentRegistrar;
}
示例5: setUp
protected function setUp()
{
$this->requestMock = $this->getMock(
'\Magento\Framework\App\Request\Http',
['getBasePath', 'isSecure', 'getHttpHost'],
[],
'',
false,
false
);
$this->requestMock->expects($this->atLeastOnce())->method('getBasePath')->will($this->returnValue('/'));
$this->requestMock->expects($this->atLeastOnce())
->method('getHttpHost')
->will($this->returnValue('init.host'));
$this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
$this->validatorFactory = $this->getMockBuilder('Magento\Framework\ValidatorFactory')
->disableOriginalConstructor()
->getMock();
$backendUrl = $this->getMock('\Magento\Backend\Model\Url', [], [], '', false);
$backendUrl->expects($this->once())->method('getBaseUrl')->will($this->returnValue('/'));
$this->backendUrlFactory = $this->getMock('Magento\Backend\Model\UrlFactory', ['create'], [], '', false);
$this->backendUrlFactory->expects($this->any())->method('create')->willReturn($backendUrl);
$this->filesystemMock = $this->getMock('\Magento\Framework\Filesystem', [], [], '', false);
$dirMock = $this->getMockForAbstractClass('Magento\Framework\Filesystem\Directory\WriteInterface');
$this->filesystemMock->expects($this->any())
->method('getDirectoryWrite')
->will($this->returnValue($dirMock));
}
示例6: __construct
/**
* @param \Magento\Backend\Block\Context $context
* @param \Magento\Framework\Filesystem $filesystem
* @param \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead
* @param \Magento\Framework\Stdlib\DateTime\DateTime $coreDate
* @param array $data
*/
public function __construct(\Magento\Backend\Block\Context $context, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Filesystem\Directory\ReadFactory $directoryRead, \Magento\Framework\Stdlib\DateTime\DateTime $coreDate, array $data = [])
{
parent::__construct($context, $data);
$this->_ioRead = $filesystem->getDirectoryWrite(\Magento\Framework\App\Filesystem\DirectoryList::ROOT);
$this->_coreDate = $coreDate;
$this->_directoryRead = $directoryRead->create("");
}
示例7: __construct
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Tax\Helper\Data $taxData
* @param \Magento\Framework\Filesystem $filesystem ,
* @param \Magento\Framework\Filter\FilterManager $filterManager
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
*/
public function __construct(\Magento\Framework\Model\Context $context, \Magento\Framework\Registry $registry, \Magento\Tax\Helper\Data $taxData, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Filter\FilterManager $filterManager, \Magento\Framework\Model\ResourceModel\AbstractResource $resource = null, \Magento\Framework\Data\Collection\AbstractDb $resourceCollection = null, array $data = [])
{
$this->filterManager = $filterManager;
$this->_taxData = $taxData;
$this->_rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
parent::__construct($context, $registry, $resource, $resourceCollection, $data);
}
示例8: __construct
/**
* @param \Magento\Framework\Model\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Store\Model\StoreManagerInterface $storeManager
* @param \Magento\Framework\Filesystem $filesystem
* @param \Magento\Framework\Image\Factory $imageFactory
* @param \Magento\Framework\Model\ResourceModel\AbstractResource $resource
* @param \Magento\Framework\Data\Collection\AbstractDb $resourceCollection
* @param array $data
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
* @SuppressWarnings(PHPMD.UnusedLocalVariable)
*/
public function __construct(\Magento\Store\Model\StoreManagerInterface $storeManager, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Image\Factory $imageFactory, \Magento\Framework\ObjectManagerInterface $objectManager, array $data = [])
{
$this->_mediaDirectory = $filesystem->getDirectoryWrite(DirectoryList::MEDIA);
$this->_imageFactory = $imageFactory;
$this->_storeManager = $storeManager;
$this->_objectManager = $objectManager;
}
示例9: setUp
public function setUp()
{
$this->filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
$this->varReaderWriter = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\Directory\\WriteInterface', [], '', false);
$this->filesystem->expects($this->once())->method('getDirectoryWrite')->will($this->returnValue($this->varReaderWriter));
$this->status = new Status($this->filesystem);
}
示例10: __construct
/**
* @param Dir $moduleDirs
* @param ModuleListInterface $moduleList
* @param Filesystem $filesystem
* @param FileIteratorFactory $fileIteratorFactory
*/
public function __construct(Dir $moduleDirs, ModuleListInterface $moduleList, Filesystem $filesystem, FileIteratorFactory $fileIteratorFactory)
{
$this->moduleDirs = $moduleDirs;
$this->modulesList = $moduleList;
$this->fileIteratorFactory = $fileIteratorFactory;
$this->modulesDirectory = $filesystem->getDirectoryRead(DirectoryList::MODULES);
}
示例11: __construct
/**
* @param State $appState
* @param Config $config
* @param Filesystem $filesystem
* @param Files $filesUtility
*/
public function __construct(State $appState, Config $config, Filesystem $filesystem, Files $filesUtility = null)
{
$this->appState = $appState;
$this->config = $config;
$this->rootDirectory = $filesystem->getDirectoryRead(DirectoryList::ROOT);
$this->filesUtility = null !== $filesUtility ? $filesUtility : new Files(BP);
}
示例12: testAddTrackingNumbersToShipment
/**
* @covers \Magento\Shipping\Model\Shipping\LabelGenerator
* @param array $info
* @dataProvider labelInfoDataProvider
*/
public function testAddTrackingNumbersToShipment(array $info)
{
$order = $this->getMockBuilder('Magento\\Sales\\Model\\Order')->disableOriginalConstructor()->getMock();
$order->expects(static::once())->method('getShippingMethod')->with(true)->willReturn($this->getShippingMethodMock());
/**
* @var $shipmentMock \Magento\Sales\Model\Order\Shipment|\PHPUnit_Framework_MockObject_MockObject
*/
$shipmentMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment')->disableOriginalConstructor()->getMock();
$shipmentMock->expects(static::once())->method('getOrder')->willReturn($order);
$this->carrierFactory->expects(static::once())->method('create')->with(self::CARRIER_CODE)->willReturn($this->getCarrierMock());
$labelsMock = $this->getMockBuilder('\\Magento\\Shipping\\Model\\Shipping\\Labels')->disableOriginalConstructor()->getMock();
$labelsMock->expects(static::once())->method('requestToShipment')->with($shipmentMock)->willReturn($this->getResponseMock($info));
$this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
$this->filesystem->expects(static::once())->method('getDirectoryWrite')->willReturn($this->getMock('Magento\\Framework\\Filesystem\\Directory\\WriteInterface'));
$this->scopeConfig->expects(static::once())->method('getValue')->with('carriers/' . self::CARRIER_CODE . '/title', ScopeInterface::SCOPE_STORE, null)->willReturn(self::CARRIER_TITLE);
$this->labelsFactory->expects(static::once())->method('create')->willReturn($labelsMock);
$trackMock = $this->getMockBuilder('Magento\\Sales\\Model\\Order\\Shipment\\Track')->setMethods(['setNumber', 'setCarrierCode', 'setTitle'])->disableOriginalConstructor()->getMock();
$i = 0;
$trackingNumbers = is_array($info['tracking_number']) ? $info['tracking_number'] : [$info['tracking_number']];
foreach ($trackingNumbers as $trackingNumber) {
$trackMock->expects(static::at($i++))->method('setNumber')->with($trackingNumber)->willReturnSelf();
$trackMock->expects(static::at($i++))->method('setCarrierCode')->with(self::CARRIER_CODE)->willReturnSelf();
$trackMock->expects(static::at($i++))->method('setTitle')->with(self::CARRIER_TITLE)->willReturnSelf();
}
$this->trackFactory->expects(static::any())->method('create')->willReturn($trackMock);
/**
* @var $requestMock \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
*/
$requestMock = $this->getMock('Magento\\Framework\\App\\RequestInterface');
$this->labelGenerator->create($shipmentMock, $requestMock);
}
示例13: __construct
public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Framework\Filesystem $filesystem, \Magento\Framework\Filesystem\File\ReadFactory $readFactory)
{
$this->_scopeConfig = $scopeConfig;
$this->_filesystem = $filesystem;
$this->_directory = $filesystem->getDirectoryWrite(DirectoryList::ROOT);
$this->_readFactory = $readFactory;
}
示例14: testToHtml
public function testToHtml()
{
$fieldSet = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Fieldset', [], [], '', false);
$form = $this->getMock('Magento\\Framework\\Data\\Form', [], [], '', false);
$attributeModel = $this->getMock('\\Magento\\Catalog\\Model\\ResourceModel\\Eav\\Attribute', [], [], '', false);
$entityType = $this->getMock('Magento\\Eav\\Model\\Entity\\Type', [], [], '', false);
$formElement = $this->getMock('Magento\\Framework\\Data\\Form\\Element\\Text', ['setDisabled'], [], '', false);
$directoryReadInterface = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface');
$this->registry->expects($this->any())->method('registry')->with('entity_attribute')->willReturn($attributeModel);
$this->formFactory->expects($this->any())->method('create')->willReturn($form);
$form->expects($this->any())->method('addFieldset')->willReturn($fieldSet);
$form->expects($this->any())->method('getElement')->willReturn($formElement);
$fieldSet->expects($this->any())->method('addField')->willReturnSelf();
$attributeModel->expects($this->any())->method('getDefaultValue')->willReturn('default_value');
$attributeModel->expects($this->any())->method('setDisabled')->willReturnSelf();
$attributeModel->expects($this->any())->method('getId')->willReturn(1);
$attributeModel->expects($this->any())->method('getEntityType')->willReturn($entityType);
$attributeModel->expects($this->any())->method('getIsUserDefined')->willReturn(false);
$attributeModel->expects($this->any())->method('getAttributeCode')->willReturn('attribute_code');
$this->localeDate->expects($this->any())->method('getDateFormat')->willReturn('mm/dd/yy');
$entityType->expects($this->any())->method('getEntityTypeCode')->willReturn('entity_type_code');
$this->eavData->expects($this->any())->method('getFrontendClasses')->willReturn([]);
$formElement->expects($this->exactly(3))->method('setDisabled')->willReturnSelf();
$this->yesNo->expects($this->any())->method('toOptionArray')->willReturn(['yes', 'no']);
$this->filesystem->expects($this->any())->method('getDirectoryRead')->willReturn($directoryReadInterface);
$directoryReadInterface->expects($this->any())->method('getRelativePath')->willReturn('relative_path');
$this->block->setData(['action' => 'save']);
$this->block->toHtml();
}
示例15: __construct
/**
* Constructor
*
* @param MagentoComposerApplicationFactory $applicationFactory
* @param \Magento\Framework\Filesystem $filesystem
* @param \Magento\Framework\Stdlib\DateTime $dateTime
* @param ComposerInformation $composerInformation
* @throws \Exception
*/
public function __construct(MagentoComposerApplicationFactory $applicationFactory, Filesystem $filesystem, DateTime $dateTime, ComposerInformation $composerInformation)
{
$this->application = $applicationFactory->create();
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::VAR_DIR);
$this->dateTime = $dateTime;
$this->composerInformation = $composerInformation;
}