Skip to content

Instantly share code, notes, and snippets.

@guiwoda
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guiwoda/629e6e9f883c6659b6bd to your computer and use it in GitHub Desktop.
Save guiwoda/629e6e9f883c6659b6bd to your computer and use it in GitHub Desktop.
Embeddables with inheritance
<?php
abstract class Framework {
/**
* @type bool
*/
private $installsGlobally;
abstract public function download();
}
class Symfony extends Framework {
public function download() {
return 'git clone git@github.com:symfony/symfony.git';
}
}
class Phalcon extends Framework {
public function download() {
return 'pear install phalcon'; // idk
}
}
class Project {
/**
* @type Framework
*/
private $framework;
/**
* @type string
*/
private $name;
/**
* @type User
*/
private $owner;
}
Framework:
type: embeddable
fields:
installsGlobally: { type: boolean }
inheritanceType: SINGLE_TABLE
discriminatorColumn:
name: discr
type: string
discriminatorMap:
symfony: Symfony
phalcon: Phalcon
Project:
embedded:
framework:
class: ???
@guiwoda
Copy link
Author

guiwoda commented Dec 18, 2014

It's a silly example, but I guess the point is clear: Allow inheritance of embeddable types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment