예제 #1
0
 /**
  * @{inheritDoc}
  *
  * @param $record array
  * @return void
  */
 public function write(array $record)
 {
     $logDir = $this->filesystem->getParentDirectory($this->url);
     if (!$this->filesystem->isDirectory($logDir)) {
         $this->filesystem->createDirectory($logDir, 0777);
     }
     parent::write($record);
 }
예제 #2
0
 /**
  * @{inheritDoc}
  *
  * @param $record array
  * @return void
  */
 public function write(array $record)
 {
     $logDir = $this->filesystem->getParentDirectory($this->url);
     if (!$this->filesystem->isDirectory($logDir)) {
         $this->filesystem->createDirectory($logDir, DriverInterface::WRITEABLE_DIRECTORY_MODE);
     }
     parent::write($record);
 }
예제 #3
0
 /**
  * @return string
  */
 protected function getLockFile()
 {
     $lockFileDir = $this->filesystem->getDirectoryRead(DirectoryList::VAR_DIR)->getAbsolutePath();
     $lockFile = $lockFileDir . DIRECTORY_SEPARATOR . $this->lockFileName;
     if (!$this->filesystemDriver->isExists($lockFile)) {
         $this->filesystemDriver->filePutContents($lockFile, 0);
     }
     return $lockFile;
 }
예제 #4
0
파일: File.php 프로젝트: okite11/frames21
 /**
  * @return string
  */
 protected function getLockFile()
 {
     $lockFileDir = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR . 'var';
     $lockFile = $lockFileDir . DIRECTORY_SEPARATOR . $this->lockFileName;
     if (!$this->filesystem->isExists($lockFile)) {
         $this->filesystem->filePutContents($lockFile, 0);
     }
     return $lockFile;
 }
예제 #5
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false);
     $this->driverMock = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\DriverInterface', [], '', false, false, true, ['getRealPath']);
     $this->driverMock->expects($this->any())->method('getRealPath')->will($this->returnArgument(0));
     $this->directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', ['delete', 'getDriver', 'create'], [], '', false);
     $this->directoryMock->expects($this->any())->method('getDriver')->will($this->returnValue($this->driverMock));
     $this->filesystemMock = $this->getMock('Magento\\Framework\\Filesystem', ['getDirectoryWrite'], [], '', false);
     $this->filesystemMock->expects($this->any())->method('getDirectoryWrite')->with(DirectoryList::MEDIA)->will($this->returnValue($this->directoryMock));
     $this->adapterFactoryMock = $this->getMock('Magento\\Framework\\Image\\AdapterFactory', [], [], '', false);
     $this->imageHelperMock = $this->getMock('Magento\\Cms\\Helper\\Wysiwyg\\Images', ['getStorageRoot'], [], '', false);
     $this->imageHelperMock->expects($this->any())->method('getStorageRoot')->will($this->returnValue(self::STORAGE_ROOT_DIR));
     $this->resizeParameters = ['width' => 100, 'height' => 50];
     $this->storageCollectionFactoryMock = $this->getMock('Magento\\Cms\\Model\\Wysiwyg\\Images\\Storage\\CollectionFactory', ['create'], [], '', false);
     $this->storageFileFactoryMock = $this->getMock('Magento\\MediaStorage\\Model\\File\\Storage\\FileFactory', [], [], '', false);
     $this->storageDatabaseFactoryMock = $this->getMock('Magento\\MediaStorage\\Model\\File\\Storage\\DatabaseFactory', [], [], '', false);
     $this->directoryDatabaseFactoryMock = $this->getMock('Magento\\MediaStorage\\Model\\File\\Storage\\Directory\\DatabaseFactory', ['create'], [], '', false);
     $this->directoryCollectionMock = $this->getMock('Magento\\MediaStorage\\Model\\File\\Storage\\Directory\\Database', [], [], '', false);
     $this->uploaderFactoryMock = $this->getMockBuilder('Magento\\MediaStorage\\Model\\File\\UploaderFactory')->disableOriginalConstructor()->getMock();
     $this->sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', [], [], '', false);
     $this->backendUrlMock = $this->getMock('Magento\\Backend\\Model\\Url', [], [], '', false);
     $this->coreFileStorageMock = $this->getMockBuilder('Magento\\MediaStorage\\Helper\\File\\Storage\\Database')->disableOriginalConstructor()->getMock();
     $this->objectManagerHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->imagesStorage = $this->objectManagerHelper->getObject('Magento\\Cms\\Model\\Wysiwyg\\Images\\Storage', ['session' => $this->sessionMock, 'backendUrl' => $this->backendUrlMock, 'cmsWysiwygImages' => $this->imageHelperMock, 'coreFileStorageDb' => $this->coreFileStorageMock, 'filesystem' => $this->filesystemMock, 'imageFactory' => $this->adapterFactoryMock, 'assetRepo' => $this->getMock('Magento\\Framework\\View\\Asset\\Repository', [], [], '', false), 'storageCollectionFactory' => $this->storageCollectionFactoryMock, 'storageFileFactory' => $this->storageFileFactoryMock, 'storageDatabaseFactory' => $this->storageDatabaseFactoryMock, 'directoryDatabaseFactory' => $this->directoryDatabaseFactoryMock, 'uploaderFactory' => $this->uploaderFactoryMock, 'resizeParameters' => $this->resizeParameters, 'dirs' => ['exclude' => [], 'include' => []]]);
 }
