Skip to content

Commit

Permalink
Added overview of used snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
shyim committed Aug 27, 2017
1 parent 84e9b6c commit af76841
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 2 deletions.
73 changes: 73 additions & 0 deletions Components/Smarty/SnippetResource.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace ShyimProfiler\Components\Smarty;

use Smarty;
use Smarty_Internal_Template;
use Smarty_Template_Source;

/**
* Class SnippetResource
* @package ShyimProfiler\Components\Smarty
* @author Soner Sayakci <[email protected]>
*/
class SnippetResource extends \Enlight_Components_Snippet_Resource
{
/**
* @var array
* @author Soner Sayakci <[email protected]>
*/
private $snippets = [];

/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
if (!isset($source->smarty->registered_plugins[Smarty::PLUGIN_BLOCK]['snippet'])) {
$source->smarty->registerPlugin(Smarty::PLUGIN_BLOCK, 'snippet', array(__CLASS__, 'compileSnippetBlock'));
}
if (!isset($source->smarty->registered_plugins[Smarty::PLUGIN_MODIFIER]['snippet'])) {
$source->smarty->registerPlugin(Smarty::PLUGIN_MODIFIER, 'snippet', array($this, 'compileSnippetModifier'));
}
$default_resource = $source->smarty->default_resource_type;
$source->smarty->default_resource_type = 'file';
parent::populate($source, $_template);
$source->smarty->default_resource_type = $default_resource;
}

/**
* @param $namespace
* @param $name
* @param $default
* @param bool $force
* @return mixed
* @author Soner Sayakci <[email protected]>
*/
protected function getSnippet($namespace, $name, $default, $force = false)
{
$result = parent::getSnippet($namespace, $name, $default, $force);

$this->snippets[$namespace . '|' . $name] = [
'namespace' => $namespace,
'name' => $name,
'default' => $default,
'force' => $force,
'content' => $result
];

return $result;
}

/**
* @return array
* @author Soner Sayakci <[email protected]>
*/
public function getUsedSnippets()
{
return $this->snippets;
}
}
6 changes: 6 additions & 0 deletions Resources/services.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,11 @@
<argument type="service" id="shyim_profiler.decoration.debuglogger.inner"/>
<argument type="string">Debuglogger</argument>
</service>

<service id="snippet_resource"
class="ShyimProfiler\Components\Smarty\SnippetResource">
<argument type="service" id="snippets"/>
<argument>%shopware.snippet.showSnippetPlaceholder%</argument>
</service>
</services>
</container>
2 changes: 1 addition & 1 deletion Resources/views/@Toolbar/_resources/css/toolbar.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions Resources/views/@Toolbar/_resources/css/toolbar.less
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,13 @@
bottom: -2px;
left: -2px;
}

.table-fill {
width: 100%;
}

.btn-snippet-fixed {
position: fixed;
bottom: 50px;
right: 20px;
}
Loading

0 comments on commit af76841

Please sign in to comment.