Skip to content

Instantly share code, notes, and snippets.

View anyt's full-sized avatar

Andrii Yatsenko anyt

View GitHub Profile
<?php
class ManyToManyTest extends \PHPUnit_Framework_TestCase
{
public function testSynchronization()
{
$post = new Post();
$tag = new Tag();
$post->addTag($tag);
// Make sure that autopager plugin is loaded
if ($.autopager) {
if (!autopager_was_initialised) {
autopager_was_initialised = true;
var container = '#courses div.content';
var items_selector = container + ' > .course';
var pager_selector = container + ' > div.item-list ul.pager';
var next_selector = container + ' ' + 'li.pager-next a:first';
var img = '<div id="autopager-ajax-loader"><div class="ajax-loader"></div></div>';
$(pager_selector).hide();
<?php
class DomainToDTOMapper
{
public static function map(\Dto &$dto,\Domain $domain) {
foreach($dto as &$property) {
$property = call_user_func(array($domain, 'get' . ucfirst($property));
}
}
}
@anyt
anyt / Post.php
Created January 9, 2014 23:58
Count of Tags for Post in doctrine2 orm
<?php
namespace Anyt\BlogBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Post
*
<?php
namespace Anyt\BlogBundle\Twig;
class MaxTaggedPostsCountExtension extends \Twig_Extension
{
public function getFunctions()
{
return array(
new Twig_SimpleFunction('getTagWeight', 'getTagWeight'),
@anyt
anyt / config.yml
Created January 12, 2014 17:58
Enable doctrine2 underscore naming strategy in Symfony2.
doctrine:
orm:
naming_strategy: doctrine.orm.naming_strategy.underscore
<?php
require 'vendor/autoload.php';
// Create the mail transport configuration
$transport = Swift_MailTransport::newInstance();
// Create the message
$message = Swift_Message::newInstance();
$message->setTo(array(
@anyt
anyt / composer.json
Created January 22, 2014 22:54
add jquery and jquery ui to composer
"repositories": [
{
"type": "package",
"package": {
"name": "jquery/jquery",
"version": "1.10.2",
"dist": {
"url": "http://code.jquery.com/jquery-1.10.2.js",
"type": "file"
}
// примеры команд, которые выполняются при успешном сабмите формы
$.ajaxFormCommands = {
redirect: function (target) {
window.location.href = target;
},
reload: function () {
location.reload();
},
replace: function (newContent, target) {
"repositories": [
{
"type":"package",
"package": {
"name": "l3pp4rd/doctrine-extensions",
"version":"master",
"source": {
"url": "https://github.com/l3pp4rd/DoctrineExtensions.git",
"type": "git",
"reference":"master"