diff --git a/Module.php b/Module.php
new file mode 100644
index 0000000..86356ba
--- /dev/null
+++ b/Module.php
@@ -0,0 +1,60 @@
+getParam('application');
+ $sm = $app->getServiceManager();
+ $options = $sm->get('goalioforgotpassword_module_options');
+
+ // Add the default entity driver only if specified in configuration
+ if ($options->getEnableDefaultEntities()) {
+ $chain = $sm->get('doctrine.driver.orm_default');
+ $chain->addDriver(new XmlDriver(__DIR__ . '/config/xml/zfcuserdoctrineorm'), 'ZfcUserDoctrineORM\Entity');
+ }
+ }
+
+ public function getAutoloaderConfig()
+ {
+ return array(
+ 'Zend\Loader\StandardAutoloader' => array(
+ 'namespaces' => array(
+ __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
+ ),
+ ),
+ );
+ }
+
+ public function getServiceConfig()
+ {
+ return array(
+ 'aliases' => array(
+ 'goalioforgotpassword_doctrine_em' => 'doctrine.entitymanager.orm_default',
+
+ ),
+ 'factories' => array(
+ 'goalioforgotpassword_module_options' => function ($sm) {
+ $config = $sm->get('Config');
+ return new Options\ModuleOptions(isset($config['goalioforgotpassword']) ? $config['goalioforgotpassword'] : array());
+ },
+ 'goalioforgotpassword_password_mapper' => function ($sm) {
+ return new \GoalioForgotPasswordDoctrineORM\Mapper\User(
+ $sm->get('goalioforgotpassword_doctrine_em'),
+ $sm->get('goalioforgotpassword_module_options')
+ );
+ },
+ ),
+ );
+ }
+
+ public function getConfig()
+ {
+ return include __DIR__ . '/config/module.config.php';
+ }
+}
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..beabcf0
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,29 @@
+{
+ "name": "goalio/goalio-forgotpassword-doctrine-orm",
+ "description": "Doctrine2 ORM storage adapter for GoalioForgotPassword.",
+ "type": "library",
+ "keywords": [
+ "zf2"
+ ],
+ "homepage": "https://github.com/goalio/GoalioForgotPasswordDoctrineORM",
+ "authors": [
+ {
+ "name": "Philipp Dobrigkeit",
+ "email": "p.dobrigkeit@goalio.de",
+ "homepage": "http://www.goalio.de"
+ }
+ ],
+ "require": {
+ "php": ">=5.3.3",
+ "goalio/goalio-forgotpassword": "0.*",
+ "doctrine/doctrine-orm-module": "0.*"
+ },
+ "autoload": {
+ "psr-0": {
+ "GoalioForgotPasswordDoctrineORM": "src/"
+ },
+ "classmap": [
+ "./Module.php"
+ ]
+ }
+}
\ No newline at end of file
diff --git a/config/module.config.php b/config/module.config.php
new file mode 100644
index 0000000..e1a79d0
--- /dev/null
+++ b/config/module.config.php
@@ -0,0 +1,17 @@
+ array(
+ 'driver' => array(
+ 'goalioforgotpassword_entity' => array(
+ 'class' => 'Doctrine\ORM\Mapping\Driver\XmlDriver',
+ 'paths' => __DIR__ . '/xml/goalioforgotpassword'
+ ),
+
+ 'orm_default' => array(
+ 'drivers' => array(
+ 'GoalioForgotPasswordDoctrineORM\Entity' => 'goalioforgotpassword_entity'
+ )
+ )
+ )
+ ),
+);
diff --git a/config/xml/goalioforgotpassword/GoalioForgotPassword.Entity.Password.dcm.xml b/config/xml/goalioforgotpassword/GoalioForgotPassword.Entity.Password.dcm.xml
new file mode 100644
index 0000000..0f728a4
--- /dev/null
+++ b/config/xml/goalioforgotpassword/GoalioForgotPassword.Entity.Password.dcm.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/config/xml/goalioforgotpassworddoctrineorm/GoalioForgotPasswordDoctrineORM.Entity.Password.dcm.xml b/config/xml/goalioforgotpassworddoctrineorm/GoalioForgotPasswordDoctrineORM.Entity.Password.dcm.xml
new file mode 100644
index 0000000..068df1c
--- /dev/null
+++ b/config/xml/goalioforgotpassworddoctrineorm/GoalioForgotPasswordDoctrineORM.Entity.Password.dcm.xml
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
diff --git a/src/GoalioForgotPasswordDoctrineORM/Entity/Password.php b/src/GoalioForgotPasswordDoctrineORM/Entity/Password.php
new file mode 100644
index 0000000..b085839
--- /dev/null
+++ b/src/GoalioForgotPasswordDoctrineORM/Entity/Password.php
@@ -0,0 +1,8 @@
+em = $em;
+ $this->options = $options;
+ }
+
+ public function remove($passwordModel)
+ {
+ $this->em->remove($passwordModel);
+ $this->em->flush();
+ }
+
+ public function findByUser($userId)
+ {
+ $er = $this->em->getRepository($this->options->getPasswordEntityClass());
+
+ return $er->findOneBy(array('user' => $userId));
+ }
+
+ public function findByUserIdRequestKey($userId, $key)
+ {
+ $er = $this->em->getRepository($this->options->getPasswordEntityClass());
+ return $er->findOneBy(array('user' => $userId, 'requestKey' => $key));
+ }
+
+ public function cleanExpiredForgotRequests($expiryTime=86400)
+ {
+
+ }
+
+ public function cleanPriorForgotRequests($userId)
+ {
+ $dql = sprintf("DELETE %s u WHERE u.user = %s", $this->options->getPasswordEntityClass(), $userId);
+ $query = $this->em->createQuery($dql);
+ $query->getResult();
+ }
+
+ public function persist($passwordModel)
+ {
+ $this->em->persist($passwordModel);
+ $this->em->flush();
+
+ return $passwordModel;
+ }
+
+}
\ No newline at end of file
diff --git a/src/GoalioForgotPasswordDoctrineORM/Options/ModuleOptions.php b/src/GoalioForgotPasswordDoctrineORM/Options/ModuleOptions.php
new file mode 100644
index 0000000..3d32ce4
--- /dev/null
+++ b/src/GoalioForgotPasswordDoctrineORM/Options/ModuleOptions.php
@@ -0,0 +1,35 @@
+enableDefaultEntities = $enableDefaultEntities;
+ return $this;
+ }
+
+ /**
+ * @return boolean
+ */
+ public function getEnableDefaultEntities()
+ {
+ return $this->enableDefaultEntities;
+ }
+}