Skip to content

Instantly share code, notes, and snippets.

Avatar

Bram Van der Sype Brammm

View GitHub Profile
@Brammm
Brammm / Menu Active Setter thingie
Last active Aug 29, 2015
How to set parent menu items active
View Menu Active Setter thingie
<?php
// A very silly representation of our menu.
$menu = [
[
'title' => 'Home',
'uri' => '/',
'active' => false,
],
[
'title' => 'Category',
@Brammm
Brammm / PHP_Interview.md
Last active Dec 25, 2015
Some useful questions for a PHP interview
View PHP_Interview.md

PHP interview

  • Are you familiar with the tools we're given in PHP 5.4 to write Object Oriented code?
    We can manipulate scope, have interfaces, abstract classes, traits, namespaces…

  • What's the difference between Public, Protected and Private?
    Public ensures a class method/variable is available everywhere, from any instance of the class. Protected makes the method/variable only available to the class itself and extending classes. Private makes the method/var only accessible to the class itself.

  • Do you know any of these acronyms?

    • DRY "Don't Repeat Yourself"
@Brammm
Brammm / gist:6580046
Created Sep 16, 2013
Time interval function
View gist:6580046
public function timeAgo(\Datetime $then)
{
$now = new \Datetime('now');
$interval = $then->diff($now);
$points = array(
'y' => array('year', 'years'),
'm' => array('month', 'months'),
'd' => array('day', 'days'),
@Brammm
Brammm / gist:5568265
Last active Dec 17, 2015
Overwriting/extending ACL permissions
View gist:5568265
/*
In security.yml I declared a parameter (for the life of me, I can't remember if this was important):
# security.yml
parameters:
security.acl.permission.map.class: Acme\DemoBundle\Security\Acl\Permission\PermissionMap
In services.yml I redeclare the acl collection cache service:
@Brammm
Brammm / AclManager.php
Created Apr 10, 2013
This is a basic AclManager service. It only handles ObjectAces. It provides a grant, revoke and revokeAll method.
View AclManager.php
<?php
namespace Smoovi\CoreBundle\Security;
use Symfony\Component\Security\Acl\Model\AclProviderInterface,
Symfony\Component\Security\Acl\Domain\ObjectIdentity,
Symfony\Component\Security\Acl\Domain\UserSecurityIdentity;
use Smoovi\CoreBundle\Security\Acl\Permission\MaskBuilder;
@Brammm
Brammm / gist:5299083
Created Apr 3, 2013
Capifony example deploy script
View gist:5299083
#logger.level = Logger::MAX_LEVEL
#default_run_options[:pty] = true
set :application, "moovly"
set :stage, "staging"
set :branch, "develop"
set :domain, "#{stage}.#{application}.com"
set :deploy_to, "/var/www/html/sites/#{domain}"
set :app_path, "app"