$(window).bind('statechange', function () {
var State = History.getState();
var url = State.url;
var data = State.data;
if (ajaxRequest) {
ajaxRequest.abort();
} else {
$resultContainer.html('<div class="ajax-loader" style="position:relative;"><img src="http://i.imgur.com/6RMhx.gif" /></div>');
}
ajaxRequest = $.ajax({
url: url,
data: data,
dataType: 'json',
success: function (data, textStatus, jqXHR) {
$resultContainer.html(data.content);
if (data.form) {
$filterForm.html(data.form);
filterFormInitCallback();
}
ajaxRequest = null;
},
error: function (jqXHR, textStatus, errorThrown) {
if ('abort' != textStatus) {
document.location.href = url;
}
return false;
}
});
});
$filterForm.submit(function () {
var query = $(this).formSerialize();
// decodeURIComponent т.к. formSerialize выдает закодированный урл, а histoty.js пытается закодировать его еще раз
History.pushState(null, document.title, '?' + window.decodeURIComponent(query));
return false;
});
defaults: { _controller: TestTestBundle:Test:index }
defaults: { _controller: test:indexAction }
<?php
$name = 'name';
$title = 'title';
$text = 'text';
$body = <<<BODY
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>$title</title>
</head>
<body>
<h1>$title<h1>
<p>$text</p>
</body>
</html>
BODY;
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename=' . sprintf('%s.html', $name));
header('Content-Length: ' . sizeof($body));
echo $body;
interface VotableInterface
{
public function setRating($rating);
}
class Object implements VotableInterface
{
/**
* @ORM\Column(type="integer")
*/
private $rating;
public function setRating($rating)
{
$this->rating = $rating;
}
public function getRating()
{
return $this->rating;
}
}
class VoteListener
{
public function postPersist(LifecycleEventArgs $event)
{
$vote = $event->getEntity();
if (!$vote instanceof Vote) {
return;
}
/**
* @var Object $entity
*/
$entity = $vote->getEntityObject();
if (!$entity instanceof VotableInterface) {
// Exception
}
$entity->setRating($entity->getRating() + $vote->getValue());
// Update $entity
}
}
$(document).ready(function(){
$('.list-h-item').addClass("hidden").viewportChecker({
callbackFunction: function(elem, action) {
$('.list-h-item').addClass('visible');
$('.list-h-item').each(function(i) {
$(this).delay((i++) * 500).fadeTo(1000, 2); });
});
}
});
});
$dateFormatter = new \IntlDateFormatter(
'ru',
\IntlDateFormatter::FULL,
\IntlDateFormatter::FULL,
new \DateTimeZone('UTC'),
IntlDateFormatter::GREGORIAN,
'dd MMM yyyy HH:mm:ss'
);
$string = '06 окт. 2014 21:45:17';
var_dump($string);
$timestamp = $dateFormatter->parse($string);
$test = new \DateTime(sprintf('@%s UTC', $timestamp));
var_dump($test);
{{ object_path(entity) }}
$compiledRoute = $route->compile();
$variables = $compiledRoute->getVariables();
$parameters = array();
if (!empty($variables)) {
foreach ($variables as $variable) {
$parameters[$variable] = $this->getObjectProperty($object, $variable);
}
}
return $this->router->generate($name, $parameters);
{{ object_path('route_name', entity) }}
Все необходимые параметры возьмутся из модели. Удобно для CRUD getRequest()
и getDoctrine()
$this->getDoctrine()->getManager()->getRepository('...')
сам пока не решил.