Skip to content

Instantly share code, notes, and snippets.

View matej21's full-sized avatar

David Matějka matej21

View GitHub Profile
<?php
/**
* @author David Matejka
*/
class Identity extends \Nette\Object implements \Nette\Security\IIdentity
{
/** @var int */
protected $id;
<?php
class MyAuthenticator extends Nette\Object implements IAuthenticator
{
/** @var array */
private $userlist;
/**
* @param array list of pairs username => password
*/
<?php
use Nette\Http\Request;
class RefUrlFactory extends Object
{
/** @var \Nette\Http\Url */
protected $fallbackUrl;
/** @var \Nette\Http\Request */
<?php
public function beforeCompile()
{
$builder = $this->getContainerBuilder();
$targetServiceDef = $builder->getDefinition($this->prefix('serviceName'));
foreach ($builder->findByTag('myTag') as $name => $attrs) {
$def = $builder->getDefinition($name);
$targetServideDef->addSetup('addFoo', array($def));
}
<?php
interface IUserAccessor
{
/**
* @return \Nette\Security\User
*/
public function get();
}
@matej21
matej21 / default.latte
Created August 2, 2014 20:41
Invalidace formularovych prvku
{snippetArea form}
{form myForm}
{inlineSnippet name}
{input name}
{/inlineSnippet}
{input ok}
{/form}
{/snippetArea}
<a n:href="redraw!" class="ajax">prekresli</a>
@matej21
matej21 / Gruntfile.js
Last active August 29, 2015 14:04
grunt + webloader
uglify: {
options: {
compress: false,
sourceMap: true
},
front: {
files: {
'./www/dist/front/output.js': [
"./www/vendor/jquery/dist/jquery.js",
"./www/vendor/nette.ajax.js/nette.ajax.js",
@matej21
matej21 / Presenter.php
Created August 7, 2014 23:27
nested snippets
<?php
$this->redrawControl('snippet-nested-sub2');
@matej21
matej21 / FooControl.php
Created August 12, 2014 10:41
komponenty
<?php
use Nette\Application\UI;
class FooControl extends UI\Control
{
public function __construct(...)
{
//predani parametru a zavislosti
}
@matej21
matej21 / config.neon
Last active August 29, 2015 14:05
Base třídy - konečné řešení
extensions:
setup: Librette\Setup\SetupExtension
setup:
#nastavi sitename na vsech presenterech, ktery dedi od BasePresenteru a jsou registrovany v DIC
-
type: [App\BasePresenter]
setup:
- setSiteName('example.com')
#zapne inject na vsech komponentach (i tech, ktere jsou vytvareny gen. tovarnickou), ktere dedi od BaseControlu
-