Skip to content

Instantly share code, notes, and snippets.

View fprochazka's full-sized avatar
🏠
Working from home

Filip Procházka fprochazka

🏠
Working from home
View GitHub Profile
@fprochazka
fprochazka / test.md
Last active December 26, 2015 13:19
<?php

$article->getOne(); $article->one;
$article->getTwo(); $article->two; 
$article->getThree(); $article->three;
<?php
use Nette\Application\Routers\RouteList,
Nette\Application\Routers\Route,
Nette\Application\Routers\SimpleRouter;
use Nette\Utils\Strings;
/**
* Router factory.
@fprochazka
fprochazka / Configuration.php
Created May 12, 2013 18:33
WkhtmlToPDF abstraction that can run either localy or remotely, or even can be used as a hosted service.
<?php
/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008, 2012 Filip Procházka (filip@prochazka.su)
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/
<?php
// .phpstorm.meta.php
namespace NEON_META { // we want to avoid the pollution
$CONFIG_KEYS = [
'dibi' => [ 'host' => '', 'dbname' => '', 'user' => '', 'password' => '' ], // unobstrusive static definition
'nette' => \Nette\Config\Extensions\NetteExtension::$defaults, // no problem the property is actually not static
'nette' => [
'session' => [
@fprochazka
fprochazka / BasePresenter.php
Created April 17, 2013 14:04
Hack for lazylinks to
<?php
use Nette\Application\UI;
class BasePresenter extends UI\Presenter
{
/**
* Returns destination as Link object.
* @param string destination in format "[[module:]presenter:]view" or "signal!"
@fprochazka
fprochazka / ArraySessionStorage.php
Last active August 31, 2017 20:23
faking nette session in tests
<?php
/**
* Třída existuje, aby se vůbec neukládala session, tam kde není potřeba.
* Například v API, nebo v Cronu se různě sahá na session, i když se reálně mezi requesty nepřenáší.
*
* @internal
*/
class ArraySessionStorage extends Nette\Object implements Nette\Http\ISessionStorage
{

To je komponenta, která pouze zpracovává signál a vytváří odkazy systémovým způsobem, díky napojení na presenter.

<?php

	protected function createComponentFbLogin()
	{
		$dialog = $this->facebook->createDialog('login');
		/** @var LoginDialog $dialog */
 $dialog-&gt;onResponse[] = $this-&gt;facebookLoginResponse;
<?php
function handle($throw = FALSE)
{
try {
try {
throw new \LogicException('invalid xml');
} catch (\Exception $e) {
throw new \LogicException('', 0, $e); // wrap
@fprochazka
fprochazka / sorting-finder.php
Created December 21, 2012 19:37
Sorting finder results - directory first.
<?php
Finder::extensionMethod('sort', function (Finder $finder, $callback) {
$result = iterator_to_array($finder);
uasort($result, $callback);
return new \ArrayIterator($result);
});
$index = Finder::find('*')->in($dir)->sort(function (\SplFileInfo $a, \SplFileInfo $b) {
return $a->isDir() ? ($b->isDir() ? strnatcasecmp($a->getBasename(), $b->getBasename()) : -1)
<?php
/**
* This file is part of the Kdyby (http://www.kdyby.org)
*
* Copyright (c) 2008, 2012 Filip Procházka (filip@prochazka.su)
*
* For the full copyright and license information, please view the file license.txt that was distributed with this source code.
*/