Delete exports and imports where the class is not valid
modifié: core/lib/Thelia/Core/Template/Loop/ImportExportType.php modifié: core/lib/Thelia/Model/Export.php modifié: core/lib/Thelia/Model/Import.php
This commit is contained in:
@@ -13,6 +13,7 @@
|
|||||||
namespace Thelia\Core\Template\Loop;
|
namespace Thelia\Core\Template\Loop;
|
||||||
use Propel\Runtime\ActiveQuery\Criteria;
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||||
|
use Propel\Runtime\Exception\ClassNotFoundException;
|
||||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||||
use Thelia\Core\Template\Element\LoopResult;
|
use Thelia\Core\Template\Element\LoopResult;
|
||||||
use Thelia\Core\Template\Element\LoopResultRow;
|
use Thelia\Core\Template\Element\LoopResultRow;
|
||||||
@@ -48,15 +49,20 @@ abstract class ImportExportType extends BaseI18nLoop implements PropelSearchLoop
|
|||||||
$this->getBaseUrl() . DS . $type->getId()
|
$this->getBaseUrl() . DS . $type->getId()
|
||||||
);
|
);
|
||||||
|
|
||||||
$loopResultRow
|
try {
|
||||||
->set("ID", $type->getId())
|
$loopResultRow
|
||||||
->set("TITLE", $type->getVirtualColumn("i18n_TITLE"))
|
->set("HANDLE_CLASS", $type->getHandleClass())
|
||||||
->set("DESCRIPTION", $type->getVirtualColumn("i18n_DESCRIPTION"))
|
->set("ID", $type->getId())
|
||||||
->set("URL", $url)
|
->set("TITLE", $type->getVirtualColumn("i18n_TITLE"))
|
||||||
->set("POSITION", $type->getPosition())
|
->set("DESCRIPTION", $type->getVirtualColumn("i18n_DESCRIPTION"))
|
||||||
->set("CATEGORY_ID", $type->getByName($this->getCategoryName()))
|
->set("URL", $url)
|
||||||
->set("HANDLE_CLASS", $type->getHandleClass())
|
->set("POSITION", $type->getPosition())
|
||||||
;
|
->set("CATEGORY_ID", $type->getByName($this->getCategoryName()))
|
||||||
|
;
|
||||||
|
} catch(ClassNotFoundException $e) {
|
||||||
|
|
||||||
|
} catch(\ErrorException $e) {}
|
||||||
|
|
||||||
|
|
||||||
$loopResult->addRow($loopResultRow);
|
$loopResult->addRow($loopResultRow);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
namespace Thelia\Model;
|
namespace Thelia\Model;
|
||||||
|
|
||||||
use Propel\Runtime\ActiveQuery\Criteria;
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Propel\Runtime\Connection\ConnectionInterface;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\ImportExport\Export\DocumentsExportInterface;
|
use Thelia\ImportExport\Export\DocumentsExportInterface;
|
||||||
@@ -110,6 +111,8 @@ class Export extends BaseExport
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
|
$this->delete();
|
||||||
|
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
Translator::getInstance()->trans(
|
Translator::getInstance()->trans(
|
||||||
"The class \"%class\" doesn't exist",
|
"The class \"%class\" doesn't exist",
|
||||||
@@ -123,6 +126,8 @@ class Export extends BaseExport
|
|||||||
$instance = new $class($container);
|
$instance = new $class($container);
|
||||||
|
|
||||||
if (!$instance instanceof ExportHandler) {
|
if (!$instance instanceof ExportHandler) {
|
||||||
|
$this->delete();
|
||||||
|
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
Translator::getInstance()->trans(
|
Translator::getInstance()->trans(
|
||||||
"The class \"%class\" must extend %baseClass",
|
"The class \"%class\" must extend %baseClass",
|
||||||
@@ -137,6 +142,28 @@ class Export extends BaseExport
|
|||||||
return static::$cache = $instance;
|
return static::$cache = $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConnectionInterface $con
|
||||||
|
*
|
||||||
|
* Handle the position of other exports
|
||||||
|
*/
|
||||||
|
public function delete(ConnectionInterface $con = null)
|
||||||
|
{
|
||||||
|
$imports = ExportQuery::create()
|
||||||
|
->filterByPosition($this->getPosition(), Criteria::GREATER_THAN)
|
||||||
|
->find()
|
||||||
|
;
|
||||||
|
|
||||||
|
foreach ($imports as $import) {
|
||||||
|
$import->setPosition($import->getPosition() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$imports->save();
|
||||||
|
|
||||||
|
parent::delete($con);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function hasImages(ContainerInterface $container)
|
public function hasImages(ContainerInterface $container)
|
||||||
{
|
{
|
||||||
if (static::$cache === null) {
|
if (static::$cache === null) {
|
||||||
|
|||||||
@@ -2,11 +2,17 @@
|
|||||||
|
|
||||||
namespace Thelia\Model;
|
namespace Thelia\Model;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
use Propel\Runtime\ActiveQuery\Criteria;
|
use Propel\Runtime\ActiveQuery\Criteria;
|
||||||
|
use Propel\Runtime\Connection\ConnectionInterface;
|
||||||
|
use Propel\Runtime\Exception\ClassNotFoundException;
|
||||||
|
use Propel\Runtime\Exception\PropelException;
|
||||||
|
use Propel\Runtime\Propel;
|
||||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
use Thelia\Core\Translation\Translator;
|
use Thelia\Core\Translation\Translator;
|
||||||
use Thelia\ImportExport\Import\ImportHandler;
|
use Thelia\ImportExport\Import\ImportHandler;
|
||||||
use Thelia\Model\Base\Import as BaseImport;
|
use Thelia\Model\Base\Import as BaseImport;
|
||||||
|
use Thelia\Model\ImportQuery as ChildImportQuery;
|
||||||
use Thelia\Model\Map\ImportTableMap;
|
use Thelia\Model\Map\ImportTableMap;
|
||||||
|
|
||||||
class Import extends BaseImport
|
class Import extends BaseImport
|
||||||
@@ -102,7 +108,9 @@ class Import extends BaseImport
|
|||||||
$class = $this->getHandleClass();
|
$class = $this->getHandleClass();
|
||||||
|
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
throw new \ErrorException(
|
$this->delete();
|
||||||
|
|
||||||
|
throw new ClassNotFoundException(
|
||||||
Translator::getInstance()->trans(
|
Translator::getInstance()->trans(
|
||||||
"The class \"%class\" doesn't exist",
|
"The class \"%class\" doesn't exist",
|
||||||
[
|
[
|
||||||
@@ -115,6 +123,8 @@ class Import extends BaseImport
|
|||||||
$instance = new $class($container);
|
$instance = new $class($container);
|
||||||
|
|
||||||
if (!$instance instanceof ImportHandler) {
|
if (!$instance instanceof ImportHandler) {
|
||||||
|
$this->delete();
|
||||||
|
|
||||||
throw new \ErrorException(
|
throw new \ErrorException(
|
||||||
Translator::getInstance()->trans(
|
Translator::getInstance()->trans(
|
||||||
"The class \"%class\" must extend %baseClass",
|
"The class \"%class\" must extend %baseClass",
|
||||||
@@ -128,4 +138,27 @@ class Import extends BaseImport
|
|||||||
|
|
||||||
return $instance;
|
return $instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ConnectionInterface $con
|
||||||
|
*
|
||||||
|
* Handle the position of other imports
|
||||||
|
*/
|
||||||
|
public function delete(ConnectionInterface $con = null)
|
||||||
|
{
|
||||||
|
$imports = ImportQuery::create()
|
||||||
|
->filterByPosition($this->getPosition(), Criteria::GREATER_THAN)
|
||||||
|
->find()
|
||||||
|
;
|
||||||
|
|
||||||
|
foreach ($imports as $import) {
|
||||||
|
$import->setPosition($import->getPosition() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$imports->save();
|
||||||
|
|
||||||
|
parent::delete($con);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user