/** * Converts the Response object body to an array * * @return array */ public function bodyToArray() { // Getting response content $xmlContent = $this->response->getContent(); // Wrapping it into a Xml reader object and convert it to array $xmlReader = new Xml(); return $xmlReader->fromString($xmlContent); }
/** * Get result from cache or read from xml file * * @param string $file path to file and filename * @param string $key template file ident * @param ServiceLocatorInterface $sl */ protected function getTemplateFileAsConfig($file, $key, $sl) { $cache = $sl->get(static::CONTENTINUM_CACHE); if (!($result = $cache->getItem($key))) { $xmlFile = new Xml(); $result = new Config($xmlFile->fromFile($file)); $cache->setItem($key, $result); } return $result; }
/** * Checks if installation is valid * @return bool */ protected function _isInstallationValid() { $reader = new Reader(); $data = $reader->fromFile($this->_getXmlInstallPath()); $_isValid = $data['global']['install']['is_valid']; if ($_isValid !== static::VALID_INSTALL_VALUE) { return false; } $fileDbParams = $data['global']['install']['db_params']; if (($fileDbParams !== $this->_getDbParams()) === true) { return false; } return true; }
/** * @param $path * @param null $table_name * @return array */ protected function getFileData($path, $table_name = null) { $directory = dir($path); $fileList = null; while (($entry = $directory->read()) !== false) { if (strpos($entry, ".xml") !== false) { if ($table_name) { if ($table_name . ".xml" == $entry) { $fileList[] = $entry; } } else { $fileList[] = $entry; } } } $list = array(); foreach ($fileList as $name) { $reader = new Xml(); $list[] = $reader->fromFile($path . '/' . $name); } return $list; }
/** * call and read specified configuration * * @param string $path * @param string $type * @return array */ protected function configurationStrategy($path, $type) { $config = []; if (!file_exists($path)) { throw new \InvalidArgumentException('File ' . $path . 'don\'t exists.'); } switch ($type) { case 'array': $config = (include_once $path); break; case 'ini': $reader = new Reader\Ini(); $config = $reader->fromFile($path); break; case 'xml': $reader = new Reader\Xml(); $config = $reader->fromFile($path); break; case 'json': $reader = new Reader\Json(); $config = $reader->fromFile($path); break; case 'yaml': $reader = new Reader\Yaml(['Spyc', 'YAMLLoadString']); $config = $reader->fromFile($path); break; } return $config; }