Skip to content

Instantly share code, notes, and snippets.

View Brammm's full-sized avatar

Bram Van der Sype Brammm

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

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 September 16, 2013 12:26
Time interval function
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 December 17, 2015 06:49
Overwriting/extending ACL permissions
/*
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 April 10, 2013 13:53
This is a basic AclManager service. It only handles ObjectAces. It provides a grant, revoke and revokeAll method.
<?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 April 3, 2013 07:19
Capifony example deploy script
#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"