Skip to content

Instantly share code, notes, and snippets.

@boettner-it
Created March 11, 2020 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save boettner-it/110413b6e122237adfb1f0edf46965fb to your computer and use it in GitHub Desktop.
Save boettner-it/110413b6e122237adfb1f0edf46965fb to your computer and use it in GitHub Desktop.
Text converter for Aimeos import jobs to respect linebreaks, newline, linefeeds, carriage returns and the like. Docs: https://aimeos.org/docs/Developers/Controller/Import_products_from_CSV#Data_converters
<?php
/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015-2018
* @package MW
* @subpackage Convert
*/
namespace Aimeos\MW\Convert\Text;
/**
* Converts latin text into UTF-8
*
* @package MW
* @subpackage Convert
*/
class Nl2Br implements \Aimeos\MW\Convert\Iface
{
/**
* Translates a value to another one.
*
* @param mixed $value Value to translate
* @return mixed Translated value
*/
public function translate( $value )
{
return nl2br( $value );
}
/**
* Reverses the translation of the value.
*
* @param mixed $value Value to reverse
* @return mixed Reversed translation
*/
public function reverse( $value )
{
return str_replace('<br/>', chr(10), $value );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment