<head>
...
<script type="text/javascript" src="//vk.com/js/api/openapi.js?113"></script>
<script type="text/javascript">
VK.init({apiId: ваш_appId, onlyWidgets: true});
</script>
</head>
<body>
...
<div id="vk_like"></div>
<script type="text/javascript">
VK.Widgets.Like("vk_like", {type: "button"});
VK.Observer.subscribe("widgets.like.shared", function f() {
alert('Молодец!');
});
</script>
location ~* ^.+.(jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|mid|midi|wav|bmp|rtf|js|html|flv|mp3)\$ {
expires 7d;
}
location ~ ^/media/cache/my_thumb/uploads/files/.+\.(png|jpeg|jpg|gif)\$ {
try_files \$uri @rewriteapp;
}
location @rewriteapp {
rewrite ^(.*)\$ /app.php/\$1 last;
}
try_files \$uri @rewriteapp;
class PurchaseListener {
protected $notifications = array();
public function preUpdate(LifecycleEventArgs $args) {
$entity = $args->getEntity();
$em = $args->getEntityManager();
if ($entity instanceof Purchase) {
...
$notification = new Notification();
$notification->setUser($entity->getUser())
->setText('блабла')
->setType('success');
$this->notifications[] = $notification;
...
}
}
public function postFlush(PostFlushEventArgs $event)
{
if(count($this->notifications)>0) {
$em = $event->getEntityManager();
foreach ($this->notifications as $thing) {
$em->persist($thing);
}
$this->notifications = array();
$em->flush();
}
}
}