/** * Load progress from serialized file * @return bool|array */ public function getData() { if (empty($this->data)) { $data = @unserialize($this->filesystemDriver->fileGetContents($this->getLockFile())); if (is_array($data)) { $this->data = $data; } } return $this->data; }
/** * 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(); } }
/** * Retrieve file contents from given path * * @param string $path * @param string|null $flag * @param resource|null $context * @param string|null $protocol * @return string * @throws FilesystemException */ public function readFile($path, $flag = null, $context = null, $protocol = null) { $absolutePath = $this->driver->getAbsolutePath($this->path, $path, $protocol); if (is_null($protocol)) { return $this->driver->fileGetContents($absolutePath, $flag, $context); } /** @var \Magento\Framework\Filesystem\File\Read $fileReader */ $fileReader = $this->fileFactory->create($absolutePath, $protocol, $this->driver); return $fileReader->readAll($flag, $context); }
/** * 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)]); } }
/** * Retrieve file contents from given path * * @param string $path * @param string|null $flag * @param resource|null $context * @return string * @throws FileSystemException */ public function readFile($path, $flag = null, $context = null) { $absolutePath = $this->driver->getAbsolutePath($this->path, $path); return $this->driver->fileGetContents($absolutePath, $flag, $context); }
/** * Return file content * * @param string|null $flag * @param resource|null $context * @return string */ public function readAll($flag = null, $context = null) { return $this->driver->fileGetContents($this->path, $flag, $context); }