for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* Webino (http://webino.sk)
*
* @link https://github.com/webino/WebinoDraw for the canonical source repository
* @copyright Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
* @author Peter Bačinský <[email protected]>
* @license BSD-3-Clause
*/
namespace WebinoDraw\Manipulator\Plugin;
use WebinoDraw\Dom\Element;
class NodeTranslation extends AbstractPlugin implements InLoopPluginInterface
{
* @var array
protected $lastNodeTranslation = [];
* @param PluginArgument $arg
public function inLoop(PluginArgument $arg)
$node = $arg->getNode();
if (!$node instanceof Element) {
return;
}
$translation = $arg->getTranslation();
// unset the last node translation then merge current one
$nodeTranslation = $this->createNodeTranslation($node, $arg->getSpec());
$translation->unsetKeys(array_keys($this->lastNodeTranslation));
$this->lastNodeTranslation = $nodeTranslation->getArrayCopy();
$translation->merge($this->lastNodeTranslation);