transientAttributes)) {
- $this->set($propName, $Record->get($propName, true));
+ $this->set($propName, $record->get($propName, true));
} elseif (!$propObj->isPrivate() && isset($this->$propName) && $this->$propName instanceof Relation) {
$prop = $this->getPropObject($propName);
@@ -2595,7 +2631,8 @@ public static function checkDatabaseExists()
{
$config = ConfigProvider::getInstance();
- $provider = ActiveRecordProviderFactory::getInstance($config->get('db.provider.name'), new Person());
+ $provider = ServiceFactory::getInstance($config->get('db.provider.name'), 'Alpha\Model\ActiveRecordProviderInterface');
+ $provider->setRecord(new Person());
return $provider->checkDatabaseExists();
}
@@ -2611,7 +2648,8 @@ public static function createDatabase()
{
$config = ConfigProvider::getInstance();
- $provider = ActiveRecordProviderFactory::getInstance($config->get('db.provider.name'), new Person());
+ $provider = ServiceFactory::getInstance($config->get('db.provider.name'), 'Alpha\Model\ActiveRecordProviderInterface');
+ $provider->setRecord(new Person());
$provider->createDatabase();
}
@@ -2626,7 +2664,8 @@ public static function dropDatabase()
{
$config = ConfigProvider::getInstance();
- $provider = ActiveRecordProviderFactory::getInstance($config->get('db.provider.name'), new Person());
+ $provider = ServiceFactory::getInstance($config->get('db.provider.name'), 'Alpha\Model\ActiveRecordProviderInterface');
+ $provider->setRecord(new Person());
$provider->dropDatabase();
}
}
diff --git a/Alpha/Model/ActiveRecordProviderFactory.php b/Alpha/Model/ActiveRecordProviderFactory.php
deleted file mode 100644
index 0c2db3b4..00000000
--- a/Alpha/Model/ActiveRecordProviderFactory.php
+++ /dev/null
@@ -1,106 +0,0 @@
-
- *
- * @version $Id: ActiveRecordProviderFactory.php 1842 2014-11-12 22:27:01Z alphadevx $
- *
- * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
- * @copyright Copyright (c) 2017, John Collins (founder of Alpha Framework).
- * All rights reserved.
- *
- *
- * Redistribution and use in source and binary forms, with or
- * without modification, are permitted provided that the
- * following conditions are met:
- *
- * * Redistributions of source code must retain the above
- * copyright notice, this list of conditions and the
- * following disclaimer.
- * * Redistributions in binary form must reproduce the above
- * copyright notice, this list of conditions and the
- * following disclaimer in the documentation and/or other
- * materials provided with the distribution.
- * * Neither the name of the Alpha Framework nor the names
- * of its contributors may be used to endorse or promote
- * products derived from this software without specific
- * prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
- * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
- * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- */
-class ActiveRecordProviderFactory
-{
- /**
- * Trace logger.
- *
- * @var \Alpha\Util\Logging\Logger
- *
- * @since 1.1
- */
- private static $logger = null;
-
- /**
- * A static method that attempts to return a ActiveRecordProviderInterface instance
- * based on the name of the provider class supplied.
- *
- * @param string $providerName The fully-qualified class name of the provider class.
- * @param ActiveRecord $Record The (optional) active record instance to pass to the persistance provider for mapping.
- *
- * @throws \Alpha\Exception\IllegalArguementException
- *
- * @return \Alpha\Model\ActiveRecordProviderInterface
- *
- * @since 1.1
- */
- public static function getInstance($providerName, $Record = null)
- {
- if (self::$logger == null) {
- self::$logger = new Logger('ActiveRecordProviderFactory');
- }
-
- self::$logger->debug('>>getInstance(providerName=['.$providerName.'], Record=['.print_r($Record, true).'])');
-
- if (class_exists($providerName)) {
- $instance = new $providerName();
-
- if (!$instance instanceof ActiveRecordProviderInterface) {
- throw new IllegalArguementException('The class ['.$providerName.'] does not implement the expected ActiveRecordProviderInterface interface!');
- }
-
- if ($Record instanceof ActiveRecord) {
- $instance->setRecord($Record);
- }
-
- self::$logger->debug('<debug('<get('session.provider.name');
- $session = SessionProviderFactory::getInstance($sessionProvider);
+ $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
// get the class attributes
$reflection = new ReflectionClass(get_class($this->record));
@@ -1040,7 +1040,7 @@ public function saveAttribute($attribute, $value)
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
- $session = SessionProviderFactory::getInstance($sessionProvider);
+ $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
if ($this->record->getVersion() != $this->record->getVersionNumber()->getValue()) {
throw new LockingException('Could not save the object as it has been updated by another user. Please try saving again.');
diff --git a/Alpha/Model/ActiveRecordProviderSQLite.php b/Alpha/Model/ActiveRecordProviderSQLite.php
index beac587c..f8df802a 100644
--- a/Alpha/Model/ActiveRecordProviderSQLite.php
+++ b/Alpha/Model/ActiveRecordProviderSQLite.php
@@ -15,7 +15,7 @@
use Alpha\Model\Type\Boolean;
use Alpha\Util\Config\ConfigProvider;
use Alpha\Util\Logging\Logger;
-use Alpha\Util\Http\Session\SessionProviderFactory;
+use Alpha\Util\Service\ServiceFactory;
use Alpha\Exception\AlphaException;
use Alpha\Exception\FailedSaveException;
use Alpha\Exception\FailedDeleteException;
@@ -472,9 +472,9 @@ public function loadAll($start = 0, $limit = 0, $orderBy = 'ID', $order = 'ASC',
if (!$ignoreClassType && $this->record->isTableOverloaded()) {
if ($limit == 0) {
- $sqlQuery = 'SELECT ID FROM '.$this->record->getTableName().' WHERE classname = \''.addslashes(get_class($this->record)).'\' ORDER BY '.$orderBy.' '.$order.';';
+ $sqlQuery = 'SELECT ID FROM '.$this->record->getTableName().' WHERE classname = \''.get_class($this->record).'\' ORDER BY '.$orderBy.' '.$order.';';
} else {
- $sqlQuery = 'SELECT ID FROM '.$this->record->getTableName().' WHERE classname = \''.addslashes(get_class($this->record)).'\' ORDER BY '.$orderBy.' '.$order.' LIMIT '.
+ $sqlQuery = 'SELECT ID FROM '.$this->record->getTableName().' WHERE classname = \''.get_class($this->record).'\' ORDER BY '.$orderBy.' '.$order.' LIMIT '.
$limit.' OFFSET '.$start.';';
}
} else {
@@ -833,7 +833,7 @@ public function save()
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
- $session = SessionProviderFactory::getInstance($sessionProvider);
+ $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
// get the class attributes
$reflection = new ReflectionClass(get_class($this->record));
@@ -1070,7 +1070,7 @@ public function saveAttribute($attribute, $value)
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
- $session = SessionProviderFactory::getInstance($sessionProvider);
+ $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
if ($this->record->getVersion() != $this->record->getVersionNumber()->getValue()) {
throw new LockingException('Could not save the object as it has been updated by another user. Please try saving again.');
@@ -1606,7 +1606,7 @@ public function getCount($attributes = array(), $values = array())
self::$logger->debug('>>getCount(attributes=['.var_export($attributes, true).'], values=['.var_export($values, true).'])');
if ($this->record->isTableOverloaded()) {
- $whereClause = ' WHERE classname = \''.addslashes(get_class($this->record)).'\' AND';
+ $whereClause = ' WHERE classname = \''.get_class($this->record).'\' AND';
} else {
$whereClause = ' WHERE';
}
diff --git a/Alpha/Model/Article.php b/Alpha/Model/Article.php
index 7bb998eb..2869ba52 100644
--- a/Alpha/Model/Article.php
+++ b/Alpha/Model/Article.php
@@ -9,7 +9,7 @@
use Alpha\Model\Type\Relation;
use Alpha\Util\Config\Configprovider;
use Alpha\Util\Logging\Logger;
-use Alpha\Util\Http\Session\SessionProviderFactory;
+use Alpha\Util\Service\ServiceFactory;
use Alpha\Exception\ValidationException;
use Alpha\Exception\FileNotFoundException;
use Alpha\Exception\AlphaException;
@@ -486,7 +486,7 @@ public function checkUserVoted()
{
$config = ConfigProvider::getInstance();
$sessionProvider = $config->get('session.provider.name');
- $session = SessionProviderFactory::getInstance($sessionProvider);
+ $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface');
// just going to return true if nobody is logged in
if ($session->get('currentUser') == null) {
return true;
diff --git a/Alpha/Model/Person.php b/Alpha/Model/Person.php
index ce8f4c54..eeb698d4 100644
--- a/Alpha/Model/Person.php
+++ b/Alpha/Model/Person.php
@@ -8,7 +8,7 @@
use Alpha\Util\Helper\Validator;
use Alpha\Util\Logging\Logger;
use Alpha\Util\Config\ConfigProvider;
-use Alpha\Util\Email\EmailProviderFactory;
+use Alpha\Util\Service\ServiceFactory;
use Alpha\Exception\RecordNotFoundException;
/**
@@ -408,7 +408,7 @@ public function sendMail($message, $subject)
$body .= '