Skip to content

Instantly share code, notes, and snippets.

View Ocramius's full-sized avatar
🔬
In your repositories, watching your code. Always watching.

Marco Pivetta Ocramius

🔬
In your repositories, watching your code. Always watching.
View GitHub Profile
<?php
namespace BLAHBLAH\GraphLoader;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Instantiator\Instantiator;
use BLAHBLAH\Exception\UnexpectedValueException;
final class ArrayObjectGraphLoader implements ArrayObjectGraphLoaderInterface
@Ocramius
Ocramius / Product.php
Last active January 31, 2016 16:48
Association as an Identifier (Doctrine2)
<?php
class Product
{
/** @ORM\Column @ORM\Id ... */
private $id;
}
@Ocramius
Ocramius / README.md
Last active January 22, 2024 00:09
`__invoke` vs `function` vs `Closure`
@Ocramius
Ocramius / BrutalForeignKeyDisablingMySQLPurger.php
Created March 4, 2015 09:55
Brutal ORM Purger for doctrine/data-fixtures
<?php
namespace FixturesStuff
use Doctrine\Common\DataFixtures\Purger\ORMPurger;
use Doctrine\ORM\EntityManagerInterface;
/**
* @TODO this has to go once we implement correct purging of entities
*/
@Ocramius
Ocramius / SimpleFixtureLoader.php
Created March 3, 2015 16:57
Simple array-based fixture loader for Doctrine ORM
<?php
namespace FixtureLoader;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Instantiator\Instantiator;
class SimpleFixtureLoader
{
@Ocramius
Ocramius / example.js
Created February 24, 2015 22:13
EventSourcing for Angular Repository actions reflows
(function (exports) {
function EventBus() {
this.handlers = [];
}
EventBus.prototype.push = function (event) {
foreach (idx in this.handlers) {
if (this.handler[idx].canHandle(event)) {
this.handler[idx].handle(event);
}
@Ocramius
Ocramius / nested-transactions.php
Created January 20, 2015 12:59
Multiple nested Doctrine2 EntityManager transactions pseudo-code
<?php
use doctrine\ORM\EntityManagerInterface;
$entityManager->transactional(function (EntityManagerInterface $entityManager) {
// first transaction
$entityManager->transactional(function () {
// nested transaction #1
});
@Ocramius
Ocramius / Foo54b039119141f998026307.php
Created January 9, 2015 20:25
ProxyManager generated GhostObject
<?php
namespace ProxyManagerTest\Functional;
class Foo54b039119141f998026307 extends \ProxyManagerTestAsset\ClassWithCollidingPrivateInheritedProperties implements \ProxyManager\Proxy\GhostObjectInterface
{
/**
* @var \Closure|null initializer responsible for generating the wrapped object
*/
<?php
namespace MyModule;
use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\Filter\Word\CamelCaseToUnderscore;
use Zend\Db\Resultset\HydratingResultSet;
use Zend\Stdlib\Hydrator\ClassMethods;
<div class="ngCellText" ng-class="col.colIndex()" style="padding-top:5px; padding-left:5px;">
<span ng-cell-text>
{{console.log(row)}}
{{row.getProperty(col.id)}}
<button type="button" class="btn btn-sm btn-default" title="Edit peddler">
<span class="glyphicon glyphicon-edit"></span>
</button>
<button type="button" class="btn btn-sm btn-default" title="Pricing forumulas" ng-click="viewPricingFormulas()">
<span class="glyphicon glyphicon-usd"></span>