Skip to content

Instantly share code, notes, and snippets.

View bakura10's full-sized avatar

Michaël Gallego bakura10

View GitHub Profile
<?php
class Foo
{
public function myMethod()
{
$myData = [];
// MyData is filled with approximately 50-500 elements, but with a lot of attributes inside each element.
// BUT one of the property inside each element is an iterator. Therefore each element looks a bit like this:
<?php
class UserController
{
/**
* @var EntityManagerInterface
*/
private $entityManager;
public function create()
<?php
class UserRegistrationService
{
private $em;
private $service1;
private $service2;
.collection,
.search {
.products-list {
.grid-item {
@include grid($collection-items-per-row, $collection-horizontal-gutter, $collection-vertical-gutter);
}
}
}
.products-list {
.newest-products {
.products-list {
.grid-item {
@include grid($home-items-per-row, $home-horizontal-gutter, $home-vertical-gutter);
}
}
.price {
color: red; // Ceci ne s'applique que pour le .price contenu dans .newest-products
}
.new-products {
background-color: $index-newest-products-background;
.product-list {
.grid-item {
@include grid($index-newest-products-items-per-row, $index-newest-products-horizontal-gutter, $index-newest-products-vertical-gutter);
}
}
.index-section-title {
private function convertToZfResponse(ResponseInterface $response)
{
$zfResponse = new HttpResponse();
$zfResponse->setStatusCode($response->getStatusCode());
$zfResponse->setReasonPhrase($response->getReasonPhrase());
$zfResponse->setContent((string) $response->getBody());
foreach ($response->getHeaders() as $name => $values) {
$zfResponse->getHeaders()->addHeaderLine($name, implode(", ", $values));
<header class="header" role="banner">
<div class="header__wrapper">
<!-- Le plus "logique" serait "header__item__sidebar-toggle" mais c'est trop lourd. J'ai aussi pensé à créer un
nouveau "contexte" et faire header-item__sidebar-toggle mais je trouvais ça illogique d'avoir header__item et header-item
sur le même élément !-->
<div class="header__item header__item__sidebar-toggle">
<a href="#"></a>
</div>
</div>
</header>
<!-- Let's say we have a "block" that displays a product's title and price: -->
<div class="product-meta">
<h2 class="product-meta__title">Foo</h2>
<p class="product-meta__price">Price</h2>
</div>
<!-- This block has specific styling on a given page. There are other pages when this block is actually included
inside another block. Most styles will be the same, but with very little variations.-->
@bakura10
bakura10 / Row helper use cases
Created June 29, 2012 20:31
Form Row Helper use cases
The form row helper is a utility helper that allow to reduce the boilerplate code of a view file by automatically generating a label (if specified), a form element and errors that may arise during validation.
Simple example
Let's add an element :
$this->add(array(
'type' => 'Zend\Form\Element\Color',
'name' => 'one_color'
));