Skip to content

Instantly share code, notes, and snippets.

<?php
class MCache
{
private $memcache;
private $memcachehost;
{
"grouped":{
"catalog_id":{
"matches":4,
"ngroups":1,
"groups":[{
"groupValue":3,
"doclist":{"numFound":4,"start":0,"maxScore":1.0,"docs":[
{
@mustafaileri
mustafaileri / gist:8840988
Last active June 23, 2017 11:04
Doctrine Filter Sample
$giftProducts = $cart->getItems()->filter(function($item) {
return $item->getTotal() == 0;
});
@mustafaileri
mustafaileri / gist:8945118
Created February 11, 2014 22:01
Sample test with mock
<?php
/**
* User: Mustafa Ileri
* Date: 7/28/13
* Time: 11:29 PM
* Please type something...
*/
namespace Hezarfen\Bundle\CmsBundle\Tests\Service;
@mustafaileri
mustafaileri / gist:8976423
Created February 13, 2014 14:56
phpist-backend
[
{
"id": 1,
"name": "6 Temmuz YTU",
"startDate": {
"date": "2013-07-06 09:00:00",
"timezone_type": 3,
"timezone": "Europe/Zurich"
},
"endDate": {
@mustafaileri
mustafaileri / gist:9659863
Last active August 29, 2015 13:57
Mocking methods by parameters
public function setRouterMock()
{
$routerMock = $this->getMockBuilder("Symfony\Bundle\FrameworkBundle\Routing\Router")->disableOriginalConstructor()
->disableOriginalConstructor()->setMethods(array("all", "getRouteCollection", "generate"))->getMock();
$routerMock->expects($this->any())->method("all")->will($this->returnValue(array()));
$routerMock->expects($this->any())->method("getRouteCollection")->will($this->returnValue($this->routeCollection));
$routerMock->expects($this->any())->method("generate")->withAnyParameters()->will($this->returnCallback(array($this, "generateUrlCallback")));
$this->routerMock = $routerMock;
@mustafaileri
mustafaileri / DoctrineEventListener.php
Last active August 29, 2015 14:03
Cache Invalidation with Doctrine2 EventListeners
<?php
namespace Joker\Bundle\CoreBundle\EventListener;
use Doctrine\ORM\Event\LifecycleEventArgs;
class DoctrineEventListener
<!-- The default high-performance update handler -->
<updateHandler class="solr.DirectUpdateHandler2">
<updateLog>
<str name="dir">${solr.ulog.dir:}</str>
</updateLog>
<autoSoftCommit>
<maxDocs>250</maxDocs>
<maxTime>10000</maxTime>
@mustafaileri
mustafaileri / settings.py
Last active December 5, 2016 20:47
drf-haystack_settings
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://elastic:9200/',
'INDEX_NAME': 'index?name',
},
}
@mustafaileri
mustafaileri / models.py
Last active December 5, 2016 21:19
drf-haystack-model
class Model(models.Model):
STATUS_CHOICES = (
('active', 'Aktif'),
('passive', 'Pasif'),
('redirected', 'Yönlendirilmiş')
)
TRACTION_CHOICES = (
('front-wheel-drive', 'Önden Çekişli'),
('rear-wheel-drive', 'Arkadan İtişli'),