From 819ed07c516ac224e3fbb8ab5215701ee33e6c0c Mon Sep 17 00:00:00 2001 From: Thomas Flori Date: Wed, 29 May 2019 10:02:37 +0200 Subject: [PATCH] create a static query method to get an entity fetcher for the entity --- src/Entity.php | 10 ++++++++++ tests/Entity/HelperTest.php | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 tests/Entity/HelperTest.php diff --git a/src/Entity.php b/src/Entity.php index 7170988..6a994a6 100644 --- a/src/Entity.php +++ b/src/Entity.php @@ -132,6 +132,16 @@ public static function getColumnName($attribute) ->getColumnName(static::class, $attribute, static::$columnPrefix, static::$namingSchemeColumn); } + /** + * Create an entityFetcher for this entity + * + * @return EntityFetcher + */ + public static function query() + { + return EM::getInstance(static::class)->fetch(static::class); + } + /** * Get the primary key vars * diff --git a/tests/Entity/HelperTest.php b/tests/Entity/HelperTest.php new file mode 100644 index 0000000..2e8b599 --- /dev/null +++ b/tests/Entity/HelperTest.php @@ -0,0 +1,18 @@ +fetch(Article::class), $fetcher); + } +}