Skip to content

Instantly share code, notes, and snippets.

View matej21's full-sized avatar

David Matějka matej21

View GitHub Profile
<?php
protected function tryCall($method, array $params)
{
$type = substr($method, 0, 6);
if ($type === 'action') {
$this->evm->dispatchEvent(get_class($this) . '::onBeforeAction', new EventArgsList([$this, $this->action]));
} elseif ($type === 'render') {
$this->evm->dispatchEvent(get_class($this) . '::onBeforeRender', new EventArgsList([$this, $this->view]));
}
$result = parent::tryCall($method, $params);
- Praha: http://srazy.info/nettefwpivo
- Brno: http://srazy.info/nettefwbrnopivo
- České Budějovice: http://srazy.info/nettefwcbpivo
- Smilovice: http://srazy.info/nettefwsmilovicepivo
- Plzeň: http://srazy.info/nettefwplzenpivo
- Hradec Králové: http://srazy.info/nettehkpivo
- Chrudim: http://srazy.info/nettefwchrudimpivo
- Pardubice: http://srazy.info/nettefwpardubicepivo
<?php
class SessionCleanerListener implements Kdyby\Events\Subscriber
{
private $session;
public function __construct(Nette\Http\Session $session)
{
$this->session = $session;
}
<?php
class CategorySpecification
{
private $category;
public function __construct($category)
{
$this->category = $category;
}
<?php
class MyFormFactory
{
public function create(BusinessCard $card)
{
$form = new Form;
$form->addText(...);
$form->onSuccess[] = function ($form) use ($card) {
$this->processForm($form, $card);
<?php
class RouterFactory
{
public /* static */ function createRouter()
{
$router = new Nette\Application\Routers\RouteList();
$router[] = $adminRouter = new Nette\Application\Routers\RouteList("Admin");
@matej21
matej21 / MessageFactory.php
Created January 15, 2015 16:14
Tovarna na message
<?php
interface MessageFactory
{
/**
* @return \Nette\Mail\Message
*/
public function create();
}
@matej21
matej21 / BasePresenter.php
Last active March 14, 2024 08:32
Backlink
<?php
/** @var string @persistent */
public $_backlink;
public function link($destination, $args = [])
{
$modifiers = [];
if (($pos = strrpos($destination, ')')) !== FALSE) {
$modifiers = array_fill_keys(explode(')(', substr($destination, 1, $pos - 1)), TRUE);
$destination = substr($destination, $pos + 1);
<?php
class Foo
{
public function __construct($id, FooModel $fooModel)
{
...
}
}
@matej21
matej21 / read.lua
Last active August 29, 2015 14:07
Redis script overujici invalidace zaznamu
local key = KEYS[1]
local val = redis.call("get", key)
if val == nil then
return nil
end
local tags = redis.call('sMembers', "Nette.Journal:" .. key .. ":tags")
local expirations = redis.call("hMGet", "invalidations", unpack(tags))
local added = nil