Skip to content

Instantly share code, notes, and snippets.

@technetium
technetium / .Propagating-awareness-via-ManyToOne-associations.md
Created April 14, 2016 07:47
Propagating awareness via ManyToOne associations

Propagating awareness via ManyToOne associations

Introduction

Michaël Perrin has written an article about using annotation and filters improve security.

With a more complex model, for example an order that contains products, you want also to filter on the associations of the filtered entity.

@technetium
technetium / distance.sql
Last active March 29, 2019 10:26
Create a function to calculate the distance between two points on the earth. This function assumes the input to be decimal degrees and the earth to be a sphere with a radius of 6371 km
CREATE FUNCTION distance (lat1 REAL, lng1 REAL, lat2 REAL, lng2 REAL)
RETURNS REAL DETERMINISTIC
RETURN 2 * 6371 * ASIN(SQRT(
SIN(RADIANS(lat1 - lat2)/2) * SIN(RADIANS(lat1 - lat2)/2) +
COS(RADIANS(lat1)) * COS(RADIANS(lat2)) *
SIN(RADIANS(lng1 - lng2)/2) * SIN(RADIANS(lng1 - lng2)/2)
));
@technetium
technetium / Association-management-methods.md
Last active October 26, 2018 08:13
Association Management Methods

Altough the Doctrine documentation about Working with associations states: "proper bidirectional association management in plain OOP is a non-trivial task and encapsulating all the details inside the classes can be challenging" I've used the following management methods (getters. setters, adders and removers) quite successfully.