예제 #6
0
 /**
  * Returns module config data and a path to the module.xml file.
  *
  * Example of data returned by generator:
  * <code>
  *     [ 'vendor/module/etc/module.xml', '<xml>contents</xml>' ]
  * </code>
  *
  * @return \Traversable
  *
  * @author Josh Di Fabio <*****@*****.**>
  */
 private function getModuleConfigs()
 {
     $modulePaths = $this->moduleRegistry->getPaths(ComponentRegistrar::MODULE);
     foreach ($modulePaths as $modulePath) {
         $filePath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, "{$modulePath}/etc/module.xml");
         (yield [$filePath, $this->filesystemDriver->fileGetContents($filePath)]);
     }
 }
 /**
  * Create relations
  *
  * @return RelationsInterface
  */
 public function createRelations()
 {
     $path = $this->_definitionDir . '/' . 'relations.ser';
     if ($this->_filesystemDriver->isReadable($path)) {
         return new \Magento\Framework\ObjectManager\Relations\Compiled($this->_unpack($this->_filesystemDriver->fileGetContents($path)));
     } else {
         return new \Magento\Framework\ObjectManager\Relations\Runtime();
     }
 }
예제 #8
0
파일: Loader.php 프로젝트: nja78/magento2
 /**
  * Returns module config data and a path to the module.xml file.
  *
  * Example of data returned by generator:
  * <code>
  *     [ 'vendor/module/etc/module.xml', '<xml>contents</xml>' ]
  * </code>
  *
  * @return \Traversable
  *
  * @author Josh Di Fabio <*****@*****.**>
  */
 private function getModuleConfigs()
 {
     $modulesDir = $this->filesystem->getDirectoryRead(DirectoryList::MODULES);
     foreach ($modulesDir->search('*/*/etc/module.xml') as $filePath) {
         (yield [$filePath, $modulesDir->readFile($filePath)]);
     }
     foreach ($this->moduleRegistry->getModulePaths() as $modulePath) {
         $filePath = str_replace(['\\', '/'], DIRECTORY_SEPARATOR, "{$modulePath}/etc/module.xml");
         (yield [$filePath, $this->filesystemDriver->fileGetContents($filePath)]);
     }
 }
예제 #9
0
 /**
  * Checks that application is installed and DI resources are cleared
  *
  * @return string[]
  */
 private function checkEnvironment()
 {
     $messages = [];
     if (!$this->deploymentConfig->isAvailable()) {
         $messages[] = 'You cannot run this command because the Magento application is not installed.';
     }
     /**
      * By the time the command is able to execute, the Object Management configuration is already contaminated
      * by old config info, and it's too late to just clear the files in code.
      *
      * TODO: reconfigure OM in runtime so DI resources can be cleared after command launches
      *
      */
     $path = $this->directoryList->getPath(DirectoryList::DI);
     if ($this->fileDriver->isExists($path)) {
         $messages[] = "DI configuration must be cleared before running compiler. Please delete '{$path}'.";
     }
     return $messages;
 }
예제 #10
0
 /**
  * Checks that application is installed and DI resources are cleared
  *
  * @return string[]
  */
 private function checkEnvironment()
 {
     $messages = [];
     $config = $this->deploymentConfig->get(ConfigOptionsListConstants::KEY_MODULES);
     if (!$config) {
         $messages[] = 'You cannot run this command because modules are not enabled. You can enable modules by' . ' running the \'module:enable --all\' command.';
     }
     /**
      * By the time the command is able to execute, the Object Management configuration is already contaminated
      * by old config info, and it's too late to just clear the files in code.
      *
      * TODO: reconfigure OM in runtime so DI resources can be cleared after command launches
      *
      */
     $path = $this->directoryList->getPath(DirectoryList::DI);
     if ($this->fileDriver->isExists($path)) {
         $messages[] = "DI configuration must be cleared before running compiler. Please delete '{$path}'.";
     }
     return $messages;
 }
