Skip to content

Commit

Permalink
Enhanced, added ViewSnippet manipulator plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
bacinsky committed Dec 26, 2019
1 parent aa5fc5c commit c88b528
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/WebinoDraw/Factory/ManipulatorFactory.php
Expand Up @@ -57,6 +57,7 @@ public function createService(ServiceLocatorInterface $services)
->setPlugin(new Plugin\Cdata($instructionsRenderer), 20)
->setPlugin(new Plugin\OnVar($varTranslator, $instructionsRenderer), 10)
->setPlugin(new Plugin\OnEmpty($instructionsRenderer), -100)
->setPlugin(new Plugin\ViewSnippet($instructionsRenderer), -450)
->setPlugin(new Plugin\SubInstructions($instructionsRenderer), -500);
}
}
1 change: 0 additions & 1 deletion src/WebinoDraw/Manipulator/Plugin/Render.php
Expand Up @@ -11,7 +11,6 @@
namespace WebinoDraw\Manipulator\Plugin;

use Zend\View\Renderer\PhpRenderer;

use WebinoDraw\Dom\Element;

/**
Expand Down
44 changes: 44 additions & 0 deletions src/WebinoDraw/Manipulator/Plugin/ViewSnippet.php
@@ -0,0 +1,44 @@
<?php
/**
* Webino (http://webino.sk)
*
* @link https://github.com/webino/WebinoDraw for the canonical source repository
* @copyright Copyright (c) 2012-2019 Webino, s. r. o. (http://webino.sk)
* @author Peter Bačinský <peter@bacinsky.sk>
* @license BSD-3-Clause
*/

namespace WebinoDraw\Manipulator\Plugin;

use Zend\View\Renderer\PhpRenderer;
use WebinoDraw\Dom\Element;

/**
* Class ViewSnippet
*/
class ViewSnippet extends AbstractPlugin implements InLoopPluginInterface
{
/**
* @param PluginArgument $arg
*/
public function inLoop(PluginArgument $arg)
{
$spec = $arg->getSpec();
if (empty($spec['render'])) {
return;
}

$node = $arg->getNode();
if (!$node instanceof Element) {
return;
}

$spec['instructions']['view-snippet'] = [
'locator' => 'view',
'render' => ['snippet' => '{$_snippet}'],
'replace' => '{$snippet}',
];

$arg->setSpec($spec);
}
}

0 comments on commit c88b528

Please sign in to comment.