- 2 ответа
- 0 вопросов
2
Вклад в тег
<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>
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();
}
}
}