Skip to content

Instantly share code, notes, and snippets.

@thomaslarsson
Created October 23, 2014 12:51
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 thomaslarsson/5f20adfe04a7efea2ab6 to your computer and use it in GitHub Desktop.
Save thomaslarsson/5f20adfe04a7efea2ab6 to your computer and use it in GitHub Desktop.
Google shop mapper
...
use eZ\Publish\Core\MVC\Legacy\Kernel as LegacyKernel;
use \eZURI;
class GoogleApiMapperService {
/** @var eZLegacyKernel */
protected $legacyKernel;
public function __construct(\Closure $legacyKernel)
{
$this->legacyKernel = $legacyKernel();
}
public function map( $results )
{
foreach ( $results as $key => $node )
{
$dataMap = $node->dataMap(); // Old eZ Legacy node
$product = new GoogleProduct();
$product->link(
$this->generateUrl($node->attribute('url_alias'))
);
... other mapping code
$this->products[] = $product;
}
}
protected function generateUrl($uri)
{
return = $this->legacyKernel->runCallback(
function() use ($uri)
{
eZURI::transformURI($uri, true, 'full');
return $uri;
}
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment