Skip to content

Instantly share code, notes, and snippets.

<?php
namespace OverrideBundle;
use Doctrine\ODM\MongoDB\Types\Type;
use Symfony\Component\HttpKernel\Bundle\Bundle;
class OverrideBundle extends Bundle
{
public function __construct()
/**
* @MongoDB\PreFlush
* @return ArrayCollection
*/
public function orderSteps()
{
//workaround to sort steps collection
$iterator = $this->steps->getIterator();
$iterator->uasort(
function ($a, $b) {
/**
*@Route("/sendHello")
*/
public function helloAction(Request $request)
{
$data = $this->someModel->process($someInput);
//return something
}
<?php
namespace Ma7shy\BackendBundle\Form\Type\Field;
use Doctrine\ODM\MongoDB\DocumentManager;
use Ma7shy\BackendBundle\Form\Transformer\ObjectToDocumentTransformer;
use Ma7shy\BackendBundle\Form\Transformer\ObjectToRefTransformer;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\OptionsResolver\OptionsResolverInterface,
@AhmedSamy
AhmedSamy / gist:10870928
Created April 16, 2014 13:01
Sorting embeded collection
function getSortedIngredients()
{
//workaround to sort ingredients by quantities collection
$iterator = $this->ingredients->getIterator();
$iterator->uasort(
function ($a, $b) {
return ($a->getQuantity() > $b->getQuantity()) ? -1 : 1;
}
);
Install update to apt-get
sudo apt-get install python-software-properties
PHP
—————
sudo add-apt-repository ppa:ondrej/php5
sudo apt-get update
sudo apt-get upgrade
@AhmedSamy
AhmedSamy / Mongoc.php
Created March 14, 2014 13:09
Refresh doctrine odm
mongoc ()
{
php app/console doctrine:mongodb:cache:clear-metadata;
php app/console doctrine:mongodb:mapping:info;
php app/console doctrine:mongodb:generate:hydrators;
php app/console doctrine:mongodb:generate:proxies
}
@AhmedSamy
AhmedSamy / 0_reuse_code.js
Created March 14, 2014 13:07
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
$(document).ready(function () {
$("#list2").jqGrid(
{
url: '{{ path('edfa3ly_backend_banner_jq') }}',
datatype: "json",
colNames: ['ID', 'Status', 'Title'],
colModel: [
{name: 'id', index: '_id', width: 300},
{name: 'status', index: 'status', width: 300},
{name: 'title', index: 'title', width: 300}