Created
October 23, 2014 12:51
-
-
Save thomaslarsson/5f20adfe04a7efea2ab6 to your computer and use it in GitHub Desktop.
Google shop mapper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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