Skip to content

Instantly share code, notes, and snippets.

@matej21
Last active August 29, 2015 14:06
Show Gist options
  • Save matej21/b995cf61678718839a8b to your computer and use it in GitHub Desktop.
Save matej21/b995cf61678718839a8b to your computer and use it in GitHub Desktop.
librette/forms - factory na formular a formular rozsireny o podporu mapperu, mapper nacita hodnoty z formulare a uklada nekam (do entit)
librette/doctrine - jen par utilit pro praci s entitama
librette/doctrine-forms - doctrine form mapper a factory na formular. Doporucuji ji injectovat (Librette\Doctrine\Forms\FormFactory), pak se nemusis starat o ukladani dat :)
librette/security-namespaces - moznost rozdeleni authenticatoru a autorizatoru dle namespace v user storage (vice v doc nette, je to tam zmineny, ze muzes diky tomu mit vic identit)
librette/security-extension - zakladni authenticator pro doctrinu, user entita a komponenty pro editaci usera, login a jeste neco myslim.... :D
"require": {
"librette/forms": "@dev",
"librette/doctrine": "@dev",
"librette/doctrine-forms": "@dev",
"librette/security-namespaces": "@dev",
"librette/security-extension": "@dev"
}
extensions:
securityNamespaces: Librette\SecurityNamespaces\DI\SecurityNamespacesExtension
security: Librette\SecurityExtension\DI\SecurityExtension
libretteDoctrine: Librette\Doctrine\DI\DoctrineExtension
services:
- Librette\Forms\FormFactory #pokud mas registrovany translation, automaticky se preda. stejne tak muzes jako sluzbu registrovat form renderer
- Librette\Doctrine\Forms\FormFactory #stara se o propojeni form factory s mapper factory
-
class: Librette\Doctrine\Forms\Mapper
implement: \Librette\Doctrine\Forms\MapperFactory
parameters: [entity, offset = NULL]
arguments: [%entity%, %offset%]
security:
namespaces:
admin: Muj\Namespace\User
<?php
class SecuredPresneter extends BasePresenter
{
public function checkRequirements($element)
{
$this->user->storage->setNamespace('admin'); //stejny jako v configu
if (!$this->getUser()->isLoggedIn()) {
$this->redirect($this->getLoginPage()); //nejaka tvoje kontrola
}
}
}
<?php
namespace Muj\Namespace;
use Doctrine\ORM\Mapping as ORM;
use Librette\SecurityExtension\Models\UserEntity;
/**
* @author David Matejka
* @ORM\Entity
* @ORM\Table(name="app_user")
*/
class User extends UserEntity
{
}
/*
pokud chces, aby mel user i username, implementuj Librette\SecurityExtension\Models\INamedUser
defaultni implementace tohohle rozhrani je dostupna v Librette\SecurityExtension\Models\TNamedUser
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment