Skip to content

Instantly share code, notes, and snippets.

<?php
// In controller...
public function getReportAcrossDatabasesAction(Request $request)
{
// Listen for Gearman to notify that it has data from a completed job.
$this->get('event_dispatcher')
->addListener('gearman.client.callback.complete',array($this,'gearmanCallback'));
$gearman = $this->get('gearman');
@daum
daum / gist:9259785
Last active November 17, 2015 06:51
Gearman worker
<?php
<?php
namespace My\DemoBundle\Gearman\Worker;
use Mmoreram\GearmanBundle\Driver\Gearman;
use Symfony\Component\DependencyInjection\Container;
/**
* @Gearman\Work(
* iterations = 30,
* description = "Test worker",
@daum
daum / gist:9259700
Created February 27, 2014 21:14
Gearman Sample
<?php
// In controller
public function triggerSendNotificationsAction(Request $request)
{
// Code to get that user triggered a bunch of notifications to an array of user ids.
$userIds = array(.......);
$message = 'some message from the frontend user';
//Get Gearman and tell it to run in the background a 'job'
$this->get('gearman')->doBackgroundJob('MyDemoBundleWorker~sendNotificationsToUsers',
Checking query: select * from sf_guard_user u LEFT JOIN sf_guard_user_profile p ON u.id=p.id
FK not found for u.id (sf_guard_user.id) join on p.id (sf_guard_user_profile.id)! Available mappings:
-sf_guard_user_group.group_id=>sf_guard_group.id
-sf_guard_user_group.user_id=>sf_guard_user.id
-sf_guard_user_permission.permission_id=>sf_guard_permission.id
-sf_guard_user_permission.user_id=>sf_guard_user.id
-sf_guard_user_profile.user_id=>sf_guard_user.id
-sf_guard_user_profile.participant_source_id=>participant_source.id
<?php
/**
* @Route("/login-token/{token}/{userHash}", name="participant_autologin_token")
* @ParamConverter("autologinToken", class="MyBundle:AutologinToken", options={"repository_method" = "findByTokenJoinWithUser"})
* @Template()
*/
public function autoLoginAction(Request $request, AutologinToken $autologinToken, $userHash){
....
}
public function checkAvailableFunds($data,ExecutionContextInterface $context)
{
if($data['oneField']===1&&$data['twoField']===3){
$context->addViolation('No or not enough giftcodes for selected export are available!');
}
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(
array('constraints'=>array(new Callback(array('methods'=>array(array($this,'checkAvailableFunds'))))),
)
);
}
<?php
use Symfony\Component\ClassLoader\ApcClassLoader;
use Symfony\Component\HttpFoundation\Request;
$loader = require_once __DIR__.'/../app/bootstrap.php.cache';
// Use APC for autoloading to improve performance.
// Change 'sf2' to a unique prefix in order to prevent cache key conflicts
// with other applications also using APC.
{"success":true,"msg":"","data":[]}
<?php
namespace Setfive\DemoBundle\Listener;
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use Symfony\Component\Security\Http\Event\SwitchUserEvent;
class LoginListener
{
/**