Skip to content

Instantly share code, notes, and snippets.

@gusdecool
Created November 4, 2013 06:16
Show Gist options
  • Save gusdecool/7298722 to your computer and use it in GitHub Desktop.
Save gusdecool/7298722 to your computer and use it in GitHub Desktop.
How singleton passing property to child
<?php
class Place
{
/**
* @var string
*/
private $key;
/**
* @var PlaceNearby
*/
private $nearby
public function __construct($key)
{
$this->key = $key;
$this->nearby = new PlaceNearby();
}
}
<?php
Class PlaceNearby
{
public function __construct()
{
// do something here
}
public function execute()
{
// How can i get my parent key (@_@)
$this->parent->key;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment