Skip to content

Instantly share code, notes, and snippets.

View fabiocarneiro's full-sized avatar

Fábio Carneiro fabiocarneiro

View GitHub Profile
<?php
namespace Product\Criteria;
use Doctrine\Common\Collections\Criteria;
/**
* Order the units by the last modified one
*
* @author Fábio Carneiro <fahecs@gmail.com>
<script>
function retrieveUf(latitude,longitude){
var request = new XMLHttpRequest();
var method = 'GET';
var url = 'http://maps.googleapis.com/maps/api/geocode/json?latlng='+latitude+','+longitude+'&sensor=true';
var async = true;
request.open(method, url, async);
request.send();
<?php
class Router {
protected $routes = array();
protected $namedRoutes = array();
protected $basePath = '';
protected $matchTypes = array(
'i' => '[0-9]++',
'a' => '[0-9A-Za-z]++',
public function extract()
{
if ($this->object instanceof Traversable) {
$this->object = ArrayUtils::iteratorToArray($this->object, false);
}
if (!is_array($this->object)) {
return array();
}
<?php
public function addAction()
{
$album = new Album;
$form = new AlbumForm($this->getEntityManager());
$form->setHydrator(new DoctrineEntity($this->getEntityManager(),'Admin\Entity\Album'));
-- element --
string 'Cart\Form\ProductFieldset' (length=25)
-- object --
object(Product\Entity\Product)[539]
protected 'id' => int 31
protected 'sku' => string 'PH043' (length=5)
protected 'name' => string 'FONE COM MICROFONE USB DIGITAL PC / PLAYSTATION 3' (length=49)
protected 'slug' => string 'fone-com-microfone-usb-digital-pc-playstation-3' (length=47)
-- hydrator target class --
string 'Product\Entity\Product' (length=22)
<?php
use Zend\Form\Fieldset;
use Zend\Form\Form;
use Zend\Form\View\Helper\Form as FormHelper;
use Zend\Form\View\HelperConfig;
use Zend\Stdlib\ArrayUtils;
use Zend\Stdlib\Hydrator\ObjectProperty;
use Zend\View\Renderer\PhpRenderer;
<?php
namespace Cart;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
class Module
{
class cart {
public $item;
public function getItem() {
return $this->item;
}
public function setItem(&$item) {
$this->item = $item;
}
public function getFreightForm() {
$form = new Form();
$items = $this->session->offsetGet('list');
foreach ($items as $i => $consumer) {
$fieldset = new Fieldset($i);
foreach ($consumer->getItems() as $token => $item) {
$fieldset->add(array(
'type' => 'text',