‘code snippets’ ile ilgili yazılar

Symfony 2: Setting Cookies

Symfony 2 is great but it’s not well documented yet and there is no documentation about cookie handling as well. After a few code digging I’ve found the solution. As we know, basically, cookies are just HTTP headers and you can get them from requests or send with responses. Symfony\Component\HttpFoundation\Response class has a public property named [...]

Symfony 2: Getting Current Route in Twig

Twig: {{ app.request.attributes.get(‘_route’) }} Php: $app->getRequest()->attributes->get(‘_route’) Controller: $this->container->get(‘request’)->attributes->get(‘_route’)

Javascript: Remove Element From Array

var myArray = ['foo', 'bar']; var elementIndex = myArray.indexOf(‘bar’); // Finding index of the element we want to remove if (elementIndex != -1) { myArray.splice(elementIndex, 1); } console.log(myArray);