Skip to content

Instantly share code, notes, and snippets.

View iampersistent's full-sized avatar

Rich Shank iampersistent

View GitHub Profile
class PSR7Connector
{
public function fromTheOutside($prs7)
{
$this->transformerFriendly = $psr7->getBody()->getContents();
}
public function dataForTransformer(): array
{
return $this->transformerFriendly;
public function transform($conncetorIn, $connectorOut, AbstractTransformer $transformer, $fieldMap = '*', $resourceClass = Item::class)
{
$resource = new $resourceClass($data, '', $fieldMap);
$transformed = $transformer->transform($conncetorIn->dataForTransformer());
$connectorOut->dataFromTransformer($transformed);
}
@iampersistent
iampersistent / gist:19d63d2521ca525629a8
Created October 1, 2015 19:53
Installing ext-intl OSX Yosemite
curl http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz > autoconf.tar.gz
tar -xvzf autoconf.tar.gz
cd autoconf-2.69
./configure
sudo make && sudo make install
export PHP_AUTOCONF=/usr/local/bin/autoconf
from browser - http://sourceforge.net/projects/icu/files/ICU4C/55.1/icu4c-55_1-src.tgz/download
cd ~/Downloads
tar xzvf icu4c-55_1-src.tgz
@iampersistent
iampersistent / gist:6204679
Created August 11, 2013 12:29
merging repos
git clone (target repo url)
cd dir
git remote add added (added repo url)
git fetch added
git pull added master
fix conflicts
git add -m 'added repo'
git push origin master
git remote add additional (additional repo url)
git fetch additional
@iampersistent
iampersistent / gist:2880690
Created June 6, 2012 08:39
filters for testing for valid links in indexer
use CamelSpider\Entity\LinkFilter
class Indexer extends AbstractSpider
{
protected $linkFilters;
// these could added in a compiler pass in the DI
public function addLinkFilter(LinkFilter $filter)
{
$this->linkFilters[] = $filter;
@iampersistent
iampersistent / SimpleCartPricingProvider.php
Created March 14, 2012 09:16
old SimpleCartPricingProvider, in case the code is needed for a handler
<?php
/**
* (c) 2011-2012 Vespolina Project http://www.vespolina-project.org
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Vespolina\CartBundle\Pricing;
@iampersistent
iampersistent / Controller
Created August 28, 2011 02:00
using SonataMediaBundle w/o SonataAdminBundle
// in controller ...
$mgr = $this->get('sonata.media.manager.media');
$pool = $this->get('sonata.media.pool');
$class = $mgr->getClass();
$medium = new $class();
$medium->setProviderName('sonata.media.provider.image');
$form = $this->createForm(new MediaFormType(), $medium);
@iampersistent
iampersistent / gist:1119337
Created August 2, 2011 00:35
config for key value
->arrayNode('identifiers')
->useAttributeAsKey('key')
->prototype('scalar')
->end()
->end()
@iampersistent
iampersistent / gist:781393
Created January 16, 2011 00:03
mongodb conditional operators
is this possible
{"_id": {"$ne":{ObjectId('1234554321'), ObjectId('543212345')}}}
Substitute "$ne" for any conditional operator and find the right syntax for multiple ObjectId()s
I'm needing this for the doctrine mongodb-orm
@iampersistent
iampersistent / gist:772693
Created January 10, 2011 12:08
security config
# app/config/security.yml
security.config:
providers:
fos_user:
id: fos_user.user_manager
firewalls:
public:
pattern: .*
form_login:
login_path: /login