*/ return function () { $tablePrefix = \XLite::getInstance()->getOptions(array('database_details', 'table_prefix')); $tables = array('news' => 'id'); foreach ($tables as $table => $tableKey) { $tableName = $tablePrefix . $table; $tableColumns = \XLite\Core\Database::getEM()->getConnection()->getSchemaManager()->listTableColumns($tableName); $found = false; foreach (array_keys($tableColumns) as $column) { if (strtolower($column) == 'cleanurl') { $found = true; break; } } if ($found) { $items = array(); $query = 'SELECT ' . $tableKey . ', cleanURL FROM ' . $tableName; $result = \Includes\Utils\Database::fetchAll($query); if ($result) { foreach ($result as $data) { if ($data['cleanURL']) { $items[$data[$tableKey]] = $data['cleanURL']; } } if ($items) { \Includes\Utils\Operator::saveServiceYAML(LC_DIR_VAR . 'cleanURL.newsMessages.yaml', $items); } } } } };
/** * Save service YAML * * @param string $path File path * @param array $data Data * * @return integer */ public function saveServiceYAML($path, array $data) { return \Includes\Utils\Operator::saveServiceYAML($path, $data); }
*/ return function () { $tablePrefix = \XLite::getInstance()->getOptions(array('database_details', 'table_prefix')); $tables = array('products' => 'product_id', 'categories' => 'category_id'); foreach ($tables as $table => $tableKey) { $tableName = $tablePrefix . $table; $tableColumns = \XLite\Core\Database::getEM()->getConnection()->getSchemaManager()->listTableColumns($tableName); $found = false; foreach (array_keys($tableColumns) as $column) { if (strtolower($column) == 'cleanurl') { $found = true; break; } } if ($found) { $items = array(); $query = 'SELECT ' . $tableKey . ', cleanURL FROM ' . $tableName; $result = \Includes\Utils\Database::fetchAll($query); if ($result) { foreach ($result as $data) { if ($data['cleanURL']) { $items[$data[$tableKey]] = $data['cleanURL']; } } if ($items) { \Includes\Utils\Operator::saveServiceYAML(LC_DIR_VAR . 'cleanURL.' . $table . '.yaml', $items); } } } } };
/** * Store DATA information in the YAML format to the file * * @param string $path Path to the file * @param array|null $data Data to store in YAML * * @return void */ public static function storeModuleRegistry($path, $data) { if ($data) { \Includes\Utils\Operator::saveServiceYAML($path, $data); } elseif (\Includes\Utils\FileManager::isExists($path)) { \Includes\Utils\FileManager::deleteFile($path); } }