Skip to content

Instantly share code, notes, and snippets.

View KaiCMueller's full-sized avatar

Kai Müller KaiCMueller

View GitHub Profile
// global array
array = new Array();
Selenium.prototype.doStoreCellValue = function(variableName,cellPosition)
{
var xy = cellPosition.split(",");
var x = xy[0] - 1;
var y = xy[1] - 1;
var value = array[x][y];
storedVars[variableName] = value;
@KaiCMueller
KaiCMueller / AdminController.php
Last active April 2, 2018 11:49
Add template parameters in EasyAdmin
<?php
namespace App\Controller;
use EasyCorp\Bundle\EasyAdminBundle\Controller\AdminController as BaseAdminController;
/**
* General controller for administrating all entities
*/
class AdminController extends BaseAdminController
@KaiCMueller
KaiCMueller / services.yaml
Last active June 18, 2018 12:36
Symfony Framework: Using methods and constants in service parameters
services:
My\Custom\Service:
class: My\Custom\Service
arguments:
- "@=service('My\\\\Custom\\\\Config').getCustomString()"
- !php/const My\Custom\ServiceConstants::MY_CONSTANT
- "@=container.hasParameter('some_param') ? parameter('some_param') : 'default_value'"
@KaiCMueller
KaiCMueller / layout.html.twig
Last active July 3, 2018 11:35
Extending the EasyAdmin core template
{# this template is located in templates/bundles/EasyAdminBundle/default/layout.html.twig #}
{# pay attention to the "!" in front of the bundle name which tells symfony to use the core template #}
{% extends '@!EasyAdmin/default/layout.html.twig' %}
{% block head_javascript %}
{{ parent() }}
{% block application_javascript %}{% endblock application_javascript %}
{% endblock head_javascript %}
@KaiCMueller
KaiCMueller / index.js
Last active March 20, 2019 11:58
Cordova app which loads a website in full screen and opens external links in system browser
var appUrl = 'https://www.my-website.com';
var app = {
currentUrl: appUrl,
initialize: function() {
document.addEventListener('deviceready', this.onDeviceReady.bind(this), false);
},
@KaiCMueller
KaiCMueller / doctrine_order_by_null_values_first.php
Created September 16, 2019 12:27
Doctrine: Order by NULL values first
<?php
$queryBuilder
->addSelect("(CASE WHEN entity.placedDate IS NULL THEN 1 ELSE 0 END) AS HIDDEN PLACED")
->orderBy('PLACED', 'DESC')
->addOrderBy('entity.placedDate', 'DESC');
@KaiCMueller
KaiCMueller / WorkingDaysCalculator.php
Created April 6, 2020 12:53
Calculation of next working day date
class WorkingDaysCalculator
{
const SUNDAY = 0;
const SATURDAY = 6;
/**
* Get next working day date
*
* @param \DateTime $baseDate - default now
* @param int $additionalWorkingDays - default 0
@KaiCMueller
KaiCMueller / menu.html.twig
Created December 12, 2018 16:27
EasyAdmin: Active entity menu items
{% macro render_menu_item(item, translation_domain) %}
{% if item.type == 'divider' %}
{{ item.label|trans(domain = translation_domain) }}
{% else %}
{% set menu_params = { menuIndex: item.menu_index, submenuIndex: item.submenu_index } %}
{% set path =
item.type == 'link' ? item.url :
item.type == 'route' ? path(item.route, item.params) :
item.type == 'entity' ? path('easyadmin', { entity: item.entity, action: 'list' }|merge(menu_params)|merge(item.params)) :
item.type == 'empty' ? '#' : ''
@KaiCMueller
KaiCMueller / TablePrefixEventListener.php
Created February 21, 2020 09:06
Symfony: Add an automatic table prefix with Doctrine
<?php
namespace App\EventListener;
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
use Doctrine\ORM\Mapping\ClassMetadataInfo;
class TablePrefixEventListener
{
/**
@KaiCMueller
KaiCMueller / getCalendarYearWeek.php
Last active July 16, 2020 14:42
Get year and week number as 6 digit integer from any DateTime object including fix for in between the years
<?php
/**
* @param \DateTime $dateTime
*
* @return int - e.g. 202001
*/
protected function getCalendarYearWeek(DateTime $dateTime): int
{
$week = $dateTime->format('W');