Skip to content

Instantly share code, notes, and snippets.

View treetop1500's full-sized avatar

Robert Wade treetop1500

  • Gray Loon Marketing Group
  • Salt Lake City, Utah
View GitHub Profile
@treetop1500
treetop1500 / Page.php
Created September 12, 2016 16:55
Page Entity for Symfony 3 Projects (Extends BaseContent)
<?php
namespace Common\ContentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\Common\Collections\ArrayCollection;
use Common\ContentBundle\Entity\BaseContent;
@treetop1500
treetop1500 / Product.php
Created September 12, 2016 16:57
Product Entity for Symfony3 Projects (Extends BaseContent)
<?php
namespace Common\ContentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Doctrine\Common\Collections\ArrayCollection;
use Gedmo\Mapping\Annotation as Gedmo;
@treetop1500
treetop1500 / twig_extension_icon.txt
Last active September 14, 2016 20:44
Twig Extensions
/**
* @param string $class
* @return string
* returns a proper, accessible font-awesome icon.
* usage: {{ icon('fa-download') }}
*/
function icon($class)
{
return "<i class=\"fa $class\" aria-hidden=\"true\"></i>";
@treetop1500
treetop1500 / doctrine_extensions.yml
Created September 15, 2016 14:29
doctrine extensions yml file for Gedmo extensions
# services to handle doctrine extensions
# import it in config.yml
services:
# KernelRequest listener
extension.listener:
class: AppBundle\Listener\DoctrineExtensionListener
calls:
- [ setContainer, [ "@service_container" ] ]
tags:
# translatable sets locale after router processing
@treetop1500
treetop1500 / twig_extension_price.php
Created September 16, 2016 16:22
Twig Extensions:twig_extension_price.php
/**
* @param $amt
* @return string
* strips out non-numeric characters and adds the +1 country code.
*/
function price($amt)
{
return '<span class="dollar-sign">$</span>'.number_format($amt,2);
}
@treetop1500
treetop1500 / sass-alpha-color-loop.scss
Last active September 22, 2016 15:49
For generating classes with alpha using rgb
@mixin alphaColor ($name,$color) {
@for $i from 1 through 10 {
.c-#{$name}-#{$i} {
color: rgba($color,$i/10);
}
}
}
@include alphaColor("blue",blue);
@include alphaColor("red",#ed1414);
@treetop1500
treetop1500 / SassMeister-input.scss
Last active September 22, 2016 19:10
Looping sass and incrementing by 3
// ----
// Sass (v3.4.21)
// Compass (v1.0.3)
// ----
.box {
@for $i from 0 through 9 {
$c : $i + 1;
&:nth-child(#{$c}) {
order: (($i - $i % 3) / 3) + 1;
@treetop1500
treetop1500 / FroalaController.php
Last active September 26, 2016 13:15
Froala Image Receiver Controller
<?php
/**
* Created by PhpStorm.
* User: grayloon
* Date: 9/3/16
* Time: 7:39 AM
*
* Set these routes up!!
* # froala receive route for file uploads
* froala_receiver:
@treetop1500
treetop1500 / flash_msg.txt
Last active September 30, 2016 15:21
Flash Message
// controller delete action:
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
...
try {
$em->remove($entity);
$em->flush();
} catch(ForeignKeyConstraintViolationException $e) {
$this->addFlash('warning', 'This item is in use by related entities and cannot be deleted.');
}
@treetop1500
treetop1500 / config_dev.yml
Last active October 3, 2016 15:50
Monolog Config
monolog:
handlers:
main:
type: rotating_file
path: %kernel.logs_dir%/%kernel.environment%.log
level: error
max_files: 10
action_level: error
bubble: true
grouped: