Skip to content

Instantly share code, notes, and snippets.

<?php
declare(strict_types=1);
namespace App\Twig\Extension;
use Twig\Environment;
use Twig\Extension\AbstractExtension;
use Twig\TwigFunction;
class ExampleComponentExtension extends AbstractExtension
{
@freema
freema / sample.php
Created January 18, 2019 14:21
Error / Warning tracy production mode exception
<?php
$configurator = new Nette\Config\Configurator;
$configurator->enableDebugger(__DIR__ . '/log');
$configurator->setTempDirectory(__DIR__ . '/temp');
if(\Tracy\Debugger::$productionMode === TRUE) {
set_error_handler(function($severity, $message, $file, $line, $context) {
\Tracy\Debugger::log("$message in $file:$line", \Tracy\Debugger::ERROR);
$e = new ErrorException($message, 0, $severity, $file, $line);
@freema
freema / config.neon
Created April 15, 2016 09:43
Nette presenter DI container params setter
services:
HomepagePresenter:
class: FrontModule\HomepagePresenter()
setup:
- $tempPath(%tempPath%)
#nebo
- FrontModule\HomepagePresenter()
@freema
freema / cursor.php
Created April 14, 2016 11:50
The array cursor same key restard
$array = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15);
$restart = TRUE;
while (list($key, $value) = each($array)) {
if($key === 5 && $restart) {
prev($array);
$restart = FALSE;
}
var_dump($key);
@freema
freema / gwapiv2.txt
Last active November 29, 2016 14:53
Guild wars API v2 description
** Public API v2 **
Usage:
The API follows the general pattern of enumerating possible values of the
subsequent path segment, with the fully qualified path yielding a json object
of the type being enumerated.
For example, /v2/colors will yield:
[1, 2, 3, ... ]
<?php
use Nette\Application\UI\InvalidLinkException;
use Nette\Application\UI\Presenter;
use Tracy\Debugger;
abstract class BasePresenter extends Presenter {
/**
* @param InvalidLinkException $e
@freema
freema / gist:3ed19d6160793d8cde5d
Last active August 29, 2015 14:14
Nette latte flashmessage by twitter boostrap 3
<div n:if="count($flashes) > 0" n:foreach="$flashes as $flash" role="alert" class="alert alert-{$flash->type}">
{$flash->message}
</div>
<div n:foreach="$flashes as $flash" class="alert alert-{$flash->type}">
<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
{$flash->message}
</div>
@freema
freema / gist:edb7849805e99e0b9cbf
Last active September 1, 2016 07:36
Nette twitter boostrap 3 submit to button
<?php
$form = new Form();
$form->addSubmit('submit', NULL)
->setAttribute("title", "vložení do košíku")
->setAttribute("alt", "vložení do košíku");
$vybratBtn = $form['submit']->getControlPrototype();
$vybratBtn->setName("button");
$vybratBtn->type = 'submit';
$vybratBtn->create('i class="fa fa-shopping-cart"');
@freema
freema / @layout.latte
Created January 30, 2015 10:07
Nette separate rendering of js and html content
{control test:HTML}
{control test:JS}
@freema
freema / NeonBulder.php
Last active August 29, 2015 14:02
NeonBulder
<?php
namespace Model;
use Exception;
use Nette\DI\Config\Adapters\NeonAdapter;
use Nette\IOException;
use Nette\Utils\Neon;
/**
* Description of NeonBuilder