Skip to content

Instantly share code, notes, and snippets.

@Charlie-Lucas
Charlie-Lucas / WidgetSliderNavContentResolve1r.php
Last active March 16, 2017 10:19
First one is an exemple to default find record method, seccond is an exemple for custom find record
<?php
public function getWidgetBusinessEntityContent(Widget $widget)
{
$parameters = parent::getWidgetBusinessEntityContent($widget);
/** @var WidgetSliderNav $widget */
//get previous and next record if entity is set
if ($entity = $widget->getEntity()) {
@Charlie-Lucas
Charlie-Lucas / my.cnf
Created November 8, 2016 09:15
/etc/mysql/my.cnf
[mysqld]
sql-mode=""
<?php
public function getById($id)
{
$hash = "reference:" . $id;
return $this->unredislizeArray($this->redis->hgetall($hash));
}
<?php
public function unredislize($data)
{
$data = urldecode($data);
// unserialize data if we can
$unserializedData = @unserialize($data);
if($unserializedData !== false)
{
return $unserializedData;
}
<?php
public function redislize($data)
{
// Only serialize if it's not a string or a integer
if(!is_string($data) && !is_integer($data))
{
return urlencode(serialize($data));
}
// Encode string to escape wrong saves
return urlencode($data);
<?php
public function create(MonObjet $object)
{
$hash = "reference:" . $object->getId();
if($this->redis->exists($hash))
{
throw new \Exception('An redis hash "' . $hash . ' already exist');
}
$values = $this->transformObjectToArray($object);
$valuesReadyToRedis = $this->redislizeArray($array);
snc_redis:
clients:
victoire:
type: predis
alias: victoire
dsn: redis://localhost
<?php
new Snc\RedisBundle\SncRedisBundle(),