예제 #11
0
 /**
  * Cover createHistoryReport().
  *
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Source file coping failed
  */
 public function testCreateHistoryReportThrowException()
 {
     $sourceFileRelative = null;
     $entity = '';
     $extension = '';
     $result = '';
     $gmtTimestamp = 1234567;
     $this->import->expects($this->once())->method('isReportEntityType')->with($entity)->willReturn(true);
     $this->_varDirectory->expects($this->never())->method('getRelativePath');
     $phrase = $this->getMock('\\Magento\\Framework\\Phrase', [], [], '', false);
     $this->_driver->expects($this->any())->method('fileGetContents')->willReturnCallback(function () use($phrase) {
         throw new \Magento\Framework\Exception\FileSystemException($phrase);
     });
     $this->dateTime->expects($this->once())->method('gmtTimestamp')->willReturn($gmtTimestamp);
     $args = [$sourceFileRelative, $entity, $extension, $result];
     $actualResult = $this->invokeMethod($this->import, 'createHistoryReport', $args);
     $this->assertEquals($this->import, $actualResult);
 }
예제 #12
0
 /**
  * Check whether given path is directory
  *
  * @param string $path [optional]
  * @return bool
  */
 public function isDirectory($path = null)
 {
     return $this->driver->isDirectory($this->driver->getAbsolutePath($this->path, $path));
 }
예제 #13
0
 /**
  * {@inheritDoc}
  *
  * @return array
  */
 public function stat()
 {
     return $this->driver->stat($this->path);
 }
예제 #14
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $this->_filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', array(), array(), '', false);
     $this->_driverMock = $this->getMockForAbstractClass('Magento\\Framework\\Filesystem\\DriverInterface', array(), '', false, false, true, array('getRealPath'));
     $this->_driverMock->expects($this->any())->method('getRealPath')->will($this->returnArgument(0));
     $this->_directoryMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', array('delete', 'getDriver'), array(), '', false);
     $this->_directoryMock->expects($this->any())->method('getDriver')->will($this->returnValue($this->_driverMock));
     $this->_filesystemMock = $this->getMock('Magento\\Framework\\App\\Filesystem', array('getDirectoryWrite'), array(), '', false);
     $this->_filesystemMock->expects($this->any())->method('getDirectoryWrite')->with(\Magento\Framework\App\Filesystem::MEDIA_DIR)->will($this->returnValue($this->_directoryMock));
     $this->_adapterFactoryMock = $this->getMock('Magento\\Framework\\Image\\AdapterFactory', array(), array(), '', false);
     $this->_imageHelperMock = $this->getMock('Magento\\Cms\\Helper\\Wysiwyg\\Images', array('getStorageRoot'), array(), '', false);
     $this->_imageHelperMock->expects($this->any())->method('getStorageRoot')->will($this->returnValue(self::STORAGE_ROOT_DIR));
     $this->_resizeParameters = array('width' => 100, 'height' => 50);
     $this->_storageCollectionFactoryMock = $this->getMock('Magento\\Cms\\Model\\Wysiwyg\\Images\\Storage\\CollectionFactory');
     $this->_storageFileFactoryMock = $this->getMock('Magento\\Core\\Model\\File\\Storage\\FileFactory');
     $this->_storageDatabaseFactoryMock = $this->getMock('Magento\\Core\\Model\\File\\Storage\\DatabaseFactory');
     $this->_directoryDatabaseFactoryMock = $this->getMock('Magento\\Core\\Model\\File\\Storage\\Directory\\DatabaseFactory');
     $this->_uploaderFactoryMock = $this->getMock('Magento\\Core\\Model\\File\\UploaderFactory');
     $this->_sessionMock = $this->getMock('Magento\\Backend\\Model\\Session', array(), array(), '', false);
     $this->_backendUrlMock = $this->getMock('Magento\\Backend\\Model\\Url', array(), array(), '', false);
     $objectManagerHelper = new \Magento\TestFramework\Helper\ObjectManager($this);
     $this->_model = $objectManagerHelper->getObject('Magento\\Cms\\Model\\Wysiwyg\\Images\\Storage', array('session' => $this->_sessionMock, 'backendUrl' => $this->_backendUrlMock, 'cmsWysiwygImages' => $this->_imageHelperMock, 'coreFileStorageDb' => $this->getMock('Magento\\Core\\Helper\\File\\Storage\\Database', array(), array(), '', false), 'filesystem' => $this->_filesystemMock, 'imageFactory' => $this->_adapterFactoryMock, 'assetRepo' => $this->getMock('Magento\\Framework\\View\\Asset\\Repository', array(), array(), '', false), 'storageCollectionFactory' => $this->_storageCollectionFactoryMock, 'storageFileFactory' => $this->_storageFileFactoryMock, 'storageDatabaseFactory' => $this->_storageDatabaseFactoryMock, 'directoryDatabaseFactory' => $this->_directoryDatabaseFactoryMock, 'uploaderFactory' => $this->_uploaderFactoryMock, 'resizeParameters' => $this->_resizeParameters));
 }