From 0ae9c562e4567b90a2f7bc383c26060e5ff9095c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 14 Oct 2013 14:58:08 +0200 Subject: [PATCH 01/50] tax rule edition --- .../Core/Template/Loop/TaxRuleCountry.php | 112 +++++++++++------- templates/admin/default/tax-rule-edit.html | 44 +++++-- 2 files changed, 105 insertions(+), 51 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php b/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php index 91616f398..ee20a3d20 100644 --- a/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php +++ b/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php @@ -32,6 +32,7 @@ use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; +use Thelia\Model\CountryQuery; use Thelia\Model\Map\CountryTableMap; use Thelia\Model\Map\TaxRuleCountryTableMap; use Thelia\Model\Map\TaxTableMap; @@ -58,8 +59,14 @@ class TaxRuleCountry extends BaseI18nLoop protected function getArgDefinitions() { return new ArgumentCollection( - Argument::createIntTypeArgument('country'), - Argument::createIntListTypeArgument('taxes'), + Argument::createIntTypeArgument('country', null, true), + new Argument( + 'ask', + new TypeCollection( + new Type\EnumType(array('taxes', 'countries')) + ), + 'taxes' + ), Argument::createIntTypeArgument('tax_rule', null, true) ); } @@ -73,40 +80,54 @@ class TaxRuleCountry extends BaseI18nLoop { $search = TaxRuleCountryQuery::create(); + $ask = $this->getAsk(); + $country = $this->getCountry(); - $taxes = $this->getTaxes(); + $taxRule = $this->getTax_rule(); - if((null === $country && null === $taxes)) { - throw new \InvalidArgumentException('You must provide either `country` or `taxes` parameter in tax-rule-country loop'); - } + if($ask === 'countries') { + $taxCountForOriginCountry = TaxRuleCountryQuery::create()->filterByCountryId($country)->count(); - if((null === $country && null !== $taxes)) { - throw new \InvalidArgumentException('You must provide `country` parameter with `taxes` parameter in tax-rule-country loop'); - } + if($taxCountForOriginCountry > 0) { + $search->groupByCountryId(); - if(null !== $taxes) { - $search->groupByCountryId(); + $originalCountryJoin = new Join(); + $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', 'origin'); + $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', 'origin'); + $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', null, TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', 'origin'); + $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', 'origin', Criteria::NOT_EQUAL); + $originalCountryJoin->setJoinType(Criteria::LEFT_JOIN); - $originalCountryJoin = new Join(); - $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_RULE_ID', 'origin'); - $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'TAX_ID', 'origin'); - $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', null, TaxRuleCountryTableMap::TABLE_NAME, 'POSITION', 'origin'); - $originalCountryJoin->addExplicitCondition(TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', null, TaxRuleCountryTableMap::TABLE_NAME, 'COUNTRY_ID', 'origin', Criteria::NOT_EQUAL); - $originalCountryJoin->setJoinType(Criteria::LEFT_JOIN); + $search->addJoinObject($originalCountryJoin, 's_to_o'); + $search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', $country, \PDO::PARAM_INT); - $search->addJoinObject($originalCountryJoin, 's_to_o'); - $search->where('`origin`.`COUNTRY_ID`' . Criteria::EQUAL . '?', $country, \PDO::PARAM_INT); + $search->having('COUNT(*)=?', $taxCountForOriginCountry, \PDO::PARAM_INT); - $search->having('COUNT(*)=?', count($taxes), \PDO::PARAM_INT); + $search->filterByTaxRuleId($taxRule); - /* manage tax translation */ - $this->configureI18nProcessing( - $search, - array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), - CountryTableMap::TABLE_NAME, - 'COUNTRY_ID' - ); - } elseif(null !== $country) { + /* manage tax translation */ + $this->configureI18nProcessing( + $search, + array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), + CountryTableMap::TABLE_NAME, + 'COUNTRY_ID' + ); + + $search->addAscendingOrderByColumn('`' . CountryTableMap::TABLE_NAME . '_i18n_TITLE`'); + } else { + $search = CountryQuery::create() + ->joinTaxRuleCountry('trc', Criteria::LEFT_JOIN); + + /* manage tax translation */ + $this->configureI18nProcessing( + $search + ); + + $search->where('ISNULL(`trc`.`COUNTRY_ID`)'); + + $search->addAscendingOrderByColumn('i18n_TITLE'); + } + } elseif($ask === 'taxes') { $search->filterByCountryId($country); /* manage tax translation */ @@ -116,13 +137,11 @@ class TaxRuleCountry extends BaseI18nLoop TaxTableMap::TABLE_NAME, 'TAX_ID' ); + + $search->filterByTaxRuleId($taxRule); + $search->orderByPosition(Criteria::ASC); } - $taxRule = $this->getTax_rule(); - $search->filterByTaxRuleId($taxRule); - - $search->orderByPosition(Criteria::ASC); - /* perform search */ $taxRuleCountries = $this->search($search, $pagination); @@ -132,16 +151,23 @@ class TaxRuleCountry extends BaseI18nLoop $loopResultRow = new LoopResultRow($loopResult, $taxRuleCountry, $this->versionable, $this->timestampable, $this->countable); - if(null !== $taxes) { - $loopResultRow - ->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId()) - ->set("COUNTRY" , $taxRuleCountry->getCountryId()) - ->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE')) - ->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_CHAPO')) - ->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) - ->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')) - ; - }elseif(null !== $country) { + if($ask === 'countries') { + if($taxCountForOriginCountry > 0) { + $loopResultRow + ->set("COUNTRY" , $taxRuleCountry->getCountryId()) + ->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_TITLE')) + ->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_CHAPO')) + ->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) + ->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')); + } else { + $loopResultRow + ->set("COUNTRY" , $taxRuleCountry->getId()) + ->set("COUNTRY_TITLE" , $taxRuleCountry->getVirtualColumn('i18n_TITLE')) + ->set("COUNTRY_CHAPO" , $taxRuleCountry->getVirtualColumn('i18n_CHAPO')) + ->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn('i18n_DESCRIPTION')) + ->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn('i18n_POSTSCRIPTUM')); + } + } elseif($ask === 'taxes') { $loopResultRow ->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId()) ->set("COUNTRY" , $taxRuleCountry->getCountryId()) diff --git a/templates/admin/default/tax-rule-edit.html b/templates/admin/default/tax-rule-edit.html index c236e7bc4..5ad6ab205 100644 --- a/templates/admin/default/tax-rule-edit.html +++ b/templates/admin/default/tax-rule-edit.html @@ -116,11 +116,11 @@

{intl l="Countries that have the same tax rule"} :

-

+

{$matchedCountries.first=$asked_country} - {loop type="tax-rule-country" name="same-country-list" tax_rule=$ID taxes="1,2,3" country=$asked_country} + {loop type="tax-rule-country" name="same-country-list" tax_rule=$ID ask="countries" country=$asked_country} {$matchedCountries[]=$COUNTRY} {$COUNTRY_TITLE} {/loop} @@ -129,6 +129,7 @@ {intl l="NONE"} {/elseloop}

+
@@ -234,11 +235,16 @@

{intl l="Tax rule taxes will be update for the following countries :"}

- +
+ + + + +
{/form_field} @@ -283,6 +289,29 @@ $('#tax_list_update_dialog').modal(); {/if} + + $('.js-collapse').each(function(k, v) { + var h = $(v).data('collapse-height'); + if( $(v).height() > h ) { + $(v).css('overflow', 'hidden').css('height', h + 'px'); + } else { + $('[data-collapse-block=' + $(v).attr('id') + ']').hide(); + } + }); + + $('.js-collapse-btn').click(function(e) { + e.preventDefault(); + var block = $(this).data('collapseBlock'); + $('#' + block).css('overflow', 'initial').css('height', 'initial'); + $(this).unbind().remove(); + }); + + $('.js-uncheck-all').click(function(e) { + e.preventDefault(); + var selectId = $(this).data('uncheckSelect'); + $('#' + selectId).selectpicker('deselectAll'); + }); + {literal} $('#country-selector').change(function(e) { $('#country-selector-form').submit(); @@ -308,7 +337,6 @@ }); }); - console.log(taxesRules); $('#tax_list').val(JSON.stringify(taxesRules)); }); From 085c2fa75cb8a0c063ba29b9d232508faff20b0c Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 14 Oct 2013 17:28:31 +0200 Subject: [PATCH 02/50] taxes management --- core/lib/Thelia/Action/Tax.php | 104 +++++++++ core/lib/Thelia/Config/Resources/action.xml | 5 + core/lib/Thelia/Config/Resources/config.xml | 4 + .../Thelia/Config/Resources/routing/admin.xml | 23 +- .../Thelia/Controller/Admin/TaxController.php | 198 ++++++++++++++++++ core/lib/Thelia/Core/Event/Tax/TaxEvent.php | 109 ++++++++++ core/lib/Thelia/Core/Event/TheliaEvents.php | 6 + core/lib/Thelia/Core/Template/Loop/Tax.php | 12 +- core/lib/Thelia/Form/TaxCreationForm.php | 67 ++++++ core/lib/Thelia/Form/TaxModificationForm.php | 66 ++++++ core/lib/Thelia/Model/Tax.php | 3 + core/lib/Thelia/TaxEngine/TaxEngine.php | 71 +++++++ .../Thelia/TaxEngine/TaxType/BaseTaxType.php | 2 + .../TaxType/FeatureFixAmountTaxType.php | 5 + .../TaxType/FeatureSlicePercentTaxType.php | 5 + .../TaxEngine/TaxType/FixAmountTaxType.php | 5 + .../TaxEngine/TaxType/PricePercentTaxType.php | 7 +- templates/admin/default/tax-edit.html | 130 ++++++++++++ templates/admin/default/taxes-rules.html | 187 ++++++++++++++++- 19 files changed, 995 insertions(+), 14 deletions(-) create mode 100644 core/lib/Thelia/Action/Tax.php create mode 100644 core/lib/Thelia/Controller/Admin/TaxController.php create mode 100644 core/lib/Thelia/Core/Event/Tax/TaxEvent.php create mode 100644 core/lib/Thelia/Form/TaxCreationForm.php create mode 100644 core/lib/Thelia/Form/TaxModificationForm.php create mode 100755 core/lib/Thelia/TaxEngine/TaxEngine.php create mode 100644 templates/admin/default/tax-edit.html diff --git a/core/lib/Thelia/Action/Tax.php b/core/lib/Thelia/Action/Tax.php new file mode 100644 index 000000000..91e51b59f --- /dev/null +++ b/core/lib/Thelia/Action/Tax.php @@ -0,0 +1,104 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Tax\TaxEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\Tax as TaxModel; +use Thelia\Model\TaxQuery; + +class Tax extends BaseAction implements EventSubscriberInterface +{ + /** + * @param TaxEvent $event + */ + public function create(TaxEvent $event) + { + $tax = new TaxModel(); + + $tax + ->setDispatcher($this->getDispatcher()) + ->setType($event->getType()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ; + + $tax->save(); + + $event->setTax($tax); + } + + /** + * @param TaxEvent $event + */ + public function update(TaxEvent $event) + { + if (null !== $tax = TaxQuery::create()->findPk($event->getId())) { + + $tax + ->setDispatcher($this->getDispatcher()) + ->setType($event->getType()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ->save() + ; + + + + $event->setTax($tax); + } + } + + /** + * @param TaxEvent $event + */ + public function delete(TaxEvent $event) + { + if (null !== $tax = TaxQuery::create()->findPk($event->getId())) { + + $tax + ->delete() + ; + + $event->setTax($tax); + } + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::TAX_CREATE => array("create", 128), + TheliaEvents::TAX_UPDATE => array("update", 128), + TheliaEvents::TAX_DELETE => array("delete", 128), + + ); + } +} diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 939cc9d88..1ef84b5af 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -111,6 +111,11 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 5e2227989..19b9c97f6 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -117,6 +117,10 @@
+ + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 9803bc866..af05b667e 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -787,7 +787,28 @@ - + + + + Thelia\Controller\Admin\TaxController::updateAction + \d+ + + + + Thelia\Controller\Admin\TaxController::createAction + + + + Thelia\Controller\Admin\TaxController::processUpdateAction + + + + Thelia\Controller\Admin\TaxController::deleteAction + + + + + Thelia\Controller\Admin\TaxRuleController::defaultAction diff --git a/core/lib/Thelia/Controller/Admin/TaxController.php b/core/lib/Thelia/Controller/Admin/TaxController.php new file mode 100644 index 000000000..0c83aa4cb --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/TaxController.php @@ -0,0 +1,198 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\Tax\TaxEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Form\TaxCreationForm; +use Thelia\Form\TaxModificationForm; +use Thelia\Form\TaxTaxListUpdateForm; +use Thelia\Model\TaxQuery; + +class TaxController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'tax', + 'manual', + 'order', + + 'admin.configuration.tax.view', + 'admin.configuration.tax.create', + 'admin.configuration.tax.update', + 'admin.configuration.tax.delete', + + TheliaEvents::TAX_CREATE, + TheliaEvents::TAX_UPDATE, + TheliaEvents::TAX_DELETE + ); + } + + protected function getCreationForm() + { + return new TaxCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new TaxModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $event = new TaxEvent(); + + $event->setLocale($formData['locale']); + $event->setTitle($formData['title']); + $event->setDescription($formData['description']); + $event->setType($formData['type']); + + return $event; + } + + protected function getUpdateEvent($formData) + { + $event = new TaxEvent(); + + $event->setLocale($formData['locale']); + $event->setId($formData['id']); + $event->setTitle($formData['title']); + $event->setDescription($formData['description']); + $event->setType($formData['type']); + + return $event; + } + + protected function getDeleteEvent() + { + $event = new TaxEvent(); + + $event->setId( + $this->getRequest()->get('tax_id', 0) + ); + + return $event; + } + + protected function eventContainsObject($event) + { + return $event->hasTax(); + } + + protected function hydrateObjectForm($object) + { + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'description' => $object->getDescription(), + 'type' => $object->getType(), + ); + + // Setup the object form + return new TaxModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasTax() ? $event->getTax() : null; + } + + protected function getExistingObject() + { + return TaxQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('tax_id')); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function getViewArguments() + { + return array(); + } + + protected function getRouteArguments($tax_id = null) + { + return array( + 'tax_id' => $tax_id === null ? $this->getRequest()->get('tax_id') : $tax_id, + ); + } + + protected function renderListTemplate($currentOrder) + { + // We always return to the feature edition form + return $this->render( + 'taxes-rules', + array() + ); + } + + protected function renderEditionTemplate() + { + // We always return to the feature edition form + return $this->render('tax-edit', array_merge($this->getViewArguments(), $this->getRouteArguments())); + } + + protected function redirectToEditionTemplate($request = null, $country = null) + { + // We always return to the feature edition form + $this->redirectToRoute( + "admin.configuration.taxes.update", + $this->getViewArguments($country), + $this->getRouteArguments() + ); + } + + /** + * Put in this method post object creation processing if required. + * + * @param TaxEvent $createEvent the create event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalCreateAction($createEvent) + { + $this->redirectToRoute( + "admin.configuration.taxes.update", + $this->getViewArguments(), + $this->getRouteArguments($createEvent->getTax()->getId()) + ); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute( + "admin.configuration.taxes-rules.list" + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Tax/TaxEvent.php b/core/lib/Thelia/Core/Event/Tax/TaxEvent.php new file mode 100644 index 000000000..6136630ad --- /dev/null +++ b/core/lib/Thelia/Core/Event/Tax/TaxEvent.php @@ -0,0 +1,109 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Tax; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Tax; + +class TaxEvent extends ActionEvent +{ + protected $tax = null; + + protected $locale; + protected $id; + protected $title; + protected $description; + protected $type; + + public function __construct(Tax $tax = null) + { + $this->tax = $tax; + } + + public function hasTax() + { + return ! is_null($this->tax); + } + + public function getTax() + { + return $this->tax; + } + + public function setTax(Tax $tax) + { + $this->tax = $tax; + + return $this; + } + + public function setDescription($description) + { + $this->description = $description; + } + + public function getDescription() + { + return $this->description; + } + + public function setId($id) + { + $this->id = $id; + } + + public function getId() + { + return $this->id; + } + + public function setTitle($title) + { + $this->title = $title; + } + + public function getTitle() + { + return $this->title; + } + + public function setLocale($locale) + { + $this->locale = $locale; + } + + public function getLocale() + { + return $this->locale; + } + + public function setType($type) + { + $this->type = $type; + } + + public function getType() + { + return $this->type; + } +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index a21e0a9c9..c2f2721b8 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -519,6 +519,12 @@ final class TheliaEvents const CHANGE_DEFAULT_CURRENCY = 'action.changeDefaultCurrency'; + // -- Tax management --------------------------------------------- + + const TAX_CREATE = "action.createTax"; + const TAX_UPDATE = "action.updateTax"; + const TAX_DELETE = "action.deleteTax"; + // -- Tax Rules management --------------------------------------------- const TAX_RULE_CREATE = "action.createTaxRule"; diff --git a/core/lib/Thelia/Core/Template/Loop/Tax.php b/core/lib/Thelia/Core/Template/Loop/Tax.php index 1ddf18824..0248e60d8 100644 --- a/core/lib/Thelia/Core/Template/Loop/Tax.php +++ b/core/lib/Thelia/Core/Template/Loop/Tax.php @@ -152,11 +152,13 @@ class Tax extends BaseI18nLoop $loopResultRow = new LoopResultRow($loopResult, $tax, $this->versionable, $this->timestampable, $this->countable); $loopResultRow - ->set("ID" , $tax->getId()) - ->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE" , $locale) - ->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE')) - ->set("DESCRIPTION" , $tax->getVirtualColumn('i18n_DESCRIPTION')) + ->set("ID" , $tax->getId()) + ->set("TYPE" , $tax->getType()) + ->set("SERIALIZED_REQUIREMENTS" , $tax->getSerializedRequirements()) + ->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $locale) + ->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE')) + ->set("DESCRIPTION" , $tax->getVirtualColumn('i18n_DESCRIPTION')) ; $loopResult->addRow($loopResultRow); diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php new file mode 100644 index 000000000..31b0834d4 --- /dev/null +++ b/core/lib/Thelia/Form/TaxCreationForm.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; +use Thelia\TaxEngine\TaxEngine; +use Thelia\TaxEngine\TaxType; + +class TaxCreationForm extends BaseForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm($change_mode = false) + { + $types = TaxEngine::getInstance()->getTaxTypeList(); + $typeList = array(); + foreach($types as $type) { + $classPath = "\\Thelia\\TaxEngine\\TaxType\\$type"; + $instance = new $classPath(); + $typeList[$type] = $instance->getTitle(); + } + + $this->formBuilder + ->add("locale", "text", array( + "constraints" => array(new NotBlank()) + )) + ->add("type", "choice", array( + "choices" => $typeList, + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + ), + "label" => Translator::getInstance()->trans("Type"), + "label_attr" => array("for" => "type_field"), + )) + ; + + $this->addStandardDescFields(array('postscriptum', 'chapo', 'locale')); + } + + public function getName() + { + return "thelia_tax_creation"; + } +} diff --git a/core/lib/Thelia/Form/TaxModificationForm.php b/core/lib/Thelia/Form/TaxModificationForm.php new file mode 100644 index 000000000..1c496440e --- /dev/null +++ b/core/lib/Thelia/Form/TaxModificationForm.php @@ -0,0 +1,66 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\TaxQuery; + +class TaxModificationForm extends TaxCreationForm +{ + protected function buildForm() + { + parent::buildForm(true); + + $this->formBuilder + ->add("id", "hidden", array( + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + new Constraints\Callback( + array( + "methods" => array( + array($this, "verifyTaxId"), + ), + ) + ), + ) + )) + ; + } + + public function getName() + { + return "thelia_tax_modification"; + } + + public function verifyTaxId($value, ExecutionContextInterface $context) + { + $tax = TaxQuery::create() + ->findPk($value); + + if (null === $tax) { + $context->addViolation("Tax ID not found"); + } + } +} diff --git a/core/lib/Thelia/Model/Tax.php b/core/lib/Thelia/Model/Tax.php index 7b9b22b6f..6752129a2 100755 --- a/core/lib/Thelia/Model/Tax.php +++ b/core/lib/Thelia/Model/Tax.php @@ -4,10 +4,13 @@ namespace Thelia\Model; use Thelia\Exception\TaxEngineException; use Thelia\Model\Base\Tax as BaseTax; +use Thelia\Model\Tools\ModelEventDispatcherTrait; use Thelia\TaxEngine\TaxType\BaseTaxType; class Tax extends BaseTax { + use ModelEventDispatcherTrait; + public function calculateTax($amount) { if(false === filter_var($amount, FILTER_VALIDATE_FLOAT)) { diff --git a/core/lib/Thelia/TaxEngine/TaxEngine.php b/core/lib/Thelia/TaxEngine/TaxEngine.php new file mode 100755 index 000000000..8e5a5695a --- /dev/null +++ b/core/lib/Thelia/TaxEngine/TaxEngine.php @@ -0,0 +1,71 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\TaxEngine; + +/** + * Class TaxEngine + * @package Thelia\TaxEngine + * @author Etienne Roudeix + */ +class TaxEngine +{ + static public function getInstance() + { + return new TaxEngine(); + } + + private function getTaxTypeDirectory() + { + return __DIR__ . "/TaxType"; + } + + public function getTaxTypeList() + { + $typeList = array(); + + try { + $directoryBrowser = new \DirectoryIterator($this->getTaxTypeDirectory($this->getTaxTypeDirectory())); + } catch (\UnexpectedValueException $e) { + return $typeList; + } + + /* browse the directory */ + foreach ($directoryBrowser as $directoryContent) { + /* is it a file ? */ + if (!$directoryContent->isFile()) { + continue; + } + + $fileName = $directoryContent->getFilename(); + $className = substr($fileName, 0, (1+strlen($directoryContent->getExtension())) * -1); + + if($className == "BaseTaxType") { + continue; + } + + $typeList[] = $className; + } + + return $typeList; + } +} diff --git a/core/lib/Thelia/TaxEngine/TaxType/BaseTaxType.php b/core/lib/Thelia/TaxEngine/TaxType/BaseTaxType.php index 1e0a11ca7..f8bdd8647 100755 --- a/core/lib/Thelia/TaxEngine/TaxType/BaseTaxType.php +++ b/core/lib/Thelia/TaxEngine/TaxType/BaseTaxType.php @@ -41,6 +41,8 @@ abstract class BaseTaxType public abstract function getRequirementsList(); + public abstract function getTitle(); + public function calculate(Product $product, $untaxedPrice) { return $untaxedPrice * $this->pricePercentRetriever() + $this->fixAmountRetriever($product); diff --git a/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php b/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php index 32c78c1ac..e623528c2 100755 --- a/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php +++ b/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php @@ -65,4 +65,9 @@ class FeatureFixAmountTaxType extends BaseTaxType 'feature' => new ModelValidIdType('Feature'), ); } + + public function getTitle() + { + return "Fix amount Tax depending on a feature"; + } } diff --git a/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php b/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php index 311a83272..f1e95c5c7 100755 --- a/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php +++ b/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php @@ -49,4 +49,9 @@ class featureSlicePercentTaxType extends BaseTaxType 'slices' => new FloatToFloatArrayType(), ); } + + public function getTitle() + { + return "% slice Tax depending on a feature"; + } } diff --git a/core/lib/Thelia/TaxEngine/TaxType/FixAmountTaxType.php b/core/lib/Thelia/TaxEngine/TaxType/FixAmountTaxType.php index e62136d99..c93715571 100755 --- a/core/lib/Thelia/TaxEngine/TaxType/FixAmountTaxType.php +++ b/core/lib/Thelia/TaxEngine/TaxType/FixAmountTaxType.php @@ -47,4 +47,9 @@ class FixAmountTaxType extends BaseTaxType 'amount' => new FloatType(), ); } + + public function getTitle() + { + return "Fix amount Tax"; + } } diff --git a/core/lib/Thelia/TaxEngine/TaxType/PricePercentTaxType.php b/core/lib/Thelia/TaxEngine/TaxType/PricePercentTaxType.php index 342f51a6d..6881b0288 100755 --- a/core/lib/Thelia/TaxEngine/TaxType/PricePercentTaxType.php +++ b/core/lib/Thelia/TaxEngine/TaxType/PricePercentTaxType.php @@ -47,6 +47,9 @@ class PricePercentTaxType extends BaseTaxType 'percent' => new FloatType(), ); } -} -//600 / (1 + 0,10 + 0,10) =/= 600 / (1 + 0,10 ) + 600 / (1 + 0,10 ) \ No newline at end of file + public function getTitle() + { + return "Price % Tax"; + } +} diff --git a/templates/admin/default/tax-edit.html b/templates/admin/default/tax-edit.html new file mode 100644 index 000000000..435ace42b --- /dev/null +++ b/templates/admin/default/tax-edit.html @@ -0,0 +1,130 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Edit a tax'}{/block} + +{block name="check-permissions"}admin.configuration.taxes.edit{/block} + +{block name="main-content"} + +
+ +
+ + + + {loop type="tax" name="tax" id=$tax_id backend_context="1" lang=$edit_language_id} + +
+
+ +
+ + {form name="thelia.admin.tax.modification"} + + + + {include + file = "includes/inner-form-toolbar.html" + hide_submit_buttons = false + + page_url = {url path="/admin/configuration/taxes/update/$tax_id"} + close_url = {url path="/admin/configuration/taxes_rules"} + } + + {* Be sure to get the product ID, even if the form could not be validated *} + + + {form_hidden_fields form=$form} + + {form_field form=$form field='success_url'} + + {/form_field} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
{$form_error_message}
{/if} + + {form_field form=$form field='title'} +
+ + +
+ {/form_field} + + {form_field form=$form field='description'} +
+ + + +
+ {/form_field} + + {form_field form=$form field='type'} +
+ + +
+ +
+
+ {/form_field} + +
+
+
+ +
+

{intl l='Tax created on %date_create. Last modification: %date_change' date_create={format_date date=$CREATE_DATE} date_change={format_date date=$UPDATE_DATE}}

+
+
+
+
+ + + {/form} +
+ +
+
+ + {/loop} + +
+ +{/block} + +{block name="javascript-initialization"} + + {javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + + {/javascripts} + + {javascripts file='assets/js/main.js'} + + {/javascripts} + + + + + +{/block} \ No newline at end of file diff --git a/templates/admin/default/taxes-rules.html b/templates/admin/default/taxes-rules.html index 67e8b414a..73eb35b40 100644 --- a/templates/admin/default/taxes-rules.html +++ b/templates/admin/default/taxes-rules.html @@ -21,6 +21,72 @@
+ +
+

{intl l="In order to manges your shop taxes you can manage"} {intl l="taxes"} {intl l="and"} {intl l="tax rules"}.

+

{intl l="Taxes define the amount of money which is add to a bought product."}

+

+ {intl l="Example :"} +

    +
  • {intl l="French 19.6% VAT is a tax which add a 19.6% tax to the product price."}
  • +
  • {intl l="Ecotax is a tax wich add a defined amount (throug a product feature) to the product price."}
  • +
+

+

{intl l="Tax rules are combination of different taxes."}

+

+ {intl l="Example :"} +

    +
  • {intl l="French 19.6% VAT with ecotax is the applicance of the ecotax (on the product price) then the applicance of the 19.6% tax (on the product price + the ecotax amount)."}
  • +
+

+

{intl l="you can combine taxes in tax rules and chose if they are applied one after the other or at the same time : it allows to apply taxes on an already taxed price or not."}

+
+ +
+
+ + + + + + + + + + + + {loop type="tax" name="taxes" backend_context="1"} + + + + + + + + {/loop} + + +
+ {intl l="Taxes"} + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.taxes.create"} + + + + {/loop} +
{intl l="Name"}{intl l="Description"}{intl l="Actions"}
{$TITLE}{$DESCRIPTION} +
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes.change"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes.change"} + + {/loop} +
+
+
+
+
@@ -41,7 +107,7 @@ - {loop type="tax-rule" name="taxes-rules"} + {loop type="tax-rule" name="taxes-rules" backend_context="1"} @@ -61,10 +127,10 @@ {/loop} - +
{$TITLE}
-
+
@@ -73,8 +139,8 @@
-{* -- Add tax rule confirmation dialog ----------------------------------- *} -{form name="thelia.admin.taxrule.add"} +{* -- Add tax confirmation dialog ----------------------------------- *} +{form name="thelia.admin.tax.add"} {if $form_error_message} {$taxCreateError = true} @@ -82,6 +148,99 @@ {$taxCreateError = false} {/if} +{* Capture the dialog body, to pass it to the generic dialog *} +{capture "tax_create_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
{$form_error_message}
{/if} + + {form_field form=$form field='title'} +
+ + +
+ {/form_field} + + {form_field form=$form field='description'} +
+ + + +
+ {/form_field} + + {form_field form=$form field='type'} +
+ + +
+ +
+
+ {/form_field} + +{/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "tax_create_dialog" + dialog_title = {intl l="Create a new tax"} + dialog_body = {$smarty.capture.tax_create_dialog nofilter} + + dialog_ok_label = {intl l="Create"} + dialog_cancel_label = {intl l="Cancel"} + + form_action = {url path="/admin/configuration/taxes/add"} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } + +{/form} + +{* -- Delete tax confirmation dialog ----------------------------------- *} + +{capture "tax_delete_dialog"} + + + {module_include location='tax_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "tax_delete_dialog" + dialog_title = {intl l="Delete tax"} + dialog_message = {intl l="Do you really want to delete this tax ?"} + + form_action = {url path='/admin/configuration/taxes/delete'} + form_content = {$smarty.capture.tax_delete_dialog nofilter} +} + +{* -- Add tax rule confirmation dialog ----------------------------------- *} +{form name="thelia.admin.taxrule.add"} + +{if $form_error_message} + {$taxRuleCreateError = true} +{else} + {$taxRuleCreateError = false} +{/if} + {* Capture the dialog body, to pass it to the generic dialog *} {capture "tax_rule_create_dialog"} @@ -154,15 +313,31 @@ {block name="javascript-initialization"} +{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + +{/javascripts} + +{javascripts file='assets/js/main.js'} + +{/javascripts} + {/block} \ No newline at end of file From 4f83c7f07856657c28e65875d85333cdea5c0411 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 15 Oct 2013 11:07:58 +0200 Subject: [PATCH 03/50] display module list --- .../Thelia/Config/Resources/routing/admin.xml | 2 +- .../Controller/Admin/ModuleController.php | 4 + .../admin/default/includes/module-block.html | 53 +++++ templates/admin/default/modules.html | 217 +----------------- 4 files changed, 61 insertions(+), 215 deletions(-) create mode 100644 templates/admin/default/includes/module-block.html diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 55ee6a90f..d554f0550 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -816,7 +816,7 @@ - + Thelia\Controller\Admin\ModuleController::indexAction diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index 03691c069..d2b96ce2e 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -33,6 +33,10 @@ class ModuleController extends BaseAdminController public function indexAction() { if (null !== $response = $this->checkAuth("admin.module.view")) return $response; + + + + return $this->render("modules", array("display_module" => 20)); } diff --git a/templates/admin/default/includes/module-block.html b/templates/admin/default/includes/module-block.html new file mode 100644 index 000000000..7784c84db --- /dev/null +++ b/templates/admin/default/includes/module-block.html @@ -0,0 +1,53 @@ +
+
+ + + + + + + + + {module_include location='modules_table_header'} + + + + + + + {loop type="module" name="module.{$module_type}" module_type={$module_type|default:1} backend_context=1} + + + + + + {module_include location='modules_table_row'} + + + + {/loop} + +
+ {$caption_title|default:{intl l='classic modules'}} +
{intl l="Name"}{intl l="Description"}{intl l="Enable/Disable"}{intl l="Actions"}
{$TITLE}{$CHAPO} +
+ +
+
+
+ + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} + + {/loop} + + {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} + + {/loop} +
+
+
+
\ No newline at end of file diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html index 8c86c349a..06d7420bd 100644 --- a/templates/admin/default/modules.html +++ b/templates/admin/default/modules.html @@ -25,221 +25,10 @@
-
-
- - - - - - - + {include file="includes/module-block.html" module_type="1" caption_title={intl l='Classic modules'}} + {include file="includes/module-block.html" module_type="2" caption_title={intl l='Delivery modules'}} + {include file="includes/module-block.html" module_type="3" caption_title={intl l='Payment modules'}} - {module_include location='modules_table_header'} - - - - - - - - - - - - {module_include location='modules_table_row'} - - - - - - - - - {module_include location='modules_table_row'} - - - - - - - - - {module_include location='modules_table_row'} - - - - -
- {intl l='Transport modules'} -
{intl l="Name"}{intl l="Description"}{intl l="Enable/Disable"}{intl l="Actions"}
TinymceEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid! Eius, pariatur accusantium odit quidem laboriosam. -
- -
-
-
- - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} - - {/loop} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} - - {/loop} -
-
So colissimoEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid -
- -
-
-
- - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} - - {/loop} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} - - {/loop} -
-
Title metaEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid -
- -
-
-
- - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} - - {/loop} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} - - {/loop} -
-
-
-
- -
-
- - - - - - - - - {module_include location='modules_table_header'} - - - - - - - - - - - - {module_include location='modules_table_row'} - - - - - - - - - {module_include location='modules_table_row'} - - - - - - - - - {module_include location='modules_table_row'} - - - - -
- {intl l='Delivery modules'} -
{intl l="Name"}{intl l="Description"}{intl l="Enable/Disable"}{intl l="Actions"}
TinymceEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid! Eius, pariatur accusantium odit quidem laboriosam. -
- -
-
-
- - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} - - {/loop} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} - - {/loop} -
-
So colissimoEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid -
- -
-
-
- - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} - - {/loop} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} - - {/loop} -
-
Title metaEos minima maiores doloribus mollitia perspiciatis esse iusto odit error delectus aliquid -
- -
-
-
- - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.documentation"} - - {/loop} - - {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.modules.edit"} - - {/loop} - - {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} - - {/loop} -
-
-
-
From b3c761798b1c29e8549f2ce1ea65b86504bc9637 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 16 Oct 2013 11:45:18 +0200 Subject: [PATCH 04/50] fix menu when child > 0 --- .../Core/Template/Loop/CategoryTree.php | 12 ++++--- templates/default/category.html | 2 -- templates/default/includes/menu.html | 31 ++++++++++--------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php index 009e2204f..b7c262649 100755 --- a/core/lib/Thelia/Core/Template/Loop/CategoryTree.php +++ b/core/lib/Thelia/Core/Template/Loop/CategoryTree.php @@ -84,10 +84,14 @@ class CategoryTree extends BaseI18nLoop $loopResultRow = new LoopResultRow(); $loopResultRow - ->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE')) - ->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale)) - ->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level) - ->set('CHILD_COUNT', $result->countChild())->set('PREV_LEVEL', $previousLevel) + ->set("ID", $result->getId()) + ->set("TITLE", $result->getVirtualColumn('i18n_TITLE')) + ->set("PARENT", $result->getParent()) + ->set("URL", $result->getUrl($locale)) + ->set("VISIBLE", $result->getVisible() ? "1" : "0") + ->set("LEVEL", $level) + ->set('CHILD_COUNT', $result->countChild()) + ->set('PREV_LEVEL', $previousLevel) ; $loopResult->addRow($loopResultRow); diff --git a/templates/default/category.html b/templates/default/category.html index 99db32948..419207426 100644 --- a/templates/default/category.html +++ b/templates/default/category.html @@ -46,6 +46,4 @@ - - {/block} diff --git a/templates/default/includes/menu.html b/templates/default/includes/menu.html index 083c74ef2..476e3ecd0 100644 --- a/templates/default/includes/menu.html +++ b/templates/default/includes/menu.html @@ -3,25 +3,28 @@
- \ No newline at end of file + From 9365e9ee3888ca86195378fcee8f6dab506e12ec Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 16 Oct 2013 11:46:30 +0200 Subject: [PATCH 05/50] tax management --- core/lib/Thelia/Core/Form/Type/TheliaType.php | 45 ++++++ .../Thelia/Core/Template/Element/BaseLoop.php | 2 +- .../Core/Template/Smarty/Plugins/Form.php | 135 ++++++++++++++++-- .../Template/Smarty/Plugins/TheliaLoop.php | 2 +- core/lib/Thelia/Form/TaxCreationForm.php | 23 +++ .../TaxType/FeatureSlicePercentTaxType.php | 2 +- .../Thelia/Type/AlphaNumStringListType.php | 10 ++ core/lib/Thelia/Type/AlphaNumStringType.php | 10 ++ core/lib/Thelia/Type/AnyType.php | 10 ++ core/lib/Thelia/Type/BooleanOrBothType.php | 10 ++ core/lib/Thelia/Type/BooleanType.php | 10 ++ core/lib/Thelia/Type/EnumListType.php | 10 ++ core/lib/Thelia/Type/EnumType.php | 10 ++ .../lib/Thelia/Type/FloatToFloatArrayType.php | 10 ++ core/lib/Thelia/Type/FloatType.php | 10 ++ core/lib/Thelia/Type/IntListType.php | 10 ++ .../Thelia/Type/IntToCombinedIntsListType.php | 10 ++ .../Type/IntToCombinedStringsListType.php | 10 ++ core/lib/Thelia/Type/IntType.php | 10 ++ core/lib/Thelia/Type/JsonType.php | 10 ++ core/lib/Thelia/Type/ModelType.php | 10 ++ core/lib/Thelia/Type/ModelValidIdType.php | 19 +++ core/lib/Thelia/Type/TypeInterface.php | 3 + templates/admin/default/tax-edit.html | 24 +++- 24 files changed, 393 insertions(+), 12 deletions(-) create mode 100644 core/lib/Thelia/Core/Form/Type/TheliaType.php diff --git a/core/lib/Thelia/Core/Form/Type/TheliaType.php b/core/lib/Thelia/Core/Form/Type/TheliaType.php new file mode 100644 index 000000000..4820f9b3b --- /dev/null +++ b/core/lib/Thelia/Core/Form/Type/TheliaType.php @@ -0,0 +1,45 @@ +setDefaults(array( + 'instance' => false, + 'type' => false, + 'options' => false, + )); + + $resolver->setAllowedTypes(array( + 'instance' => array('Thelia\Type\TypeInterface'), + )); + } + + /** + * {@inheritdoc} + */ + public function buildView(FormView $view, FormInterface $form, array $options) + { + $view->vars = array_replace($view->vars, array( + 'instance' => $options['instance'], + 'type' => $options['type'], + 'options' => $options['options'], + )); + } + + public function getParent() + { + return 'form'; + } + + public function getName() + { + return 'thelia_type'; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Template/Element/BaseLoop.php b/core/lib/Thelia/Core/Template/Element/BaseLoop.php index 5ac23142d..7e803c43a 100755 --- a/core/lib/Thelia/Core/Template/Element/BaseLoop.php +++ b/core/lib/Thelia/Core/Template/Element/BaseLoop.php @@ -254,7 +254,7 @@ abstract class BaseLoop * * @param $pagination * - * @return mixed + * @return LoopResult */ abstract public function exec(&$pagination); diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 37be09824..7897b74a0 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -22,7 +22,11 @@ /*************************************************************************************/ namespace Thelia\Core\Template\Smarty\Plugins; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; +use Symfony\Component\Form\Extension\Core\Type\CollectionType; +use Symfony\Component\Form\Extension\Core\View\ChoiceView; use Symfony\Component\Form\FormView; +use Thelia\Core\Form\Type\TheliaType; use Thelia\Form\BaseForm; use Thelia\Core\Template\Element\Exception\ElementNotFoundException; use Symfony\Component\HttpFoundation\Request; @@ -56,6 +60,8 @@ use Thelia\Core\Template\ParserContext; */ class Form extends AbstractSmartyPlugin { + static private $taggedFieldsStack = null; + static private $taggedFieldsStackPosition = null; protected $request; protected $parserContext; @@ -118,11 +124,16 @@ class Form extends AbstractSmartyPlugin $template->assign("value", $fieldValue); + $template->assign("options", $formFieldView->vars); + // If Checkbox input type if ($fieldVars['checked'] !== null) { $this->renderFormFieldCheckBox($template, $formFieldView['checked']); } + //data + $template->assign("data", $fieldVars['data']); + $template->assign("label", $fieldVars["label"]); $template->assign("label_attr", $fieldVars["label_attr"]); @@ -143,18 +154,51 @@ class Form extends AbstractSmartyPlugin $template->assign("attr", implode(" ", $attr)); } + protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView) + { + $formFieldType = $formFieldConfig->getType()->getInnerType(); + + /* access to choices */ + if($formFieldType instanceof ChoiceType) { + $template->assign("choices", $formFieldView->vars['choices']); + } + + /* access to collections */ + if($formFieldType instanceof CollectionType) { + if( true === $formFieldConfig->getOption('prototype') ) { + + } else { + + } + } + + /* access to thelia type */ + if($formFieldType instanceof TheliaType) { + $template->assign("formType", $formFieldView->vars['type']); + + switch($formFieldView->vars['type']) { + case "choice": + if(!isset($formFieldView->vars['options']['choices']) || !is_array($formFieldView->vars['options']['choices'])) { + //throw new + } + $choices = array(); + foreach($formFieldView->vars['options']['choices'] as $value => $choice) { + $choices[] = new ChoiceView($value, $value, $choice); + } + $template->assign("choices", $choices); + break; + } + } + } + public function renderFormField($params, $content, \Smarty_Internal_Template $template, &$repeat) { - if ($repeat) { + if ($repeat) { - $formFieldView = $this->getFormFieldView($params); + $formFieldView = $this->getFormFieldView($params); + $formFieldConfig = $this->getFormFieldConfig($params); - $template->assign("options", $formFieldView->vars); - - /* access to choices */ - if(isset($formFieldView->vars['choices'])) { - $template->assign("choices", $formFieldView->vars['choices']); - } + $this->assignFormTypeValues($template, $formFieldConfig, $formFieldView); $value = $formFieldView->vars["value"]; /* FIXME: doesnt work. We got "This form should not contain extra fields." error. @@ -185,6 +229,38 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar } } + public function renderTaggedFormFields($params, $content, \Smarty_Internal_Template $template, &$repeat) + { + if(null === $content) { + self::$taggedFieldsStack = $this->getFormFieldsFromTag($params); + self::$taggedFieldsStackPosition = 0; + } else { + self::$taggedFieldsStackPosition++; + } + + if(isset(self::$taggedFieldsStack[self::$taggedFieldsStackPosition])) { + $this->assignFieldValues( + $template, + self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->vars["full_name"], + self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->vars["value"], + self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->vars + ); + + $this->assignFormTypeValues($template, self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['config'], self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']); + + self::$taggedFieldsStack[self::$taggedFieldsStackPosition]['view']->setRendered(); + + $repeat = true; + } + + if (! $repeat) { + self::$taggedFieldsStack = null; + self::$taggedFieldsStackPosition = null; + } + + return $content; + } + public function renderHiddenFormField($params, \Smarty_Internal_Template $template) { $attrFormat = '%s="%s"'; @@ -266,6 +342,48 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar return $instance->getView()[$fieldName]; } + protected function getFormFieldsFromTag($params) + { + $instance = $this->getInstanceFromParams($params); + + $tag = $this->getParam($params, 'tag'); + + if (null == $tag) + throw new \InvalidArgumentException("'tag' parameter is missing"); + + $viewList = array(); + foreach($instance->getView() as $view) { + if(isset($view->vars['attr']['tag']) && $tag == $view->vars['attr']['tag']) { + $fieldData = $instance->getForm()->all()[$view->vars['name']]; + $viewList[] = array( + 'view' => $view, + 'config' => $fieldData->getConfig(), + ); + } + } + + return $viewList; + } + + protected function getFormFieldConfig($params) + { + $instance = $this->getInstanceFromParams($params); + + $fieldName = $this->getParam($params, 'field'); + + if (null == $fieldName) { + throw new \InvalidArgumentException("'field' parameter is missing"); + } + + $fieldData = $instance->getForm()->all()[$fieldName]; + + if (empty( $fieldData )) { + throw new \InvalidArgumentException(sprintf("Field name '%s' not found in form %s children", $fieldName, $instance->getName())); + } + + return $fieldData->getConfig(); + } + protected function getInstanceFromParams($params) { $instance = $this->getParam($params, 'form'); @@ -304,6 +422,7 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar return array( new SmartyPluginDescriptor("block", "form", $this, "generateForm"), new SmartyPluginDescriptor("block", "form_field", $this, "renderFormField"), + new SmartyPluginDescriptor("block", "form_tagged_fields", $this, "renderTaggedFormFields"), new SmartyPluginDescriptor("function", "form_hidden_fields", $this, "renderHiddenFormField"), new SmartyPluginDescriptor("function", "form_enctype", $this, "formEnctype"), new SmartyPluginDescriptor("block", "form_error", $this, "formError") diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php index a076c808a..f7b6fc559 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php @@ -300,7 +300,7 @@ class TheliaLoop extends AbstractSmartyPlugin /** * @param $smartyParams * - * @return object + * @return BaseLoop * @throws \Thelia\Core\Template\Element\Exception\InvalidElementException * @throws \Thelia\Core\Template\Element\Exception\ElementNotFoundException */ diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php index 31b0834d4..302e55890 100644 --- a/core/lib/Thelia/Form/TaxCreationForm.php +++ b/core/lib/Thelia/Form/TaxCreationForm.php @@ -24,6 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Form\Type\TheliaType; use Thelia\Core\Translation\Translator; use Thelia\TaxEngine\TaxEngine; use Thelia\TaxEngine\TaxType; @@ -36,10 +37,12 @@ class TaxCreationForm extends BaseForm { $types = TaxEngine::getInstance()->getTaxTypeList(); $typeList = array(); + $requirementList = array(); foreach($types as $type) { $classPath = "\\Thelia\\TaxEngine\\TaxType\\$type"; $instance = new $classPath(); $typeList[$type] = $instance->getTitle(); + $requirementList[$type] = $instance->getRequirementsList(); } $this->formBuilder @@ -57,6 +60,26 @@ class TaxCreationForm extends BaseForm )) ; + foreach($requirementList as $type => $requirements) { + foreach($requirements as $name => $requirementType) { + $this->formBuilder + ->add($type . '_' . $name, new TheliaType(), array( + "instance" => $requirementType, + "constraints" => array(new NotBlank()), + "attr" => array( + "tag" => "requirements", + ), + "data" => array( + "tax_type" => $type, + ), + "label" => Translator::getInstance()->trans($name), + "type" => $requirementType->getFormType(), + "options" => $requirementType->getFormOptions(), + )) + ; + } + } + $this->addStandardDescFields(array('postscriptum', 'chapo', 'locale')); } diff --git a/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php b/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php index f1e95c5c7..8ec254843 100755 --- a/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php +++ b/core/lib/Thelia/TaxEngine/TaxType/FeatureSlicePercentTaxType.php @@ -45,7 +45,7 @@ class featureSlicePercentTaxType extends BaseTaxType public function getRequirementsList() { return array( - 'featureId' => new ModelValidIdType('Currency'), + 'featureId' => new ModelValidIdType('Feature'), 'slices' => new FloatToFloatArrayType(), ); } diff --git a/core/lib/Thelia/Type/AlphaNumStringListType.php b/core/lib/Thelia/Type/AlphaNumStringListType.php index d8e53cd95..9205373ca 100755 --- a/core/lib/Thelia/Type/AlphaNumStringListType.php +++ b/core/lib/Thelia/Type/AlphaNumStringListType.php @@ -50,4 +50,14 @@ class AlphaNumStringListType implements TypeInterface { return $this->isValid($values) ? explode(',', $values) : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/AlphaNumStringType.php b/core/lib/Thelia/Type/AlphaNumStringType.php index 726e6eb67..f574300cb 100755 --- a/core/lib/Thelia/Type/AlphaNumStringType.php +++ b/core/lib/Thelia/Type/AlphaNumStringType.php @@ -44,4 +44,14 @@ class AlphaNumStringType implements TypeInterface { return $this->isValid($value) ? $value : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/AnyType.php b/core/lib/Thelia/Type/AnyType.php index 5cdbb1272..bf5349546 100755 --- a/core/lib/Thelia/Type/AnyType.php +++ b/core/lib/Thelia/Type/AnyType.php @@ -44,4 +44,14 @@ class AnyType implements TypeInterface { return $value; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/BooleanOrBothType.php b/core/lib/Thelia/Type/BooleanOrBothType.php index 210201e26..eacd89ffc 100755 --- a/core/lib/Thelia/Type/BooleanOrBothType.php +++ b/core/lib/Thelia/Type/BooleanOrBothType.php @@ -49,4 +49,14 @@ class BooleanOrBothType implements TypeInterface if ($value === self::ANY) return $value; return $value === null ? null : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/BooleanType.php b/core/lib/Thelia/Type/BooleanType.php index 69cba66ac..e231ce26a 100755 --- a/core/lib/Thelia/Type/BooleanType.php +++ b/core/lib/Thelia/Type/BooleanType.php @@ -44,4 +44,14 @@ class BooleanType implements TypeInterface { return $value === null ? null : filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/EnumListType.php b/core/lib/Thelia/Type/EnumListType.php index 2c37929a8..0d82e3a3e 100755 --- a/core/lib/Thelia/Type/EnumListType.php +++ b/core/lib/Thelia/Type/EnumListType.php @@ -69,4 +69,14 @@ class EnumListType implements TypeInterface { return in_array($value, $this->values); } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/EnumType.php b/core/lib/Thelia/Type/EnumType.php index 416f9714a..91f45a308 100755 --- a/core/lib/Thelia/Type/EnumType.php +++ b/core/lib/Thelia/Type/EnumType.php @@ -52,4 +52,14 @@ class EnumType implements TypeInterface { return $this->isValid($value) ? $value : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/FloatToFloatArrayType.php b/core/lib/Thelia/Type/FloatToFloatArrayType.php index 682ddebdd..404b7e4e4 100755 --- a/core/lib/Thelia/Type/FloatToFloatArrayType.php +++ b/core/lib/Thelia/Type/FloatToFloatArrayType.php @@ -54,4 +54,14 @@ class FloatToFloatArrayType implements TypeInterface { return $this->isValid($value) ? $value : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/FloatType.php b/core/lib/Thelia/Type/FloatType.php index f82f34b58..74d71adfb 100755 --- a/core/lib/Thelia/Type/FloatType.php +++ b/core/lib/Thelia/Type/FloatType.php @@ -44,4 +44,14 @@ class FloatType implements TypeInterface { return $this->isValid($value) ? $value : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/IntListType.php b/core/lib/Thelia/Type/IntListType.php index 28590472e..ff87bbd4e 100755 --- a/core/lib/Thelia/Type/IntListType.php +++ b/core/lib/Thelia/Type/IntListType.php @@ -50,4 +50,14 @@ class IntListType implements TypeInterface { return $this->isValid($values) ? explode(',', $values) : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/IntToCombinedIntsListType.php b/core/lib/Thelia/Type/IntToCombinedIntsListType.php index b2dc6b068..dfa21310d 100755 --- a/core/lib/Thelia/Type/IntToCombinedIntsListType.php +++ b/core/lib/Thelia/Type/IntToCombinedIntsListType.php @@ -124,4 +124,14 @@ class IntToCombinedIntsListType implements TypeInterface return true; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/IntToCombinedStringsListType.php b/core/lib/Thelia/Type/IntToCombinedStringsListType.php index 5863feb97..38152fdaa 100755 --- a/core/lib/Thelia/Type/IntToCombinedStringsListType.php +++ b/core/lib/Thelia/Type/IntToCombinedStringsListType.php @@ -124,4 +124,14 @@ class IntToCombinedStringsListType implements TypeInterface return true; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/IntType.php b/core/lib/Thelia/Type/IntType.php index 8e2ec4fd8..7a06a50fb 100755 --- a/core/lib/Thelia/Type/IntType.php +++ b/core/lib/Thelia/Type/IntType.php @@ -44,4 +44,14 @@ class IntType implements TypeInterface { return $this->isValid($value) ? $value : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/JsonType.php b/core/lib/Thelia/Type/JsonType.php index 5c92182a8..a1a1f5af6 100755 --- a/core/lib/Thelia/Type/JsonType.php +++ b/core/lib/Thelia/Type/JsonType.php @@ -46,4 +46,14 @@ class JsonType implements TypeInterface { return $this->isValid($value) ? json_decode($value, true) : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/ModelType.php b/core/lib/Thelia/Type/ModelType.php index 9eacef094..dadd47308 100755 --- a/core/lib/Thelia/Type/ModelType.php +++ b/core/lib/Thelia/Type/ModelType.php @@ -63,4 +63,14 @@ class ModelType implements TypeInterface { return $this->isValid($value) ? $value : null; } + + public function getFormType() + { + return 'text'; + } + + public function getFormOptions() + { + return array(); + } } diff --git a/core/lib/Thelia/Type/ModelValidIdType.php b/core/lib/Thelia/Type/ModelValidIdType.php index 9ae94e497..16a39359e 100755 --- a/core/lib/Thelia/Type/ModelValidIdType.php +++ b/core/lib/Thelia/Type/ModelValidIdType.php @@ -67,4 +67,23 @@ class ModelValidIdType implements TypeInterface return $this->isValid($value) ? $queryClass::create()->findPk($value) : null; } + + public function getFormType() + { + return 'choice'; + } + + public function getFormOptions() + { + $queryClass = $this->expectedModelActiveRecordQuery; + + $choices = array(); + foreach($queryClass::create()->find() as $item) { + $choices[$item->getId()] = method_exists($item, "getTitle") ? $item->getTitle() : $item->getId(); + } + + return array( + "choices" => $choices, + ); + } } diff --git a/core/lib/Thelia/Type/TypeInterface.php b/core/lib/Thelia/Type/TypeInterface.php index b293b1783..642c6d935 100755 --- a/core/lib/Thelia/Type/TypeInterface.php +++ b/core/lib/Thelia/Type/TypeInterface.php @@ -35,4 +35,7 @@ interface TypeInterface public function isValid($value); public function getFormattedValue($value); + + public function getFormType(); + public function getFormOptions(); } diff --git a/templates/admin/default/tax-edit.html b/templates/admin/default/tax-edit.html index 435ace42b..173246d76 100644 --- a/templates/admin/default/tax-edit.html +++ b/templates/admin/default/tax-edit.html @@ -76,7 +76,7 @@
- {foreach $choices as $choice} {/foreach} @@ -85,6 +85,24 @@
{/form_field} + {form_tagged_fields form=$form tag='requirements'} +
+ + {if $formType == 'choice'} + + {/if} + {if $formType == 'text'} + + {/if} +
+ {/form_tagged_fields} +
@@ -123,6 +141,10 @@ From c6dbb76ebbfc0a59b0383d696488b302d4ff4044 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 16 Oct 2013 12:02:59 +0200 Subject: [PATCH 06/50] thelia type constraints --- core/lib/Thelia/Form/TaxCreationForm.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php index 302e55890..5448d3367 100644 --- a/core/lib/Thelia/Form/TaxCreationForm.php +++ b/core/lib/Thelia/Form/TaxCreationForm.php @@ -65,7 +65,11 @@ class TaxCreationForm extends BaseForm $this->formBuilder ->add($type . '_' . $name, new TheliaType(), array( "instance" => $requirementType, - "constraints" => array(new NotBlank()), + "constraints" => array( + "methods" => array( + array($this, "verifyTaxId"), + ), + ), "attr" => array( "tag" => "requirements", ), From 60fd54d5c3ff5b5555f876a3666a818741b32e5b Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 16 Oct 2013 16:20:21 +0200 Subject: [PATCH 07/50] restart thelia form type --- .../Admin/AbstractCrudController.php | 2 ++ .../Thelia/Controller/Admin/TaxController.php | 12 ++++++++++ core/lib/Thelia/Core/Form/Type/TheliaType.php | 10 +++++--- core/lib/Thelia/Core/Template/Loop/Tax.php | 4 +++- core/lib/Thelia/Form/TaxCreationForm.php | 23 +++++++++++++++++-- templates/admin/default/tax-edit.html | 4 ++-- 6 files changed, 47 insertions(+), 8 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php index 170c35c4f..a1be6a15d 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractCrudController.php @@ -392,6 +392,8 @@ abstract class AbstractCrudController extends BaseAdminController // Get the form field values $data = $form->getData(); + $dataType = $form->all(); + $changeEvent = $this->getUpdateEvent($data); $this->dispatch($this->updateEventIdentifier, $changeEvent); diff --git a/core/lib/Thelia/Controller/Admin/TaxController.php b/core/lib/Thelia/Controller/Admin/TaxController.php index 0c83aa4cb..bbaf075cb 100644 --- a/core/lib/Thelia/Controller/Admin/TaxController.php +++ b/core/lib/Thelia/Controller/Admin/TaxController.php @@ -76,6 +76,11 @@ class TaxController extends AbstractCrudController { $event = new TaxEvent(); + /* check the requirements */ + if(!$this->checkRequirements($formData)) { + + } + $event->setLocale($formData['locale']); $event->setId($formData['id']); $event->setTitle($formData['title']); @@ -195,4 +200,11 @@ class TaxController extends AbstractCrudController "admin.configuration.taxes-rules.list" ); } + + protected function checkRequirements($formData) + { + $type = $formData['type']; + + + } } \ No newline at end of file diff --git a/core/lib/Thelia/Core/Form/Type/TheliaType.php b/core/lib/Thelia/Core/Form/Type/TheliaType.php index 4820f9b3b..19524ec85 100644 --- a/core/lib/Thelia/Core/Form/Type/TheliaType.php +++ b/core/lib/Thelia/Core/Form/Type/TheliaType.php @@ -12,12 +12,16 @@ class TheliaType extends AbstractType { $resolver->setDefaults(array( 'instance' => false, - 'type' => false, - 'options' => false, + 'type' => false, + 'options' => false, )); $resolver->setAllowedTypes(array( - 'instance' => array('Thelia\Type\TypeInterface'), + 'instance' => array('Thelia\Type\TypeInterface'), + )); + + $resolver->setAllowedValues(array( + 'type' => array('text', 'choice'), )); } diff --git a/core/lib/Thelia/Core/Template/Loop/Tax.php b/core/lib/Thelia/Core/Template/Loop/Tax.php index 0248e60d8..a927a0dbd 100644 --- a/core/lib/Thelia/Core/Template/Loop/Tax.php +++ b/core/lib/Thelia/Core/Template/Loop/Tax.php @@ -151,10 +151,12 @@ class Tax extends BaseI18nLoop $loopResultRow = new LoopResultRow($loopResult, $tax, $this->versionable, $this->timestampable, $this->countable); + $requirements = json_decode( base64_decode( $tax->getSerializedRequirements() ), true ); + $loopResultRow ->set("ID" , $tax->getId()) ->set("TYPE" , $tax->getType()) - ->set("SERIALIZED_REQUIREMENTS" , $tax->getSerializedRequirements()) + ->set("REQUIREMENTS" , $requirements) ->set("IS_TRANSLATED" , $tax->getVirtualColumn('IS_TRANSLATED')) ->set("LOCALE" , $locale) ->set("TITLE" , $tax->getVirtualColumn('i18n_TITLE')) diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php index 5448d3367..901c459b3 100644 --- a/core/lib/Thelia/Form/TaxCreationForm.php +++ b/core/lib/Thelia/Form/TaxCreationForm.php @@ -24,6 +24,7 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Form\Type\TheliaType; use Thelia\Core\Translation\Translator; use Thelia\TaxEngine\TaxEngine; @@ -54,6 +55,13 @@ class TaxCreationForm extends BaseForm "required" => true, "constraints" => array( new Constraints\NotBlank(), + new Constraints\Callback( + array( + "methods" => array( + array($this, "verifyRequirements"), + ), + ) + ), ), "label" => Translator::getInstance()->trans("Type"), "label_attr" => array("for" => "type_field"), @@ -66,8 +74,12 @@ class TaxCreationForm extends BaseForm ->add($type . '_' . $name, new TheliaType(), array( "instance" => $requirementType, "constraints" => array( - "methods" => array( - array($this, "verifyTaxId"), + new Constraints\Callback( + array( + "methods" => array( + array($this, "verifyRequirements"), + ), + ) ), ), "attr" => array( @@ -91,4 +103,11 @@ class TaxCreationForm extends BaseForm { return "thelia_tax_creation"; } + + public function verifyRequirements($value, ExecutionContextInterface $context) + { + $in = true; + + + } } diff --git a/templates/admin/default/tax-edit.html b/templates/admin/default/tax-edit.html index 173246d76..07a18a111 100644 --- a/templates/admin/default/tax-edit.html +++ b/templates/admin/default/tax-edit.html @@ -93,12 +93,12 @@ {if $formType == 'choice'} {/if} {if $formType == 'text'} - + {/if}
{/form_tagged_fields} From a2048bec240701760e9f6f0e07c083c41cac5c9b Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Wed, 16 Oct 2013 17:10:53 +0200 Subject: [PATCH 08/50] theliatype in form : types now extends bastype which implement typeinterface basetype provides verifiyForm method wich can be call in Callback constraint --- core/lib/Thelia/Core/Form/Type/TheliaType.php | 2 +- .../Core/Template/Smarty/Plugins/Form.php | 1 + core/lib/Thelia/Form/TaxCreationForm.php | 13 ++---- .../Thelia/Type/AlphaNumStringListType.php | 2 +- core/lib/Thelia/Type/AlphaNumStringType.php | 2 +- core/lib/Thelia/Type/AnyType.php | 2 +- core/lib/Thelia/Type/BaseType.php | 46 +++++++++++++++++++ core/lib/Thelia/Type/BooleanOrBothType.php | 2 +- core/lib/Thelia/Type/BooleanType.php | 2 +- core/lib/Thelia/Type/EnumListType.php | 2 +- core/lib/Thelia/Type/EnumType.php | 2 +- .../lib/Thelia/Type/FloatToFloatArrayType.php | 2 +- core/lib/Thelia/Type/FloatType.php | 2 +- core/lib/Thelia/Type/IntListType.php | 2 +- .../Thelia/Type/IntToCombinedIntsListType.php | 2 +- .../Type/IntToCombinedStringsListType.php | 2 +- core/lib/Thelia/Type/IntType.php | 2 +- core/lib/Thelia/Type/JsonType.php | 2 +- core/lib/Thelia/Type/ModelType.php | 2 +- core/lib/Thelia/Type/ModelValidIdType.php | 2 +- core/lib/Thelia/Type/TypeInterface.php | 4 +- templates/admin/default/tax-edit.html | 2 +- 22 files changed, 71 insertions(+), 29 deletions(-) create mode 100644 core/lib/Thelia/Type/BaseType.php diff --git a/core/lib/Thelia/Core/Form/Type/TheliaType.php b/core/lib/Thelia/Core/Form/Type/TheliaType.php index 19524ec85..7aeeab3e0 100644 --- a/core/lib/Thelia/Core/Form/Type/TheliaType.php +++ b/core/lib/Thelia/Core/Form/Type/TheliaType.php @@ -39,7 +39,7 @@ class TheliaType extends AbstractType public function getParent() { - return 'form'; + return 'text'; } public function getName() diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 7897b74a0..58fe2bf74 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -152,6 +152,7 @@ class Form extends AbstractSmartyPlugin } $template->assign("attr", implode(" ", $attr)); + $template->assign("attr_list", $fieldVars["attr"]); } protected function assignFormTypeValues($template, $formFieldConfig, $formFieldView) diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php index 901c459b3..ee9ef532d 100644 --- a/core/lib/Thelia/Form/TaxCreationForm.php +++ b/core/lib/Thelia/Form/TaxCreationForm.php @@ -55,13 +55,6 @@ class TaxCreationForm extends BaseForm "required" => true, "constraints" => array( new Constraints\NotBlank(), - new Constraints\Callback( - array( - "methods" => array( - array($this, "verifyRequirements"), - ), - ) - ), ), "label" => Translator::getInstance()->trans("Type"), "label_attr" => array("for" => "type_field"), @@ -77,7 +70,7 @@ class TaxCreationForm extends BaseForm new Constraints\Callback( array( "methods" => array( - array($this, "verifyRequirements"), + array($requirementType, "verifyForm"), ), ) ), @@ -104,10 +97,10 @@ class TaxCreationForm extends BaseForm return "thelia_tax_creation"; } - public function verifyRequirements($value, ExecutionContextInterface $context) + public function verifyForm($value, ExecutionContextInterface $context) { $in = true; - + //$this->getForm()->getChildren() } } diff --git a/core/lib/Thelia/Type/AlphaNumStringListType.php b/core/lib/Thelia/Type/AlphaNumStringListType.php index 9205373ca..ccf21606d 100755 --- a/core/lib/Thelia/Type/AlphaNumStringListType.php +++ b/core/lib/Thelia/Type/AlphaNumStringListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class AlphaNumStringListType implements TypeInterface +class AlphaNumStringListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/AlphaNumStringType.php b/core/lib/Thelia/Type/AlphaNumStringType.php index f574300cb..ad9595f20 100755 --- a/core/lib/Thelia/Type/AlphaNumStringType.php +++ b/core/lib/Thelia/Type/AlphaNumStringType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class AlphaNumStringType implements TypeInterface +class AlphaNumStringType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/AnyType.php b/core/lib/Thelia/Type/AnyType.php index bf5349546..4e844c6e9 100755 --- a/core/lib/Thelia/Type/AnyType.php +++ b/core/lib/Thelia/Type/AnyType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class AnyType implements TypeInterface +class AnyType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/BaseType.php b/core/lib/Thelia/Type/BaseType.php new file mode 100644 index 000000000..7ab1a86ec --- /dev/null +++ b/core/lib/Thelia/Type/BaseType.php @@ -0,0 +1,46 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Type; + +use Symfony\Component\Validator\ExecutionContextInterface; + +/** + * + * @author Etienne Roudeix + * + */ +abstract class BaseType implements TypeInterface +{ + abstract public function getType(); + abstract public function isValid($value); + abstract public function getFormattedValue($value); + abstract public function getFormType(); + abstract public function getFormOptions(); + + public function verifyForm($value, ExecutionContextInterface $context) + { + if( ! $this->isValid($value) ) { + $context->addViolation("Thelia Type not matched"); + } + } +} diff --git a/core/lib/Thelia/Type/BooleanOrBothType.php b/core/lib/Thelia/Type/BooleanOrBothType.php index eacd89ffc..25f3d9994 100755 --- a/core/lib/Thelia/Type/BooleanOrBothType.php +++ b/core/lib/Thelia/Type/BooleanOrBothType.php @@ -29,7 +29,7 @@ namespace Thelia\Type; * */ -class BooleanOrBothType implements TypeInterface +class BooleanOrBothType extends BaseType { const ANY = '*'; diff --git a/core/lib/Thelia/Type/BooleanType.php b/core/lib/Thelia/Type/BooleanType.php index e231ce26a..5f36453de 100755 --- a/core/lib/Thelia/Type/BooleanType.php +++ b/core/lib/Thelia/Type/BooleanType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class BooleanType implements TypeInterface +class BooleanType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/EnumListType.php b/core/lib/Thelia/Type/EnumListType.php index 0d82e3a3e..5b54c48bf 100755 --- a/core/lib/Thelia/Type/EnumListType.php +++ b/core/lib/Thelia/Type/EnumListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class EnumListType implements TypeInterface +class EnumListType extends BaseType { protected $values = array(); diff --git a/core/lib/Thelia/Type/EnumType.php b/core/lib/Thelia/Type/EnumType.php index 91f45a308..1283acde0 100755 --- a/core/lib/Thelia/Type/EnumType.php +++ b/core/lib/Thelia/Type/EnumType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class EnumType implements TypeInterface +class EnumType extends BaseType { protected $values = array(); diff --git a/core/lib/Thelia/Type/FloatToFloatArrayType.php b/core/lib/Thelia/Type/FloatToFloatArrayType.php index 404b7e4e4..f55997f55 100755 --- a/core/lib/Thelia/Type/FloatToFloatArrayType.php +++ b/core/lib/Thelia/Type/FloatToFloatArrayType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class FloatToFloatArrayType implements TypeInterface +class FloatToFloatArrayType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/FloatType.php b/core/lib/Thelia/Type/FloatType.php index 74d71adfb..830622a86 100755 --- a/core/lib/Thelia/Type/FloatType.php +++ b/core/lib/Thelia/Type/FloatType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class FloatType implements TypeInterface +class FloatType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntListType.php b/core/lib/Thelia/Type/IntListType.php index ff87bbd4e..5fe31aa3c 100755 --- a/core/lib/Thelia/Type/IntListType.php +++ b/core/lib/Thelia/Type/IntListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntListType implements TypeInterface +class IntListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntToCombinedIntsListType.php b/core/lib/Thelia/Type/IntToCombinedIntsListType.php index dfa21310d..562e160dd 100755 --- a/core/lib/Thelia/Type/IntToCombinedIntsListType.php +++ b/core/lib/Thelia/Type/IntToCombinedIntsListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntToCombinedIntsListType implements TypeInterface +class IntToCombinedIntsListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntToCombinedStringsListType.php b/core/lib/Thelia/Type/IntToCombinedStringsListType.php index 38152fdaa..5c4327dc8 100755 --- a/core/lib/Thelia/Type/IntToCombinedStringsListType.php +++ b/core/lib/Thelia/Type/IntToCombinedStringsListType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntToCombinedStringsListType implements TypeInterface +class IntToCombinedStringsListType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/IntType.php b/core/lib/Thelia/Type/IntType.php index 7a06a50fb..5aa146e60 100755 --- a/core/lib/Thelia/Type/IntType.php +++ b/core/lib/Thelia/Type/IntType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class IntType implements TypeInterface +class IntType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/JsonType.php b/core/lib/Thelia/Type/JsonType.php index a1a1f5af6..502a43953 100755 --- a/core/lib/Thelia/Type/JsonType.php +++ b/core/lib/Thelia/Type/JsonType.php @@ -28,7 +28,7 @@ namespace Thelia\Type; * */ -class JsonType implements TypeInterface +class JsonType extends BaseType { public function getType() { diff --git a/core/lib/Thelia/Type/ModelType.php b/core/lib/Thelia/Type/ModelType.php index dadd47308..a8ab8c553 100755 --- a/core/lib/Thelia/Type/ModelType.php +++ b/core/lib/Thelia/Type/ModelType.php @@ -30,7 +30,7 @@ use Thelia\Exception\TypeException; * @author Etienne Roudeix * */ -class ModelType implements TypeInterface +class ModelType extends BaseType { protected $expectedModelActiveRecord = null; diff --git a/core/lib/Thelia/Type/ModelValidIdType.php b/core/lib/Thelia/Type/ModelValidIdType.php index 16a39359e..a9bfec7b5 100755 --- a/core/lib/Thelia/Type/ModelValidIdType.php +++ b/core/lib/Thelia/Type/ModelValidIdType.php @@ -30,7 +30,7 @@ use Thelia\Exception\TypeException; * @author Etienne Roudeix * */ -class ModelValidIdType implements TypeInterface +class ModelValidIdType extends BaseType { protected $expectedModelActiveRecordQuery = null; diff --git a/core/lib/Thelia/Type/TypeInterface.php b/core/lib/Thelia/Type/TypeInterface.php index 642c6d935..99e2f77e0 100755 --- a/core/lib/Thelia/Type/TypeInterface.php +++ b/core/lib/Thelia/Type/TypeInterface.php @@ -22,12 +22,13 @@ /*************************************************************************************/ namespace Thelia\Type; +use Symfony\Component\Validator\ExecutionContextInterface; + /** * * @author Etienne Roudeix * */ - interface TypeInterface { public function getType(); @@ -38,4 +39,5 @@ interface TypeInterface public function getFormType(); public function getFormOptions(); + public function verifyForm($value, ExecutionContextInterface $context); } diff --git a/templates/admin/default/tax-edit.html b/templates/admin/default/tax-edit.html index 07a18a111..2bb0b260e 100644 --- a/templates/admin/default/tax-edit.html +++ b/templates/admin/default/tax-edit.html @@ -88,7 +88,7 @@ {form_tagged_fields form=$form tag='requirements'}
{if $formType == 'choice'} +
{/form_field} @@ -65,7 +65,7 @@ {intl l="The detailed description."} - +
{/form_field} @@ -78,27 +78,29 @@
+ + {$typeValue = $value} {/form_field} {form_tagged_fields form=$form tag='requirements'} -
+
{if $formType == 'choice'} - {foreach $choices as $choice} - + {/foreach} {/if} {if $formType == 'text'} - + {/if}
{/form_tagged_fields} @@ -142,7 +144,10 @@ {/block} \ No newline at end of file From 1b865d71a3cc51012d5c12623bdb1146827813d5 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 17 Oct 2013 15:36:11 +0200 Subject: [PATCH 14/50] crowl all module descriptor file for discovering new modules --- core/lib/Thelia/Module/BaseModule.php | 13 ++++++++++++- core/lib/Thelia/Module/ModuleManagement.php | 4 +++- core/lib/Thelia/Module/schema/module/module.xsd | 2 +- local/modules/Cheque/Config/module.xml | 6 ++---- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 4f18b02a8..8f3ccb2f5 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -43,6 +43,8 @@ abstract class BaseModule extends ContainerAware const IS_ACTIVATED = 1; const IS_NOT_ACTIVATED = 0; + protected $reflected; + public function __construct() { @@ -178,7 +180,16 @@ abstract class BaseModule extends ContainerAware return $moduleModel; } - abstract public function getCode(); + + public function getCode() + { + if (null === $this->reflected) { + $this->reflected = new \ReflectionObject($this); + } + + return dirname($this->reflected->getFileName()); + } + abstract public function install(); abstract public function afterActivation(); abstract public function destroy(); diff --git a/core/lib/Thelia/Module/ModuleManagement.php b/core/lib/Thelia/Module/ModuleManagement.php index 643f2a9d1..56563964f 100644 --- a/core/lib/Thelia/Module/ModuleManagement.php +++ b/core/lib/Thelia/Module/ModuleManagement.php @@ -47,8 +47,10 @@ class ModuleManagement ->name('module.xml') ->in($this->baseModuleDir . '/*/Config'); + $descriptorValidator = new ModuleDescriptorValidator(); foreach ($finder as $file) { - echo $file->getRealPath()."\n"; + $content = $descriptorValidator->getDescriptor($file->getRealPath()); + var_dump($content); exit; } } diff --git a/core/lib/Thelia/Module/schema/module/module.xsd b/core/lib/Thelia/Module/schema/module/module.xsd index c394a8f26..bbe2f47d8 100644 --- a/core/lib/Thelia/Module/schema/module/module.xsd +++ b/core/lib/Thelia/Module/schema/module/module.xsd @@ -27,7 +27,7 @@ Module version - + Module author diff --git a/local/modules/Cheque/Config/module.xml b/local/modules/Cheque/Config/module.xml index 5d2e70301..d0ef5f619 100755 --- a/local/modules/Cheque/Config/module.xml +++ b/local/modules/Cheque/Config/module.xml @@ -1,11 +1,9 @@ - + + Cheque\\Cheque Cheque - Cheque\\Cheque 1.1 Manuel Raynaud From 1b0de7144a401834f2ad5ab9156633120a8ee9d6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 17 Oct 2013 17:20:29 +0200 Subject: [PATCH 15/50] end updating module list --- .../Thelia/Command/Skeleton/Module/module.xml | 18 +++++ core/lib/Thelia/Module/BaseModule.php | 2 +- core/lib/Thelia/Module/ModuleManagement.php | 66 ++++++++++++++++++- .../Thelia/Module/schema/module/module.xsd | 2 +- local/modules/Cheque/Config/module.xml | 5 +- local/modules/Colissimo/Config/module.xml | 18 +++++ local/modules/FakeCB/Config/module.xml | 18 +++++ .../modules/TheliaDebugBar/Config/module.xml | 18 +++++ 8 files changed, 143 insertions(+), 4 deletions(-) mode change 100755 => 100644 local/modules/Colissimo/Config/module.xml mode change 100755 => 100644 local/modules/FakeCB/Config/module.xml mode change 100755 => 100644 local/modules/TheliaDebugBar/Config/module.xml diff --git a/core/lib/Thelia/Command/Skeleton/Module/module.xml b/core/lib/Thelia/Command/Skeleton/Module/module.xml index e69de29bb..ae3dbbe53 100755 --- a/core/lib/Thelia/Command/Skeleton/Module/module.xml +++ b/core/lib/Thelia/Command/Skeleton/Module/module.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 8f3ccb2f5..c7979be6e 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -187,7 +187,7 @@ abstract class BaseModule extends ContainerAware $this->reflected = new \ReflectionObject($this); } - return dirname($this->reflected->getFileName()); + return basename(dirname($this->reflected->getFileName())); } abstract public function install(); diff --git a/core/lib/Thelia/Module/ModuleManagement.php b/core/lib/Thelia/Module/ModuleManagement.php index 56563964f..84e6c6457 100644 --- a/core/lib/Thelia/Module/ModuleManagement.php +++ b/core/lib/Thelia/Module/ModuleManagement.php @@ -22,7 +22,15 @@ /*************************************************************************************/ namespace Thelia\Module; + +use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Exception\PropelException; +use Propel\Runtime\Propel; use Symfony\Component\Finder\Finder; +use Thelia\Model\Map\ModuleTableMap; +use Thelia\Model\Module; +use Thelia\Model\ModuleI18n; +use Thelia\Model\ModuleQuery; /** @@ -33,6 +41,7 @@ use Symfony\Component\Finder\Finder; class ModuleManagement { protected $baseModuleDir; + protected $reflected; public function __construct() { @@ -50,8 +59,63 @@ class ModuleManagement $descriptorValidator = new ModuleDescriptorValidator(); foreach ($finder as $file) { $content = $descriptorValidator->getDescriptor($file->getRealPath()); - var_dump($content); exit; + $reflected = new \ReflectionClass((string)$content->fullnamespace); + $code = basename(dirname($reflected->getFileName())); + if(null === ModuleQuery::create()->filterByCode($code)->findOne()) { + $module = new Module(); + $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME); + $con->beginTransaction(); + try { + $module + ->setCode($code) + ->setFullNamespace((string)$content->fullnamespace) + ->setType($this->getModuleType($reflected)) + ->setActivate(0) + ->save($con); + + $this->saveDescription($module, $content, $con); + + $con->commit(); + } catch(PropelException $e) { + $con->rollBack(); + throw $e; + } + + } } } + private function saveDescription(Module $module,\SimpleXMLElement $content, ConnectionInterface $con) + { + + foreach($content->descriptive as $description) + { + $locale = $description->attributes()->locale; + + $moduleI18n = new ModuleI18n(); + + $moduleI18n + ->setLocale($locale) + ->setModule($module) + ->setTitle($description->title) + ->setDescription(isset($description->description)?$description->description:null) + ->setPostscriptum(isset($description->postscriptum)?$description->postscriptum:null) + ->setChapo(isset($description->subtitle)?$description->subtitle:null) + ->save($con); + } + } + + private function getModuleType(\ReflectionClass $reflected) + { + if($reflected->implementsInterface('Thelia\Module\DeliveryModuleInterface')) { + return BaseModule::DELIVERY_MODULE_TYPE; + } else if($reflected->implementsInterface('Thelia\Module\PaymentModuleInterface')) { + return BaseModule::PAYMENT_MODULE_TYPE; + } else { + return BaseModule::CLASSIC_MODULE_TYPE; + } + + + } + } \ No newline at end of file diff --git a/core/lib/Thelia/Module/schema/module/module.xsd b/core/lib/Thelia/Module/schema/module/module.xsd index bbe2f47d8..bcd7bd292 100644 --- a/core/lib/Thelia/Module/schema/module/module.xsd +++ b/core/lib/Thelia/Module/schema/module/module.xsd @@ -3,7 +3,7 @@ - + The full namespace for the main class module (for example MyModule\MyModule) diff --git a/local/modules/Cheque/Config/module.xml b/local/modules/Cheque/Config/module.xml index d0ef5f619..1df6cf589 100755 --- a/local/modules/Cheque/Config/module.xml +++ b/local/modules/Cheque/Config/module.xml @@ -1,9 +1,12 @@ - Cheque\\Cheque + Cheque\Cheque Cheque + + Cheque + 1.1 Manuel Raynaud diff --git a/local/modules/Colissimo/Config/module.xml b/local/modules/Colissimo/Config/module.xml old mode 100755 new mode 100644 index e69de29bb..1f47ad9c9 --- a/local/modules/Colissimo/Config/module.xml +++ b/local/modules/Colissimo/Config/module.xml @@ -0,0 +1,18 @@ + + + Colissimo\Colissimo + + colisimo + + + colisimo + + 1.0 + + Manuel Raynaud + mraynaud@openstudio.fr + + delivery + 2.0.0 + alpha + diff --git a/local/modules/FakeCB/Config/module.xml b/local/modules/FakeCB/Config/module.xml old mode 100755 new mode 100644 index e69de29bb..0beea57f4 --- a/local/modules/FakeCB/Config/module.xml +++ b/local/modules/FakeCB/Config/module.xml @@ -0,0 +1,18 @@ + + + FakeCB\FakeCB + + fake cb + + + simulation cb + + 1.0 + + Manuel Raynaud + mraynaud@openstudio.fr + + payment + 2.0.0 + alpha + diff --git a/local/modules/TheliaDebugBar/Config/module.xml b/local/modules/TheliaDebugBar/Config/module.xml old mode 100755 new mode 100644 index e69de29bb..61a4c1b0e --- a/local/modules/TheliaDebugBar/Config/module.xml +++ b/local/modules/TheliaDebugBar/Config/module.xml @@ -0,0 +1,18 @@ + + + TheliaDebugBar\TheliaDebugBar + + debugbar for thelia + + + debugbar pour thelia + + 1.0 + + Manuel Raynaud + mraynaud@openstudio.fr + + classic + 2.0.0 + alpha + From d25ad53d5a4fcd6da636d8e02b485d5db84cffd7 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 17 Oct 2013 18:26:23 +0200 Subject: [PATCH 16/50] create module event and eventListener --- core/lib/Thelia/Action/Module.php | 69 +++++++++++++++++++ core/lib/Thelia/Config/Resources/action.xml | 5 ++ .../Thelia/Config/Resources/routing/admin.xml | 5 ++ .../Controller/Admin/ModuleController.php | 30 +++++++- core/lib/Thelia/Controller/BaseController.php | 6 +- .../Thelia/Core/Event/Module/ModuleEvent.php | 69 +++++++++++++++++++ .../Module/ModuleToggleActivationEvent.php | 67 ++++++++++++++++++ core/lib/Thelia/Core/Event/TheliaEvents.php | 2 + .../admin/default/includes/module-block.html | 9 ++- 9 files changed, 256 insertions(+), 6 deletions(-) create mode 100644 core/lib/Thelia/Action/Module.php create mode 100644 core/lib/Thelia/Core/Event/Module/ModuleEvent.php create mode 100644 core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php new file mode 100644 index 000000000..91a51c3af --- /dev/null +++ b/core/lib/Thelia/Action/Module.php @@ -0,0 +1,69 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Module\ModuleToggleActivationEvent; +use Thelia\Core\Event\TheliaEvents; + + +/** + * Class Module + * @package Thelia\Action + * @author Manuel Raynaud + */ +class Module extends BaseAction implements EventSubscriberInterface +{ + + public function toggleActivation(ModuleToggleActivationEvent $event) + { + + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128) + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index b3bc085bf..8b4cfe783 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -136,6 +136,11 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index d554f0550..a3a350365 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -820,6 +820,11 @@ Thelia\Controller\Admin\ModuleController::indexAction + + Thelia\Controller\Admin\ModuleController::toggleActivationAction + \d+ + + diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index 1f0411987..66bd11e49 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -22,6 +22,9 @@ /*************************************************************************************/ namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\Module\ModuleToggleActivationEvent; +use Thelia\Core\Event\TheliaEvents; use Thelia\Module\ModuleManagement; /** @@ -35,11 +38,10 @@ class ModuleController extends BaseAdminController { if (null !== $response = $this->checkAuth("admin.module.view")) return $response; - $modulemanagement = new ModuleManagement(); $modulemanagement->updateModules(); - return $this->render("modules", array("display_module" => 20)); + return $this->render("modules"); } public function updateAction($module_id) @@ -48,4 +50,28 @@ class ModuleController extends BaseAdminController "module_id" => $module_id )); } + + public function toggleActivationAction($module_id) + { + if (null !== $response = $this->checkAuth("admin.module.update")) return $response; + $message = null; + try { + $event = new ModuleToggleActivationEvent($module_id); + $this->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $event); + } catch (\Exception $e) { + $message = $e->getMessage(); + } + + + if($this->getRequest()->isXmlHttpRequest()) { + if($message) { + $response = $this->nullResponse($message, 500); + } + $response = $this->nullResponse(); + } else { + $response = $this->render("modules"); + } + + return $response; + } } diff --git a/core/lib/Thelia/Controller/BaseController.php b/core/lib/Thelia/Controller/BaseController.php index 8c819159b..e9f359411 100755 --- a/core/lib/Thelia/Controller/BaseController.php +++ b/core/lib/Thelia/Controller/BaseController.php @@ -58,7 +58,7 @@ class BaseController extends ContainerAware /** * Return an empty response (after an ajax request, for example) */ - protected function nullResponse($status = 200) + protected function nullResponse($content = null, $status = 200) { return new Response(null, $status); } @@ -66,9 +66,9 @@ class BaseController extends ContainerAware /** * Return a JSON response */ - protected function jsonResponse($json_data) + protected function jsonResponse($json_data, $status = 200) { - return new Response($json_data, 200, array('content-type' => 'application/json')); + return new Response($json_data, $status, array('content-type' => 'application/json')); } /** diff --git a/core/lib/Thelia/Core/Event/Module/ModuleEvent.php b/core/lib/Thelia/Core/Event/Module/ModuleEvent.php new file mode 100644 index 000000000..e9cf2623e --- /dev/null +++ b/core/lib/Thelia/Core/Event/Module/ModuleEvent.php @@ -0,0 +1,69 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Module; +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Module; + + +/** + * Class ModuleEvent + * @package Thelia\Core\Event\Module + * @author Manuel Raynaud + */ +class ModuleEvent extends ActionEvent +{ + /** + * @var \Thelia\Model\Module + */ + protected $module; + + function __construct(Module $module = null) + { + $this->module = $module; + } + + /** + * @param \Thelia\Model\Module $module + * + * @return $this + */ + public function setModule(Module $module) + { + $this->module = $module; + + return $this; + } + + /** + * @return \Thelia\Model\Module + */ + public function getModule() + { + return $this->module; + } + + + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php b/core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php new file mode 100644 index 000000000..dd517d8ff --- /dev/null +++ b/core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Module; + + +/** + * Class ModuleToggleActivationEvent + * @package Thelia\Core\Event\Module + * @author Manuel Raynaud + */ +class ModuleToggleActivationEvent extends ModuleEvent +{ + /** + * @var int + */ + protected $module_id; + + function __construct($module_id) + { + $this->module_id = $module_id; + } + + /** + * @param int $module_id + * + * @return $this + */ + public function setModuleId($module_id) + { + $this->module_id = $module_id; + + return $this; + } + + /** + * @return int + */ + public function getModuleId() + { + return $this->module_id; + } + + + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index aa365e54a..78e96bf97 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -657,4 +657,6 @@ final class TheliaEvents const GENERATE_PDF = 'thelia.generatePdf'; + const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation'; + } diff --git a/templates/admin/default/includes/module-block.html b/templates/admin/default/includes/module-block.html index 7784c84db..2b45f5bc3 100644 --- a/templates/admin/default/includes/module-block.html +++ b/templates/admin/default/includes/module-block.html @@ -22,9 +22,16 @@ {$TITLE} {$CHAPO} -
+
+ {module_include location='modules_table_row'} From 6d791f5bf7e8e80d578e52f3a99d21218d9f30b3 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 17 Oct 2013 18:50:00 +0200 Subject: [PATCH 17/50] process module toggle activation --- core/lib/Thelia/Action/Module.php | 19 +++++ .../Controller/Admin/ModuleController.php | 7 +- core/lib/Thelia/Module/BaseModule.php | 80 ++++++++++++++++--- local/modules/Cheque/Cheque.php | 11 +-- local/modules/Colissimo/Colissimo.php | 19 ----- local/modules/FakeCB/FakeCB.php | 11 +-- .../modules/TheliaDebugBar/TheliaDebugBar.php | 15 ---- 7 files changed, 99 insertions(+), 63 deletions(-) diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 91a51c3af..18fdb85cb 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -25,6 +25,8 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Module\ModuleToggleActivationEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\ModuleQuery; +use Thelia\Module\BaseModule; /** @@ -37,7 +39,24 @@ class Module extends BaseAction implements EventSubscriberInterface public function toggleActivation(ModuleToggleActivationEvent $event) { + if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) { + $moduleClass = new \ReflectionClass($module->getFullNamespace()); + $moduleInstance = $moduleClass->newInstance(); + + if( method_exists($moduleInstance, 'setContainer')) { + $moduleInstance->setContainer($this->container); + if($module->getActivate() == BaseModule::IS_ACTIVATED) { + $moduleInstance->deActivate($module); + } else { + $moduleInstance->activate($module); + } + } + + if($module->isModified()) { + $event->setModule($module); + } + } } /** diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index 66bd11e49..ec7ff472f 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -58,6 +58,11 @@ class ModuleController extends BaseAdminController try { $event = new ModuleToggleActivationEvent($module_id); $this->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $event); + + if(null === $event->getModule()) { + throw new \LogicException( + $this->getTranslator()->trans("No %obj was updated.", array('%obj' => 'Module'))); + } } catch (\Exception $e) { $message = $e->getMessage(); } @@ -69,7 +74,7 @@ class ModuleController extends BaseAdminController } $response = $this->nullResponse(); } else { - $response = $this->render("modules"); + $this->redirectToRoute('admin.module'); } return $response; diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index c7979be6e..6cfc79d28 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -24,7 +24,10 @@ namespace Thelia\Module; +use Propel\Runtime\Connection\ConnectionInterface; +use Propel\Runtime\Propel; use Symfony\Component\DependencyInjection\ContainerAware; +use Thelia\Model\Map\ModuleTableMap; use Thelia\Model\ModuleI18nQuery; use Thelia\Model\Map\ModuleImageTableMap; use Thelia\Model\ModuleI18n; @@ -50,22 +53,54 @@ abstract class BaseModule extends ContainerAware } - public function activate() + + public function activate($moduleModel = null) { - $moduleModel = $this->getModuleModel(); + if(null === $moduleModel) { + $moduleModel = $this->getModuleModel(); + } + if ($moduleModel->getActivate() == self::IS_NOT_ACTIVATED) { - $moduleModel->setActivate(self::IS_ACTIVATED); - $moduleModel->save(); + $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME); + $con->beginTransaction(); try { - $this->afterActivation(); + if($this->preActivation($con)) { + $moduleModel->setActivate(self::IS_ACTIVATED); + $moduleModel->save($con); + $this->postActivation($con); + $con->commit(); + } } catch (\Exception $e) { - $moduleModel->setActivate(self::IS_NOT_ACTIVATED); - $moduleModel->save(); + $con->rollBack(); throw $e; } } } + public function deActivate($moduleModel = null) + { + if(null === $moduleModel) { + $moduleModel = $this->getModuleModel(); + } + if ($moduleModel->getActivate() == self::IS_ACTIVATED) { + $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME); + $con->beginTransaction(); + try { + if($this->preDeactivation($con)) { + $moduleModel->setActivate(self::IS_NOT_ACTIVATED); + $moduleModel->save($con); + $this->postDeactivation($con); + + $con->commit(); + } + } catch (\Exception $e) { + $con->rollBack(); + throw $e; + } + + } + } + public function hasContainer() { return null === $this->container; @@ -190,8 +225,33 @@ abstract class BaseModule extends ContainerAware return basename(dirname($this->reflected->getFileName())); } - abstract public function install(); - abstract public function afterActivation(); - abstract public function destroy(); + public function install(){ + + } + + public function preActivation(ConnectionInterface $con = null) + { + return true; + } + + public function postActivation(ConnectionInterface $con = null) + { + + } + + public function preDeactivation(ConnectionInterface $con = null) + { + return true; + } + + public function postDeactivation(ConnectionInterface $con = null) + { + + } + + public function destroy() + { + + } } diff --git a/local/modules/Cheque/Cheque.php b/local/modules/Cheque/Cheque.php index 4516c84f3..324728990 100755 --- a/local/modules/Cheque/Cheque.php +++ b/local/modules/Cheque/Cheque.php @@ -23,6 +23,7 @@ namespace Cheque; +use Propel\Runtime\Connection\ConnectionInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Thelia\Model\ModuleImageQuery; @@ -59,12 +60,8 @@ class Cheque extends BaseModule implements PaymentModuleInterface // no special process, waiting for the cheque. } - public function install() - { - } - - public function afterActivation() + public function postActivation(ConnectionInterface $con = null) { /* insert the images from image folder if first module activation */ $module = $this->getModuleModel(); @@ -82,10 +79,6 @@ class Cheque extends BaseModule implements PaymentModuleInterface ); } - public function destroy() - { - // TODO: Implement destroy() method. - } public function getCode() { diff --git a/local/modules/Colissimo/Colissimo.php b/local/modules/Colissimo/Colissimo.php index 7ff972feb..adbbb32c3 100755 --- a/local/modules/Colissimo/Colissimo.php +++ b/local/modules/Colissimo/Colissimo.php @@ -67,25 +67,6 @@ class Colissimo extends BaseModule implements DeliveryModuleInterface return 2; } - public function afterActivation() - { - - } - - /** - * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class - * Like install and destroy - */ - public function install() - { - // TODO: Implement install() method. - } - - public function destroy() - { - // TODO: Implement destroy() method. - } - public function getCode() { return 'Colissimo'; diff --git a/local/modules/FakeCB/FakeCB.php b/local/modules/FakeCB/FakeCB.php index ca682fab3..58c8318da 100755 --- a/local/modules/FakeCB/FakeCB.php +++ b/local/modules/FakeCB/FakeCB.php @@ -23,6 +23,7 @@ namespace FakeCB; +use Propel\Runtime\Connection\ConnectionInterface; use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\HttpFoundation\Request; use Thelia\Model\Base\ModuleImageQuery; @@ -59,12 +60,8 @@ class FakeCB extends BaseModule implements PaymentModuleInterface // TODO: Implement pay() method. } - public function install() - { - } - - public function afterActivation() + public function postActivation(ConnectionInterface $con = null) { /* insert the images from image folder if first module activation */ $module = $this->getModuleModel(); @@ -82,10 +79,6 @@ class FakeCB extends BaseModule implements PaymentModuleInterface ); } - public function destroy() - { - // TODO: Implement destroy() method. - } public function getCode() { diff --git a/local/modules/TheliaDebugBar/TheliaDebugBar.php b/local/modules/TheliaDebugBar/TheliaDebugBar.php index da9fddf12..466f50d5a 100755 --- a/local/modules/TheliaDebugBar/TheliaDebugBar.php +++ b/local/modules/TheliaDebugBar/TheliaDebugBar.php @@ -32,21 +32,6 @@ class TheliaDebugBar extends BaseModule * Like install and destroy */ - public function afterActivation() - { - - } - - public function install() - { - // TODO: Implement install() method. - } - - public function destroy() - { - // TODO: Implement destroy() method. - } - public function getCode() { return 'TheliaDebugBar'; From 2ecd1caac604746ed3141a7e8c24e451b3dedc15 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 08:25:42 +0200 Subject: [PATCH 18/50] dispatching event for clearing cache --- core/lib/Thelia/Action/Cache.php | 77 +++++++++++++++++++ core/lib/Thelia/Command/CacheClear.php | 18 +++-- core/lib/Thelia/Config/Resources/action.xml | 5 ++ .../Thelia/Core/Event/Cache/CacheEvent.php | 67 ++++++++++++++++ core/lib/Thelia/Core/Event/TheliaEvents.php | 7 ++ 5 files changed, 166 insertions(+), 8 deletions(-) create mode 100644 core/lib/Thelia/Action/Cache.php create mode 100644 core/lib/Thelia/Core/Event/Cache/CacheEvent.php diff --git a/core/lib/Thelia/Action/Cache.php b/core/lib/Thelia/Action/Cache.php new file mode 100644 index 000000000..6d2cf1a16 --- /dev/null +++ b/core/lib/Thelia/Action/Cache.php @@ -0,0 +1,77 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\Filesystem\Filesystem; +use Thelia\Core\Event\Cache\CacheEvent; +use Thelia\Core\Event\TheliaEvents; + + +/** + * Class Cache + * @package Thelia\Action + * @author Manuel Raynaud + */ +class Cache extends BaseAction implements EventSubscriberInterface +{ + + public function cacheClear(CacheEvent $event) + { + $dir = $event->getDir(); + + $directoryBrowser = new \DirectoryIterator($dir); + + + $fs = new Filesystem(); + $fs->remove($dir); + + } + + /** + * Returns an array of event names this subscriber wants to listen to. + * + * The array keys are event names and the value can be: + * + * * The method name to call (priority defaults to 0) + * * An array composed of the method name to call and the priority + * * An array of arrays composed of the method names to call and respective + * priorities, or 0 if unset + * + * For instance: + * + * * array('eventName' => 'methodName') + * * array('eventName' => array('methodName', $priority)) + * * array('eventName' => array(array('methodName1', $priority), array('methodName2')) + * + * @return array The event names to listen to + * + * @api + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::CACHE_CLEAR => array('cacheClear', 128) + ); + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Command/CacheClear.php b/core/lib/Thelia/Command/CacheClear.php index e85e29741..1d4e7919c 100755 --- a/core/lib/Thelia/Command/CacheClear.php +++ b/core/lib/Thelia/Command/CacheClear.php @@ -30,6 +30,8 @@ use Symfony\Component\Filesystem\Filesystem; use Symfony\Component\Filesystem\Exception\IOException; use Thelia\Command\ContainerAwareCommand; +use Thelia\Core\Event\Cache\CacheEvent; +use Thelia\Core\Event\TheliaEvents; /** * clear the cache @@ -72,7 +74,11 @@ class CacheClear extends ContainerAwareCommand $output->writeln(sprintf("Clearing cache in %s directory", $dir)); try { - $directoryBrowser = new \DirectoryIterator($dir); + $cacheEvent = new CacheEvent($dir); + $this-> + getContainer() + ->get('event_dispatcher') + ->dispatch(TheliaEvents::CACHE_CLEAR, $cacheEvent); } catch (\UnexpectedValueException $e) { // throws same exception code for does not exist and permission denied ... if (!file_exists($dir)) { @@ -82,15 +88,11 @@ class CacheClear extends ContainerAwareCommand } throw $e; - } - - $fs = new Filesystem(); - try { - $fs->remove($dir); - - $output->writeln(sprintf("%s cache dir cleared successfully", $dir)); } catch (IOException $e) { $output->writeln(sprintf("Error during clearing cache : %s", $e->getMessage())); } + + $output->writeln(sprintf("%s cache dir cleared successfully", $dir)); + } } diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 8b4cfe783..9088d1a50 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -141,6 +141,11 @@ + + + + + diff --git a/core/lib/Thelia/Core/Event/Cache/CacheEvent.php b/core/lib/Thelia/Core/Event/Cache/CacheEvent.php new file mode 100644 index 000000000..3a882d5dd --- /dev/null +++ b/core/lib/Thelia/Core/Event/Cache/CacheEvent.php @@ -0,0 +1,67 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Cache; + +use Thelia\Core\Event\ActionEvent; + + +/** + * Class CacheEvent + * @package Thelia\Core\Event\Cache + * @author Manuel Raynaud + */ +class CacheEvent extends ActionEvent +{ + /** + * @var string cache directory + */ + protected $dir; + + public function __construct($dir) + { + $this->dir = $dir; + } + + /** + * @param mixed $dir + * + * @return $this + */ + public function setDir($dir) + { + $this->dir = $dir; + + return $this; + } + + /** + * @return mixed + */ + public function getDir() + { + return $this->dir; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 78e96bf97..f70eca2a1 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -657,6 +657,13 @@ final class TheliaEvents const GENERATE_PDF = 'thelia.generatePdf'; + /** + * sent when a module is activated or deactivated + */ const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation'; + /** + * sent for clearing cache + */ + const CACHE_CLEAR = 'thelia.cache.clear'; } From 3a4fb6f2d240a1a96909dee8a7d08a763359b500 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 08:33:46 +0200 Subject: [PATCH 19/50] clear cache after each activatin or deactivation --- core/lib/Thelia/Action/Module.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 18fdb85cb..5025c513f 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -23,6 +23,7 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Cache\CacheEvent; use Thelia\Core\Event\Module\ModuleToggleActivationEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Model\ModuleQuery; @@ -56,9 +57,18 @@ class Module extends BaseAction implements EventSubscriberInterface if($module->isModified()) { $event->setModule($module); } + + $this->cacheClear(); } } + protected function cacheClear() + { + $cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir')); + + $this->getDispatcher()->dispatch(TheliaEvents::CACHE_CLEAR, $cacheEvent); + } + /** * Returns an array of event names this subscriber wants to listen to. * From 12b5a813641ea541200978b23137327296e5f924 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 09:17:08 +0200 Subject: [PATCH 20/50] display error on ajax module activation --- .../Controller/Admin/ModuleController.php | 8 +++-- .../admin/default/includes/module-block.html | 6 ++-- templates/admin/default/modules.html | 35 +++++++++++++++++++ 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index ec7ff472f..4a22c868a 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -70,9 +70,13 @@ class ModuleController extends BaseAdminController if($this->getRequest()->isXmlHttpRequest()) { if($message) { - $response = $this->nullResponse($message, 500); + $response = $this->jsonResponse(json_encode(array( + "error" => $message + )), 500); + } else { + $response = $this->nullResponse(); } - $response = $this->nullResponse(); + } else { $this->redirectToRoute('admin.module'); } diff --git a/templates/admin/default/includes/module-block.html b/templates/admin/default/includes/module-block.html index 2b45f5bc3..dd499393f 100644 --- a/templates/admin/default/includes/module-block.html +++ b/templates/admin/default/includes/module-block.html @@ -22,14 +22,14 @@ {$TITLE} {$CHAPO} -
+
diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html index 06d7420bd..57bb14bf1 100644 --- a/templates/admin/default/modules.html +++ b/templates/admin/default/modules.html @@ -55,6 +55,21 @@ form_content = {$smarty.capture.delete_module_dialog nofilter} } + + {/block} {block name="javascript-initialization"} @@ -62,4 +77,24 @@ {javascripts file='assets/js/bootstrap-switch/bootstrap-switch.js'} {/javascripts} + + {/block} \ No newline at end of file From 52ed89f1aa3396ca2dfd71657e16334d5bdc1ca6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 09:28:17 +0200 Subject: [PATCH 21/50] fix cs --- core/lib/Thelia/Action/Area.php | 4 +--- core/lib/Thelia/Action/Cache.php | 4 +--- core/lib/Thelia/Action/Content.php | 2 +- core/lib/Thelia/Action/Country.php | 7 ++----- core/lib/Thelia/Action/Customer.php | 1 - core/lib/Thelia/Action/Module.php | 9 ++++---- core/lib/Thelia/Action/Pdf.php | 3 +-- core/lib/Thelia/Action/ShippingZone.php | 5 ++--- core/lib/Thelia/Action/TaxRule.php | 10 ++++----- core/lib/Thelia/Command/Install.php | 6 +++--- .../Thelia/Command/ModuleActivateCommand.php | 1 - .../Thelia/Command/Skeleton/Module/Class.php | 2 +- .../Controller/Admin/AddressController.php | 16 ++++++-------- .../Controller/Admin/BaseAdminController.php | 4 ++-- .../Controller/Admin/CountryController.php | 2 +- .../Controller/Admin/CustomerController.php | 5 ----- .../Controller/Admin/ModuleController.php | 7 +++---- .../Controller/Admin/OrderController.php | 3 +-- .../Admin/ShippingZoneController.php | 1 - .../Controller/Admin/TaxRuleController.php | 6 +++--- .../Core/Event/Area/AreaAddCountryEvent.php | 8 ++----- .../Core/Event/Area/AreaCreateEvent.php | 4 +--- .../Core/Event/Area/AreaDeleteEvent.php | 4 +--- core/lib/Thelia/Core/Event/Area/AreaEvent.php | 3 +-- .../Event/Area/AreaRemoveCountryEvent.php | 3 +-- .../Core/Event/Area/AreaUpdateEvent.php | 3 +-- .../Event/Area/AreaUpdatePostageEvent.php | 8 ++----- .../Thelia/Core/Event/Cache/CacheEvent.php | 4 +--- .../Event/Content/ContentAddFolderEvent.php | 5 +---- .../Content/ContentRemoveFolderEvent.php | 3 +-- .../Core/Event/Country/CountryCreateEvent.php | 4 +--- .../Core/Event/Country/CountryDeleteEvent.php | 5 ++--- .../Core/Event/Country/CountryEvent.php | 6 ++---- .../Country/CountryToggleDefaultEvent.php | 5 ++--- .../Core/Event/Country/CountryUpdateEvent.php | 8 ++----- .../Thelia/Core/Event/Module/ModuleEvent.php | 8 ++----- .../Module/ModuleToggleActivationEvent.php | 8 ++----- core/lib/Thelia/Core/Event/PdfEvent.php | 16 +++++++------- .../Core/Event/Product/ProductCreateEvent.php | 1 - .../Core/Event/Product/ProductDeleteEvent.php | 1 - .../ShippingZone/ShippingZoneAddAreaEvent.php | 8 ++----- .../ShippingZoneRemoveAreaEvent.php | 3 +-- .../Thelia/Core/Event/Tax/TaxRuleEvent.php | 1 - core/lib/Thelia/Core/Event/TheliaEvents.php | 3 --- core/lib/Thelia/Core/Template/Loop/Area.php | 7 ++----- core/lib/Thelia/Core/Template/Loop/Folder.php | 2 +- .../Thelia/Core/Template/Loop/FolderPath.php | 4 +--- core/lib/Thelia/Core/Template/Loop/Tax.php | 6 +++--- .../Core/Template/Loop/TaxRuleCountry.php | 16 ++++++-------- .../Thelia/Core/Template/Loop/Template.php | 1 - .../Smarty/Plugins/DataAccessFunctions.php | 3 ++- .../Core/Template/Smarty/Plugins/Form.php | 6 +++--- core/lib/Thelia/Form/Area/AreaCountryForm.php | 3 +-- core/lib/Thelia/Form/Area/AreaCreateForm.php | 3 +-- .../Thelia/Form/Area/AreaModificationForm.php | 3 +-- core/lib/Thelia/Form/Area/AreaPostageForm.php | 3 +-- .../Thelia/Form/CountryModificationForm.php | 2 -- .../Form/ShippingZone/ShippingZoneAddArea.php | 3 +-- .../ShippingZone/ShippingZoneRemoveArea.php | 3 +-- core/lib/Thelia/Form/TaxRuleCreationForm.php | 2 -- .../Thelia/Form/TaxRuleTaxListUpdateForm.php | 12 +++++------ core/lib/Thelia/Module/BaseModule.php | 14 ++++++------- .../Exception/InvalidXmlDocumentException.php | 3 +-- .../Module/ModuleDescriptorValidator.php | 10 ++++----- core/lib/Thelia/Module/ModuleManagement.php | 21 ++++++++----------- core/lib/Thelia/Tests/Action/BaseAction.php | 3 +-- core/lib/Thelia/Tests/Action/ContentTest.php | 7 +++---- core/lib/Thelia/Tests/Action/FolderTest.php | 13 +++++------- .../Thelia/Tests/TaxEngine/CalculatorTest.php | 8 +++---- templates/admin/default/modules.html | 2 +- 70 files changed, 136 insertions(+), 244 deletions(-) diff --git a/core/lib/Thelia/Action/Area.php b/core/lib/Thelia/Action/Area.php index d9173ae93..92eb75634 100644 --- a/core/lib/Thelia/Action/Area.php +++ b/core/lib/Thelia/Action/Area.php @@ -34,7 +34,6 @@ use Thelia\Model\CountryQuery; use Thelia\Action\BaseAction; use Thelia\Model\Area as AreaModel; - /** * Class Area * @package Thelia\Action @@ -97,7 +96,6 @@ class Area extends BaseAction implements EventSubscriberInterface $event->setArea($area); } - /** * Returns an array of event names this subscriber wants to listen to. * @@ -128,4 +126,4 @@ class Area extends BaseAction implements EventSubscriberInterface TheliaEvents::AREA_CREATE => array('create', 128) ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Cache.php b/core/lib/Thelia/Action/Cache.php index 6d2cf1a16..4407c3e92 100644 --- a/core/lib/Thelia/Action/Cache.php +++ b/core/lib/Thelia/Action/Cache.php @@ -27,7 +27,6 @@ use Symfony\Component\Filesystem\Filesystem; use Thelia\Core\Event\Cache\CacheEvent; use Thelia\Core\Event\TheliaEvents; - /** * Class Cache * @package Thelia\Action @@ -42,7 +41,6 @@ class Cache extends BaseAction implements EventSubscriberInterface $directoryBrowser = new \DirectoryIterator($dir); - $fs = new Filesystem(); $fs->remove($dir); @@ -74,4 +72,4 @@ class Cache extends BaseAction implements EventSubscriberInterface TheliaEvents::CACHE_CLEAR => array('cacheClear', 128) ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Content.php b/core/lib/Thelia/Action/Content.php index 8560aa00e..3c027ad04 100644 --- a/core/lib/Thelia/Action/Content.php +++ b/core/lib/Thelia/Action/Content.php @@ -160,7 +160,7 @@ class Content extends BaseAction implements EventSubscriberInterface ->filterByFolderId($event->getFolderId()) ->findOne(); - if(null !== $contentFolder) { + if (null !== $contentFolder) { $contentFolder->delete(); } } diff --git a/core/lib/Thelia/Action/Country.php b/core/lib/Thelia/Action/Country.php index 69bf3c568..4c2d0839b 100644 --- a/core/lib/Thelia/Action/Country.php +++ b/core/lib/Thelia/Action/Country.php @@ -32,7 +32,6 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\Country as CountryModel; use Thelia\Model\CountryQuery; - /** * Class Country * @package Thelia\Action @@ -85,15 +84,13 @@ class Country extends BaseAction implements EventSubscriberInterface public function toggleDefault(CountryToggleDefaultEvent $event) { - if( null !== $country = CountryQuery::create()->findPk($event->getCountryId())) - { + if ( null !== $country = CountryQuery::create()->findPk($event->getCountryId())) { $country->toggleDefault(); $event->setCountry($country); } } - /** * Returns an array of event names this subscriber wants to listen to. * @@ -123,4 +120,4 @@ class Country extends BaseAction implements EventSubscriberInterface TheliaEvents::COUNTRY_TOGGLE_DEFAULT => array('toggleDefault', 128) ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 85643cb88..2e18872f6 100755 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -25,7 +25,6 @@ namespace Thelia\Action; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; -use Thelia\Core\Event\Customer\CustomerAddressEvent; use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\Customer\CustomerEvent; use Thelia\Core\Event\TheliaEvents; diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 5025c513f..213024e16 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -29,7 +29,6 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\ModuleQuery; use Thelia\Module\BaseModule; - /** * Class Module * @package Thelia\Action @@ -45,16 +44,16 @@ class Module extends BaseAction implements EventSubscriberInterface $moduleInstance = $moduleClass->newInstance(); - if( method_exists($moduleInstance, 'setContainer')) { + if ( method_exists($moduleInstance, 'setContainer')) { $moduleInstance->setContainer($this->container); - if($module->getActivate() == BaseModule::IS_ACTIVATED) { + if ($module->getActivate() == BaseModule::IS_ACTIVATED) { $moduleInstance->deActivate($module); } else { $moduleInstance->activate($module); } } - if($module->isModified()) { + if ($module->isModified()) { $event->setModule($module); } @@ -95,4 +94,4 @@ class Module extends BaseAction implements EventSubscriberInterface TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128) ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/Pdf.php b/core/lib/Thelia/Action/Pdf.php index 52ce0b92d..2bdad9366 100644 --- a/core/lib/Thelia/Action/Pdf.php +++ b/core/lib/Thelia/Action/Pdf.php @@ -26,7 +26,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\PdfEvent; use Thelia\Core\Event\TheliaEvents; - /** * Class Pdf * @package Thelia\Action @@ -72,4 +71,4 @@ class Pdf extends BaseAction implements EventSubscriberInterface TheliaEvents::GENERATE_PDF => array("generatePdf", 128) ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/ShippingZone.php b/core/lib/Thelia/Action/ShippingZone.php index 517a5ca25..c621efd8f 100644 --- a/core/lib/Thelia/Action/ShippingZone.php +++ b/core/lib/Thelia/Action/ShippingZone.php @@ -29,7 +29,6 @@ use Thelia\Core\Event\TheliaEvents; use Thelia\Model\AreaDeliveryModule; use Thelia\Model\AreaDeliveryModuleQuery; - /** * Class ShippingZone * @package Thelia\Action @@ -55,7 +54,7 @@ class ShippingZone extends BaseAction implements EventSubscriberInterface ->filterByDeliveryModuleId($event->getShoppingZoneId()) ->findOne(); - if($areaDelivery) { + if ($areaDelivery) { $areaDelivery->delete(); } else { throw new \RuntimeException(sprintf('areaDeliveryModule not found with area_id = %d and delivery_module_id = %d', $event->getAreaId(), $event->getShoppingZoneId())); @@ -89,4 +88,4 @@ class ShippingZone extends BaseAction implements EventSubscriberInterface TheliaEvents::SHIPPING_ZONE_REMOVE_AREA => array('removeArea', 128), ); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Action/TaxRule.php b/core/lib/Thelia/Action/TaxRule.php index 4b24f8cb9..f9f9fb412 100644 --- a/core/lib/Thelia/Action/TaxRule.php +++ b/core/lib/Thelia/Action/TaxRule.php @@ -68,8 +68,6 @@ class TaxRule extends BaseAction implements EventSubscriberInterface ->save() ; - - $event->setTaxRule($taxRule); } } @@ -90,12 +88,12 @@ class TaxRule extends BaseAction implements EventSubscriberInterface ->delete(); /* for each country */ - foreach($event->getCountryList() as $country) { + foreach ($event->getCountryList() as $country) { $position = 1; /* on applique les nouvelles regles */ - foreach($taxList as $tax) { - if(is_array($tax)) { - foreach($tax as $samePositionTax) { + foreach ($taxList as $tax) { + if (is_array($tax)) { + foreach ($tax as $samePositionTax) { $taxModel = new TaxRuleCountry(); $taxModel->setTaxRule($taxRule) ->setCountryId($country) diff --git a/core/lib/Thelia/Command/Install.php b/core/lib/Thelia/Command/Install.php index 6423d861a..7b6ca31c5 100755 --- a/core/lib/Thelia/Command/Install.php +++ b/core/lib/Thelia/Command/Install.php @@ -143,8 +143,8 @@ class Install extends ContainerAwareCommand $permissions = new CheckPermission(false, $this->getContainer()->get('thelia.translator')); $isValid = $permissions->exec(); - foreach($permissions->getValidationMessages() as $item => $data) { - if($data['status']) { + foreach ($permissions->getValidationMessages() as $item => $data) { + if ($data['status']) { $output->writeln(array( sprintf("%s ... %s", $data['text'], @@ -162,7 +162,7 @@ class Install extends ContainerAwareCommand } - if(false === $isValid) { + if (false === $isValid) { $output->writeln(array( "", "Please put correct permissions and reload install process" diff --git a/core/lib/Thelia/Command/ModuleActivateCommand.php b/core/lib/Thelia/Command/ModuleActivateCommand.php index d5ca8156d..1b8ac600f 100755 --- a/core/lib/Thelia/Command/ModuleActivateCommand.php +++ b/core/lib/Thelia/Command/ModuleActivateCommand.php @@ -26,7 +26,6 @@ namespace Thelia\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; -use Symfony\Component\Filesystem\Filesystem; use Thelia\Model\ModuleQuery; diff --git a/core/lib/Thelia/Command/Skeleton/Module/Class.php b/core/lib/Thelia/Command/Skeleton/Module/Class.php index c4c90aa60..c9c7109ac 100755 --- a/core/lib/Thelia/Command/Skeleton/Module/Class.php +++ b/core/lib/Thelia/Command/Skeleton/Module/Class.php @@ -25,7 +25,7 @@ namespace %%NAMESPACE%%; use Thelia\Module\BaseModule; -class %%CLASSNAME%% extends BaseModule +class Class extends BaseModule { /** * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class diff --git a/core/lib/Thelia/Controller/Admin/AddressController.php b/core/lib/Thelia/Controller/Admin/AddressController.php index 38ec9cb6b..859fb8dc6 100644 --- a/core/lib/Thelia/Controller/Admin/AddressController.php +++ b/core/lib/Thelia/Controller/Admin/AddressController.php @@ -24,14 +24,12 @@ namespace Thelia\Controller\Admin; use Thelia\Core\Event\Address\AddressCreateOrUpdateEvent; use Thelia\Core\Event\Address\AddressEvent; -use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\AddressCreateForm; use Thelia\Form\AddressUpdateForm; use Thelia\Model\AddressQuery; use Thelia\Model\CustomerQuery; - /** * Class AddressController * @package Thelia\Controller\Admin @@ -78,7 +76,7 @@ class AddressController extends AbstractCrudController $this->dispatch(TheliaEvents::ADDRESS_DEFAULT, $addressEvent); $this->adminLogAppend(sprintf("address %d for customer %d removal", $address_id, $address->getCustomerId())); - } catch(\Exception $e) { + } catch (\Exception $e) { \Thelia\Log\Tlog::getInstance()->error(sprintf("error during address removal with message %s", $e->getMessage())); } @@ -176,8 +174,6 @@ class AddressController extends AbstractCrudController $formData["is_default"] ); - - return $event; } @@ -279,8 +275,8 @@ class AddressController extends AbstractCrudController /** * Put in this method post object delete processing if required. * - * @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event - * @return Response a response, or null to continue normal processing + * @param \Thelia\Core\Event\AddressEvent $deleteEvent the delete event + * @return Response a response, or null to continue normal processing */ protected function performAdditionalDeleteAction($deleteEvent) { @@ -291,8 +287,8 @@ class AddressController extends AbstractCrudController /** * Put in this method post object creation processing if required. * - * @param AddressCreateOrUpdateEvent $createEvent the create event - * @return Response a response, or null to continue normal processing + * @param AddressCreateOrUpdateEvent $createEvent the create event + * @return Response a response, or null to continue normal processing */ protected function performAdditionalCreateAction($createEvent) { @@ -303,4 +299,4 @@ class AddressController extends AbstractCrudController { $this->redirectToEditionTemplate(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 9adb7a19a..829e51c37 100755 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -378,8 +378,8 @@ class BaseAdminController extends BaseController * Render the given template, and returns the result as a string. * * @param $templateName the complete template name, with extension - * @param array $args the template arguments - * @param null $templateDir + * @param array $args the template arguments + * @param null $templateDir * * @return \Symfony\Component\HttpFoundation\Response */ diff --git a/core/lib/Thelia/Controller/Admin/CountryController.php b/core/lib/Thelia/Controller/Admin/CountryController.php index 91160311f..a19a19212 100644 --- a/core/lib/Thelia/Controller/Admin/CountryController.php +++ b/core/lib/Thelia/Controller/Admin/CountryController.php @@ -243,7 +243,7 @@ class CountryController extends AbstractCrudController try { $this->dispatch(TheliaEvents::COUNTRY_TOGGLE_DEFAULT, $toogleDefaultEvent); - if($toogleDefaultEvent->hasCountry()) { + if ($toogleDefaultEvent->hasCountry()) { return $this->nullResponse(); } } catch (\Exception $ex) { diff --git a/core/lib/Thelia/Controller/Admin/CustomerController.php b/core/lib/Thelia/Controller/Admin/CustomerController.php index e4d24e9ad..c5ebc9a39 100644 --- a/core/lib/Thelia/Controller/Admin/CustomerController.php +++ b/core/lib/Thelia/Controller/Admin/CustomerController.php @@ -25,14 +25,11 @@ namespace Thelia\Controller\Admin; use Propel\Runtime\Exception\PropelException; use Symfony\Component\Form\Form; -use Thelia\Core\Event\Address\AddressEvent; -use Thelia\Core\Event\Customer\CustomerAddressEvent; use Thelia\Core\Event\Customer\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\Customer\CustomerEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Form\CustomerModification; use Thelia\Form\Exception\FormValidationException; -use Thelia\Model\AddressQuery; use Thelia\Model\CustomerQuery; use Thelia\Core\Translation\Translator; @@ -57,8 +54,6 @@ class CustomerController extends BaseAdminController )); } - - /** * update customer action * diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index 4a22c868a..c7d020d58 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -59,7 +59,7 @@ class ModuleController extends BaseAdminController $event = new ModuleToggleActivationEvent($module_id); $this->dispatch(TheliaEvents::MODULE_TOGGLE_ACTIVATION, $event); - if(null === $event->getModule()) { + if (null === $event->getModule()) { throw new \LogicException( $this->getTranslator()->trans("No %obj was updated.", array('%obj' => 'Module'))); } @@ -67,9 +67,8 @@ class ModuleController extends BaseAdminController $message = $e->getMessage(); } - - if($this->getRequest()->isXmlHttpRequest()) { - if($message) { + if ($this->getRequest()->isXmlHttpRequest()) { + if ($message) { $response = $this->jsonResponse(json_encode(array( "error" => $message )), 500); diff --git a/core/lib/Thelia/Controller/Admin/OrderController.php b/core/lib/Thelia/Controller/Admin/OrderController.php index 1df0679f0..4524e16ac 100644 --- a/core/lib/Thelia/Controller/Admin/OrderController.php +++ b/core/lib/Thelia/Controller/Admin/OrderController.php @@ -211,7 +211,6 @@ class OrderController extends BaseAdminController { if (null !== $response = $this->checkAuth("admin.order.update")) return $response; - $html = $this->renderRaw( $fileName, array( @@ -227,7 +226,7 @@ class OrderController extends BaseAdminController $this->dispatch(TheliaEvents::GENERATE_PDF, $pdfEvent); - if($pdfEvent->hasPdf()) { + if ($pdfEvent->hasPdf()) { return Response::create($pdfEvent->getPdf(), 200, array( 'Content-type' => "application/pdf", diff --git a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php index d68de4808..b53b0a911 100644 --- a/core/lib/Thelia/Controller/Admin/ShippingZoneController.php +++ b/core/lib/Thelia/Controller/Admin/ShippingZoneController.php @@ -140,5 +140,4 @@ class ShippingZoneController extends BaseAdminController return $this->getRequest()->get('shipping_zone_id', 0); } - } diff --git a/core/lib/Thelia/Controller/Admin/TaxRuleController.php b/core/lib/Thelia/Controller/Admin/TaxRuleController.php index b0ceba67e..cfa5af1ff 100644 --- a/core/lib/Thelia/Controller/Admin/TaxRuleController.php +++ b/core/lib/Thelia/Controller/Admin/TaxRuleController.php @@ -199,8 +199,8 @@ class TaxRuleController extends AbstractCrudController /** * Put in this method post object creation processing if required. * - * @param TaxRuleEvent $createEvent the create event - * @return Response a response, or null to continue normal processing + * @param TaxRuleEvent $createEvent the create event + * @return Response a response, or null to continue normal processing */ protected function performAdditionalCreateAction($createEvent) { @@ -284,4 +284,4 @@ class TaxRuleController extends AbstractCrudController // At this point, the form has errors, and should be redisplayed. return $this->renderEditionTemplate(); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php b/core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php index b6af3c5b3..5c98c071c 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaAddCountryEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Area; - /** * Class AreaAddCountryEvent * @package Thelia\Core\Event\Area @@ -34,7 +33,7 @@ class AreaAddCountryEvent extends AreaEvent protected $area_id; protected $country_id; - function __construct($area_id, $country_id) + public function __construct($area_id, $country_id) { $this->area_id = $area_id; $this->country_id = $country_id; @@ -80,7 +79,4 @@ class AreaAddCountryEvent extends AreaEvent return $this->country_id; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php b/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php index d63afa5b9..32dc7a6c8 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaCreateEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Area; - /** * Class AreaCreateEvent * @package Thelia\Core\Event\Area @@ -49,5 +48,4 @@ class AreaCreateEvent extends AreaEvent return $this->name; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php b/core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php index 86f936140..2a83c98a4 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaDeleteEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Area; - /** * Class AreaDeleteEvent * @package Thelia\Core\Event\Area @@ -61,5 +60,4 @@ class AreaDeleteEvent extends AreaEvent return $this->area_id; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Area/AreaEvent.php b/core/lib/Thelia/Core/Event/Area/AreaEvent.php index 892d00843..9e0c2dc00 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaEvent.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Event\Area; use Thelia\Core\Event\ActionEvent; - /** * Class AreaEvent * @package Thelia\Core\Event\Shipping @@ -63,4 +62,4 @@ class AreaEvent extends ActionEvent { return null !== $this->area; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php b/core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php index 84c8f10d2..92cfd57d3 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaRemoveCountryEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Area; - /** * Class AreaRemoveCountryEvent * @package Thelia\Core\Event\Area @@ -32,4 +31,4 @@ namespace Thelia\Core\Event\Area; class AreaRemoveCountryEvent extends AreaAddCountryEvent { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.php b/core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.php index f5f7c8704..361607f42 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaUpdateEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Area; - /** * Class AreaUpdateEvent * @package Thelia\Core\Event\Area @@ -32,4 +31,4 @@ namespace Thelia\Core\Event\Area; class AreaUpdateEvent extends AreaCreateEvent { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.php b/core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.php index 5f799b93c..b9cb825c4 100644 --- a/core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.php +++ b/core/lib/Thelia/Core/Event/Area/AreaUpdatePostageEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Area; - /** * Class AreaUpdatePostageEvent * @package Thelia\Core\Event\Area @@ -34,7 +33,7 @@ class AreaUpdatePostageEvent extends AreaEvent protected $area_id; protected $postage; - function __construct($area_id) + public function __construct($area_id) { $this->area_id = $area_id; } @@ -79,7 +78,4 @@ class AreaUpdatePostageEvent extends AreaEvent return $this->postage; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Cache/CacheEvent.php b/core/lib/Thelia/Core/Event/Cache/CacheEvent.php index 3a882d5dd..7b21db53d 100644 --- a/core/lib/Thelia/Core/Event/Cache/CacheEvent.php +++ b/core/lib/Thelia/Core/Event/Cache/CacheEvent.php @@ -25,7 +25,6 @@ namespace Thelia\Core\Event\Cache; use Thelia\Core\Event\ActionEvent; - /** * Class CacheEvent * @package Thelia\Core\Event\Cache @@ -63,5 +62,4 @@ class CacheEvent extends ActionEvent return $this->dir; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php b/core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php index a1d1d44e1..dac4317ba 100644 --- a/core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php +++ b/core/lib/Thelia/Core/Event/Content/ContentAddFolderEvent.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Event\Content; use Thelia\Model\Content; - /** * Class ContentAddFolderEvent * @package Thelia\Core\Event\Content @@ -61,6 +60,4 @@ class ContentAddFolderEvent extends ContentEvent return $this->folderId; } - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Content/ContentRemoveFolderEvent.php b/core/lib/Thelia/Core/Event/Content/ContentRemoveFolderEvent.php index 195f4f3b0..1733ec893 100644 --- a/core/lib/Thelia/Core/Event/Content/ContentRemoveFolderEvent.php +++ b/core/lib/Thelia/Core/Event/Content/ContentRemoveFolderEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Content; - /** * Class ContentRemoveFolderEvent * @package Thelia\Core\Event\Content @@ -31,4 +30,4 @@ namespace Thelia\Core\Event\Content; */ class ContentRemoveFolderEvent extends ContentAddFolderEvent { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php b/core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php index 48e8469a4..92d6632ae 100644 --- a/core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Country/CountryCreateEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Country; - /** * Class CountryCreateEvent * @package Thelia\Core\Event\Country @@ -150,5 +149,4 @@ class CountryCreateEvent extends CountryEvent return $this->area; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php b/core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php index 4a7d9c400..5d658ebc0 100644 --- a/core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Country/CountryDeleteEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Country; - /** * Class CountryDeleteEvent * @package Thelia\Core\Event\Country @@ -36,7 +35,7 @@ class CountryDeleteEvent extends CountryEvent */ protected $country_id; - function __construct($country_id) + public function __construct($country_id) { $this->country_id = $country_id; } @@ -57,4 +56,4 @@ class CountryDeleteEvent extends CountryEvent return $this->country_id; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Country/CountryEvent.php b/core/lib/Thelia/Core/Event/Country/CountryEvent.php index 962d880fa..505ead8ec 100644 --- a/core/lib/Thelia/Core/Event/Country/CountryEvent.php +++ b/core/lib/Thelia/Core/Event/Country/CountryEvent.php @@ -25,7 +25,6 @@ namespace Thelia\Core\Event\Country; use Thelia\Core\Event\ActionEvent; use Thelia\Model\Country; - /** * Class CountryEvent * @package Thelia\Core\Event\Country @@ -38,7 +37,7 @@ class CountryEvent extends ActionEvent */ protected $country; - function __construct(Country $country = null) + public function __construct(Country $country = null) { $this->country = $country; } @@ -69,5 +68,4 @@ class CountryEvent extends ActionEvent return null !== $this->country; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Country/CountryToggleDefaultEvent.php b/core/lib/Thelia/Core/Event/Country/CountryToggleDefaultEvent.php index 8f8142d0d..a414c70e8 100644 --- a/core/lib/Thelia/Core/Event/Country/CountryToggleDefaultEvent.php +++ b/core/lib/Thelia/Core/Event/Country/CountryToggleDefaultEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Country; - /** * Class CountryToggleDefaultEvent * @package Thelia\Core\Event\Country @@ -33,7 +32,7 @@ class CountryToggleDefaultEvent extends CountryEvent { protected $country_id; - function __construct($country_id) + public function __construct($country_id) { $this->country_id = $country_id; } @@ -45,4 +44,4 @@ class CountryToggleDefaultEvent extends CountryEvent { return $this->country_id; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php b/core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php index 496904172..2f82b17d0 100644 --- a/core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php +++ b/core/lib/Thelia/Core/Event/Country/CountryUpdateEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Country; - /** * Class CountryUpdateEvent * @package Thelia\Core\Event\Country @@ -37,7 +36,7 @@ class CountryUpdateEvent extends CountryCreateEvent protected $description; protected $postscriptum; - function __construct($country_id) + public function __construct($country_id) { $this->country_id = $country_id; } @@ -114,7 +113,4 @@ class CountryUpdateEvent extends CountryCreateEvent return $this->country_id; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Module/ModuleEvent.php b/core/lib/Thelia/Core/Event/Module/ModuleEvent.php index e9cf2623e..c37b2b995 100644 --- a/core/lib/Thelia/Core/Event/Module/ModuleEvent.php +++ b/core/lib/Thelia/Core/Event/Module/ModuleEvent.php @@ -25,7 +25,6 @@ namespace Thelia\Core\Event\Module; use Thelia\Core\Event\ActionEvent; use Thelia\Model\Module; - /** * Class ModuleEvent * @package Thelia\Core\Event\Module @@ -38,7 +37,7 @@ class ModuleEvent extends ActionEvent */ protected $module; - function __construct(Module $module = null) + public function __construct(Module $module = null) { $this->module = $module; } @@ -63,7 +62,4 @@ class ModuleEvent extends ActionEvent return $this->module; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php b/core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php index dd517d8ff..c6ece16f4 100644 --- a/core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php +++ b/core/lib/Thelia/Core/Event/Module/ModuleToggleActivationEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Module; - /** * Class ModuleToggleActivationEvent * @package Thelia\Core\Event\Module @@ -36,7 +35,7 @@ class ModuleToggleActivationEvent extends ModuleEvent */ protected $module_id; - function __construct($module_id) + public function __construct($module_id) { $this->module_id = $module_id; } @@ -61,7 +60,4 @@ class ModuleToggleActivationEvent extends ModuleEvent return $this->module_id; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/PdfEvent.php b/core/lib/Thelia/Core/Event/PdfEvent.php index e0f873e04..b439c8a23 100644 --- a/core/lib/Thelia/Core/Event/PdfEvent.php +++ b/core/lib/Thelia/Core/Event/PdfEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event; - /** * Class PdfEvent * @package Thelia\Core\Event @@ -44,12 +43,12 @@ class PdfEvent extends ActionEvent /** * @param $content html content to transform into pdf - * @param string $orientation page orientation, same as TCPDF - * @param string $format The format used for pages, same as TCPDF - * @param string $lang Lang : fr, en, it... - * @param bool $unicode TRUE means that the input text is unicode (default = true) - * @param string $encoding charset encoding; default is UTF-8 - * @param array $marges Default marges (left, top, right, bottom) + * @param string $orientation page orientation, same as TCPDF + * @param string $format The format used for pages, same as TCPDF + * @param string $lang Lang : fr, en, it... + * @param bool $unicode TRUE means that the input text is unicode (default = true) + * @param string $encoding charset encoding; default is UTF-8 + * @param array $marges Default marges (left, top, right, bottom) */ public function __construct($content, $orientation = 'P', $format = 'A4', $lang='fr', $unicode=true, $encoding='UTF-8',array $marges = array(0, 0, 0, 0)) { @@ -189,5 +188,4 @@ class PdfEvent extends ActionEvent return $this->unicode; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Product/ProductCreateEvent.php b/core/lib/Thelia/Core/Event/Product/ProductCreateEvent.php index a9f6bbea1..9717f171d 100644 --- a/core/lib/Thelia/Core/Event/Product/ProductCreateEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductCreateEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Product; - class ProductCreateEvent extends ProductEvent { protected $ref; diff --git a/core/lib/Thelia/Core/Event/Product/ProductDeleteEvent.php b/core/lib/Thelia/Core/Event/Product/ProductDeleteEvent.php index 108ceb781..7a3406e7e 100644 --- a/core/lib/Thelia/Core/Event/Product/ProductDeleteEvent.php +++ b/core/lib/Thelia/Core/Event/Product/ProductDeleteEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\Product; - class ProductDeleteEvent extends ProductEvent { public function __construct($product_id) diff --git a/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneAddAreaEvent.php b/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneAddAreaEvent.php index d1e406646..35f3dcac1 100644 --- a/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneAddAreaEvent.php +++ b/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneAddAreaEvent.php @@ -24,7 +24,6 @@ namespace Thelia\Core\Event\ShippingZone; use Thelia\Core\Event\ActionEvent; - /** * Class ShippingZoneAddAreaEvent * @package Thelia\Core\Event\ShippingZone @@ -35,7 +34,7 @@ class ShippingZoneAddAreaEvent extends ActionEvent protected $area_id; protected $shopping_zone_id; - function __construct($area_id, $shopping_zone_id) + public function __construct($area_id, $shopping_zone_id) { $this->area_id = $area_id; $this->shopping_zone_id = $shopping_zone_id; @@ -81,7 +80,4 @@ class ShippingZoneAddAreaEvent extends ActionEvent return $this->shopping_zone_id; } - - - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneRemoveAreaEvent.php b/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneRemoveAreaEvent.php index 6dc6094d6..a3177f522 100644 --- a/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneRemoveAreaEvent.php +++ b/core/lib/Thelia/Core/Event/ShippingZone/ShippingZoneRemoveAreaEvent.php @@ -23,7 +23,6 @@ namespace Thelia\Core\Event\ShippingZone; - /** * Class ShippingZoneRemoveAreaEvent * @package Thelia\Core\Event\ShippingZone @@ -32,4 +31,4 @@ namespace Thelia\Core\Event\ShippingZone; class ShippingZoneRemoveAreaEvent extends ShippingZoneAddAreaEvent { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Tax/TaxRuleEvent.php b/core/lib/Thelia/Core/Event/Tax/TaxRuleEvent.php index e364bfd84..6d3f21e6e 100644 --- a/core/lib/Thelia/Core/Event/Tax/TaxRuleEvent.php +++ b/core/lib/Thelia/Core/Event/Tax/TaxRuleEvent.php @@ -118,5 +118,4 @@ class TaxRuleEvent extends ActionEvent return $this->taxList; } - } diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index f70eca2a1..860b63e27 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -183,7 +183,6 @@ final class TheliaEvents const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility"; const FOLDER_UPDATE_POSITION = "action.updateFolderPosition"; - const BEFORE_CREATEFOLDER = "action.before_createFolder"; const AFTER_CREATEFOLDER = "action.after_createFolder"; @@ -204,7 +203,6 @@ final class TheliaEvents const CONTENT_ADD_FOLDER = "action.contentAddFolder"; const CONTENT_REMOVE_FOLDER = "action.contentRemoveFolder"; - const BEFORE_CREATECONTENT = "action.before_createContent"; const AFTER_CREATECONTENT = "action.after_createContent"; @@ -222,7 +220,6 @@ final class TheliaEvents const COUNTRY_TOGGLE_DEFAULT = "action.toggleCountryDefault"; //const COUNTRY_UPDATE_POSITION = "action.updateFolderPosition"; - const BEFORE_CREATECOUNTRY = "action.before_createCountry"; const AFTER_CREATECOUNTRY = "action.after_createCountry"; diff --git a/core/lib/Thelia/Core/Template/Loop/Area.php b/core/lib/Thelia/Core/Template/Loop/Area.php index 4d43f524b..524777d08 100644 --- a/core/lib/Thelia/Core/Template/Loop/Area.php +++ b/core/lib/Thelia/Core/Template/Loop/Area.php @@ -30,7 +30,6 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\AreaQuery; - /** * Class Area * @package Thelia\Core\Template\Loop @@ -112,8 +111,7 @@ class Area extends BaseLoop $withoutZone = $this->getWithout_zone(); - if($withoutZone) - { + if ($withoutZone) { $search->joinAreaDeliveryModule('without_zone', Criteria::LEFT_JOIN) ->addJoinCondition('without_zone', 'delivery_module_id '.Criteria::EQUAL.' ?', $withoutZone, null, \PDO::PARAM_INT) ->where('`without_zone`.delivery_module_id '.Criteria::ISNULL); @@ -140,5 +138,4 @@ class Area extends BaseLoop return $loopResult; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Folder.php b/core/lib/Thelia/Core/Template/Loop/Folder.php index 04ba737fa..efc45030f 100755 --- a/core/lib/Thelia/Core/Template/Loop/Folder.php +++ b/core/lib/Thelia/Core/Template/Loop/Folder.php @@ -114,7 +114,7 @@ class Folder extends BaseI18nLoop if (null !== $content) { $obj = ContentQuery::create()->findPk($content); - if($obj) { + if ($obj) { $search->filterByContent($obj, Criteria::IN); } } diff --git a/core/lib/Thelia/Core/Template/Loop/FolderPath.php b/core/lib/Thelia/Core/Template/Loop/FolderPath.php index 272b9fbbb..2b9a52b0d 100644 --- a/core/lib/Thelia/Core/Template/Loop/FolderPath.php +++ b/core/lib/Thelia/Core/Template/Loop/FolderPath.php @@ -30,7 +30,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Model\FolderQuery; use Thelia\Type\BooleanOrBothType; - /** * Class FolderPath * @package Thelia\Core\Template\Loop @@ -156,5 +155,4 @@ class FolderPath extends BaseI18nLoop return $loopResult; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Template/Loop/Tax.php b/core/lib/Thelia/Core/Template/Loop/Tax.php index 1ddf18824..18fb5e0dc 100644 --- a/core/lib/Thelia/Core/Template/Loop/Tax.php +++ b/core/lib/Thelia/Core/Template/Loop/Tax.php @@ -97,7 +97,7 @@ class Tax extends BaseI18nLoop $country = $this->getCountry(); $taxRule = $this->getTax_rule(); - if(null !== $taxRule && null !== $country) { + if (null !== $taxRule && null !== $country) { $search->filterByTaxRuleCountry( TaxRuleCountryQuery::create() ->filterByCountryId($country, Criteria::EQUAL) @@ -108,7 +108,7 @@ class Tax extends BaseI18nLoop } $excludeTaxRule = $this->getExclude_tax_rule(); - if(null !== $excludeTaxRule && null !== $country) { + if (null !== $excludeTaxRule && null !== $country) { $excludedTaxes = TaxRuleCountryQuery::create() ->filterByCountryId($country, Criteria::EQUAL) ->filterByTaxRuleId($excludeTaxRule, Criteria::IN) @@ -118,7 +118,7 @@ class Tax extends BaseI18nLoop $excludedTaxes, Criteria::NOT_IN );*/ - foreach($excludedTaxes as $excludedTax) { + foreach ($excludedTaxes as $excludedTax) { $search->filterByTaxRuleCountry($excludedTax, Criteria::NOT_EQUAL); } } diff --git a/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php b/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php index 91616f398..c4c165192 100644 --- a/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php +++ b/core/lib/Thelia/Core/Template/Loop/TaxRuleCountry.php @@ -35,8 +35,6 @@ use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\Map\CountryTableMap; use Thelia\Model\Map\TaxRuleCountryTableMap; use Thelia\Model\Map\TaxTableMap; -use Thelia\Type\TypeCollection; -use Thelia\Type; use Thelia\Model\TaxRuleCountryQuery; /** @@ -76,15 +74,15 @@ class TaxRuleCountry extends BaseI18nLoop $country = $this->getCountry(); $taxes = $this->getTaxes(); - if((null === $country && null === $taxes)) { + if ((null === $country && null === $taxes)) { throw new \InvalidArgumentException('You must provide either `country` or `taxes` parameter in tax-rule-country loop'); } - if((null === $country && null !== $taxes)) { + if ((null === $country && null !== $taxes)) { throw new \InvalidArgumentException('You must provide `country` parameter with `taxes` parameter in tax-rule-country loop'); } - if(null !== $taxes) { + if (null !== $taxes) { $search->groupByCountryId(); $originalCountryJoin = new Join(); @@ -106,7 +104,7 @@ class TaxRuleCountry extends BaseI18nLoop CountryTableMap::TABLE_NAME, 'COUNTRY_ID' ); - } elseif(null !== $country) { + } elseif (null !== $country) { $search->filterByCountryId($country); /* manage tax translation */ @@ -132,7 +130,7 @@ class TaxRuleCountry extends BaseI18nLoop $loopResultRow = new LoopResultRow($loopResult, $taxRuleCountry, $this->versionable, $this->timestampable, $this->countable); - if(null !== $taxes) { + if (null !== $taxes) { $loopResultRow ->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId()) ->set("COUNTRY" , $taxRuleCountry->getCountryId()) @@ -141,7 +139,7 @@ class TaxRuleCountry extends BaseI18nLoop ->set("COUNTRY_DESCRIPTION" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_DESCRIPTION')) ->set("COUNTRY_POSTSCRIPTUM" , $taxRuleCountry->getVirtualColumn(CountryTableMap::TABLE_NAME . '_i18n_POSTSCRIPTUM')) ; - }elseif(null !== $country) { + } elseif (null !== $country) { $loopResultRow ->set("TAX_RULE" , $taxRuleCountry->getTaxRuleId()) ->set("COUNTRY" , $taxRuleCountry->getCountryId()) @@ -152,8 +150,6 @@ class TaxRuleCountry extends BaseI18nLoop ; } - - $loopResult->addRow($loopResultRow); } diff --git a/core/lib/Thelia/Core/Template/Loop/Template.php b/core/lib/Thelia/Core/Template/Loop/Template.php index 9eaa3ea4f..83ef4fabe 100644 --- a/core/lib/Thelia/Core/Template/Loop/Template.php +++ b/core/lib/Thelia/Core/Template/Loop/Template.php @@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Model\Base\TemplateQuery; -use Thelia\Type; /** * diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php index 594b45ae9..a401755a4 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/DataAccessFunctions.php @@ -172,6 +172,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin self::$dataAccessCache['defaultCountry'] = $defaultCountry; }*/ $defaultCountry = CountryQuery::create()->filterByByDefault(1)->limit(1); + return $this->dataAccessWithI18n("defaultCountry", $params, $defaultCountry); } } @@ -237,7 +238,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin public function ConfigDataAccess($params, $smarty) { - if(false === array_key_exists("key", $params)) { + if (false === array_key_exists("key", $params)) { return null; } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php index 37be09824..b86f160dc 100755 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Form.php @@ -152,7 +152,7 @@ class Form extends AbstractSmartyPlugin $template->assign("options", $formFieldView->vars); /* access to choices */ - if(isset($formFieldView->vars['choices'])) { + if (isset($formFieldView->vars['choices'])) { $template->assign("choices", $formFieldView->vars['choices']); } @@ -199,8 +199,8 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar foreach ($formView->getIterator() as $row) { if ($this->isHidden($row) && $row->isRendered() === false) { $attributeList = array(); - if(isset($row->vars["attr"])) { - foreach($row->vars["attr"] as $attrKey => $attrValue) { + if (isset($row->vars["attr"])) { + foreach ($row->vars["attr"] as $attrKey => $attrValue) { $attributeList[] = sprintf($attrFormat, $attrKey, $attrValue); } } diff --git a/core/lib/Thelia/Form/Area/AreaCountryForm.php b/core/lib/Thelia/Form/Area/AreaCountryForm.php index c511e0b3c..b3f09ae06 100644 --- a/core/lib/Thelia/Form/Area/AreaCountryForm.php +++ b/core/lib/Thelia/Form/Area/AreaCountryForm.php @@ -28,7 +28,6 @@ use Symfony\Component\Validator\Constraints\GreaterThan; use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Form\BaseForm; - /** * Class AreaCountryForm * @package Thelia\Form\Area @@ -86,4 +85,4 @@ class AreaCountryForm extends BaseForm { return 'thelia_area_country'; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/Area/AreaCreateForm.php b/core/lib/Thelia/Form/Area/AreaCreateForm.php index 590001867..79fc4b2a2 100644 --- a/core/lib/Thelia/Form/Area/AreaCreateForm.php +++ b/core/lib/Thelia/Form/Area/AreaCreateForm.php @@ -26,7 +26,6 @@ use Thelia\Core\Translation\Translator; use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Form\BaseForm; - /** * Class AreaCreateForm * @package Thelia\Form\Shipping @@ -76,4 +75,4 @@ class AreaCreateForm extends BaseForm { return 'thelia_area_creation'; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/Area/AreaModificationForm.php b/core/lib/Thelia/Form/Area/AreaModificationForm.php index eefcb825a..03f4b2e46 100644 --- a/core/lib/Thelia/Form/Area/AreaModificationForm.php +++ b/core/lib/Thelia/Form/Area/AreaModificationForm.php @@ -25,7 +25,6 @@ namespace Thelia\Form\Area; use Symfony\Component\Validator\Constraints\GreaterThan; use Thelia\Form\Area\AreaCreateForm; - /** * Class AreaModificationForm * @package Thelia\Form\Shipping @@ -46,4 +45,4 @@ class AreaModificationForm extends AreaCreateForm { return 'thelia_area_modification'; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/Area/AreaPostageForm.php b/core/lib/Thelia/Form/Area/AreaPostageForm.php index ba24499e8..fa22ab908 100644 --- a/core/lib/Thelia/Form/Area/AreaPostageForm.php +++ b/core/lib/Thelia/Form/Area/AreaPostageForm.php @@ -29,7 +29,6 @@ use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Form\BaseForm; use Thelia\Core\Translation\Translator; - /** * Class AreaPostageForm * @package Thelia\Form\Area @@ -85,4 +84,4 @@ class AreaPostageForm extends BaseForm { return 'thelia_area_postage'; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/CountryModificationForm.php b/core/lib/Thelia/Form/CountryModificationForm.php index 68570425b..99c404e62 100644 --- a/core/lib/Thelia/Form/CountryModificationForm.php +++ b/core/lib/Thelia/Form/CountryModificationForm.php @@ -23,8 +23,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints\GreaterThan; -use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Core\Translation\Translator; class CountryModificationForm extends CountryCreationForm { diff --git a/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php b/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php index 81dd422b6..ea31b696b 100644 --- a/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php +++ b/core/lib/Thelia/Form/ShippingZone/ShippingZoneAddArea.php @@ -28,7 +28,6 @@ use Symfony\Component\Validator\Constraints\GreaterThan; use Symfony\Component\Validator\Constraints\NotBlank; use Thelia\Form\BaseForm; - /** * Class ShippingZoneAddArea * @package Thelia\Form\ShippingZone @@ -84,4 +83,4 @@ class ShippingZoneAddArea extends BaseForm { return 'thelia_shippingzone_area'; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/ShippingZone/ShippingZoneRemoveArea.php b/core/lib/Thelia/Form/ShippingZone/ShippingZoneRemoveArea.php index 5c4e5597b..dfa568334 100644 --- a/core/lib/Thelia/Form/ShippingZone/ShippingZoneRemoveArea.php +++ b/core/lib/Thelia/Form/ShippingZone/ShippingZoneRemoveArea.php @@ -23,7 +23,6 @@ namespace Thelia\Form\ShippingZone; - /** * Class ShippingZoneRemoveArea * @package Thelia\Form\ShippingZone @@ -39,4 +38,4 @@ class ShippingZoneRemoveArea extends ShippingZoneAddArea { return 'thelia_shippingzone_remove_area'; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Form/TaxRuleCreationForm.php b/core/lib/Thelia/Form/TaxRuleCreationForm.php index be3556321..a5dcc1999 100644 --- a/core/lib/Thelia/Form/TaxRuleCreationForm.php +++ b/core/lib/Thelia/Form/TaxRuleCreationForm.php @@ -24,8 +24,6 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraints\NotBlank; -use Thelia\Core\Translation\Translator; -use Thelia\Model\CountryQuery; class TaxRuleCreationForm extends BaseForm { diff --git a/core/lib/Thelia/Form/TaxRuleTaxListUpdateForm.php b/core/lib/Thelia/Form/TaxRuleTaxListUpdateForm.php index 1d96c7e4d..ea2d1f06b 100644 --- a/core/lib/Thelia/Form/TaxRuleTaxListUpdateForm.php +++ b/core/lib/Thelia/Form/TaxRuleTaxListUpdateForm.php @@ -34,7 +34,7 @@ class TaxRuleTaxListUpdateForm extends BaseForm protected function buildForm() { $countryList = array(); - foreach(CountryQuery::create()->find() as $country) { + foreach (CountryQuery::create()->find() as $country) { $countryList[$country->getId()] = $country->getId(); } @@ -96,7 +96,7 @@ class TaxRuleTaxListUpdateForm extends BaseForm public function verifyTaxList($value, ExecutionContextInterface $context) { $jsonType = new JsonType(); - if(!$jsonType->isValid($value)) { + if (!$jsonType->isValid($value)) { $context->addViolation("Tax list is not valid JSON"); } @@ -104,10 +104,10 @@ class TaxRuleTaxListUpdateForm extends BaseForm /* check we have 2 level max */ - foreach($taxList as $taxLevel1) { - if(is_array($taxLevel1)) { - foreach($taxLevel1 as $taxLevel2) { - if(is_array($taxLevel2)) { + foreach ($taxList as $taxLevel1) { + if (is_array($taxLevel1)) { + foreach ($taxLevel1 as $taxLevel2) { + if (is_array($taxLevel2)) { $context->addViolation("Bad tax list JSON"); } else { $taxModel = TaxQuery::create()->findPk($taxLevel2); diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 6cfc79d28..83636b921 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -53,10 +53,9 @@ abstract class BaseModule extends ContainerAware } - public function activate($moduleModel = null) { - if(null === $moduleModel) { + if (null === $moduleModel) { $moduleModel = $this->getModuleModel(); } @@ -64,7 +63,7 @@ abstract class BaseModule extends ContainerAware $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME); $con->beginTransaction(); try { - if($this->preActivation($con)) { + if ($this->preActivation($con)) { $moduleModel->setActivate(self::IS_ACTIVATED); $moduleModel->save($con); $this->postActivation($con); @@ -79,14 +78,14 @@ abstract class BaseModule extends ContainerAware public function deActivate($moduleModel = null) { - if(null === $moduleModel) { + if (null === $moduleModel) { $moduleModel = $this->getModuleModel(); } if ($moduleModel->getActivate() == self::IS_ACTIVATED) { $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME); $con->beginTransaction(); try { - if($this->preDeactivation($con)) { + if ($this->preDeactivation($con)) { $moduleModel->setActivate(self::IS_NOT_ACTIVATED); $moduleModel->save($con); $this->postDeactivation($con); @@ -215,7 +214,6 @@ abstract class BaseModule extends ContainerAware return $moduleModel; } - public function getCode() { if (null === $this->reflected) { @@ -225,8 +223,8 @@ abstract class BaseModule extends ContainerAware return basename(dirname($this->reflected->getFileName())); } - public function install(){ - + public function install() + { } public function preActivation(ConnectionInterface $con = null) diff --git a/core/lib/Thelia/Module/Exception/InvalidXmlDocumentException.php b/core/lib/Thelia/Module/Exception/InvalidXmlDocumentException.php index 2d679cfd0..49a7d5a68 100644 --- a/core/lib/Thelia/Module/Exception/InvalidXmlDocumentException.php +++ b/core/lib/Thelia/Module/Exception/InvalidXmlDocumentException.php @@ -23,7 +23,6 @@ namespace Thelia\Module\Exception; - /** * Class InvalidXmlDocumentException * @package Thelia\Module\Exception @@ -32,4 +31,4 @@ namespace Thelia\Module\Exception; class InvalidXmlDocumentException extends \RuntimeException { -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Module/ModuleDescriptorValidator.php b/core/lib/Thelia/Module/ModuleDescriptorValidator.php index 679373e02..8f8c89d4a 100644 --- a/core/lib/Thelia/Module/ModuleDescriptorValidator.php +++ b/core/lib/Thelia/Module/ModuleDescriptorValidator.php @@ -24,13 +24,12 @@ namespace Thelia\Module; use Thelia\Module\Exception\InvalidXmlDocumentException; - /** * Class ModuleDescriptorValidator * @package Thelia\Module * @author Manuel Raynaud */ -class ModuleDescriptorValidator +class ModuleDescriptorValidator { private $xsd_file; @@ -44,7 +43,7 @@ class ModuleDescriptorValidator $dom = new \DOMDocument(); if ($dom->load($xml_file)) { - if($dom->schemaValidate($this->xsd_file)) { + if ($dom->schemaValidate($this->xsd_file)) { return true; } } @@ -52,9 +51,10 @@ class ModuleDescriptorValidator throw new InvalidXmlDocumentException(sprintf("%s file is not a valid file", $xml_file)); } - public function getDescriptor($xml_file) { + public function getDescriptor($xml_file) + { $this->validate($xml_file); return @simplexml_load_file($xml_file); } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Module/ModuleManagement.php b/core/lib/Thelia/Module/ModuleManagement.php index 84e6c6457..99cc5ca9f 100644 --- a/core/lib/Thelia/Module/ModuleManagement.php +++ b/core/lib/Thelia/Module/ModuleManagement.php @@ -32,13 +32,12 @@ use Thelia\Model\Module; use Thelia\Model\ModuleI18n; use Thelia\Model\ModuleQuery; - /** * Class ModuleManagement * @package Thelia\Module * @author Manuel Raynaud */ -class ModuleManagement +class ModuleManagement { protected $baseModuleDir; protected $reflected; @@ -59,16 +58,16 @@ class ModuleManagement $descriptorValidator = new ModuleDescriptorValidator(); foreach ($finder as $file) { $content = $descriptorValidator->getDescriptor($file->getRealPath()); - $reflected = new \ReflectionClass((string)$content->fullnamespace); + $reflected = new \ReflectionClass((string) $content->fullnamespace); $code = basename(dirname($reflected->getFileName())); - if(null === ModuleQuery::create()->filterByCode($code)->findOne()) { + if (null === ModuleQuery::create()->filterByCode($code)->findOne()) { $module = new Module(); $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME); $con->beginTransaction(); try { $module ->setCode($code) - ->setFullNamespace((string)$content->fullnamespace) + ->setFullNamespace((string) $content->fullnamespace) ->setType($this->getModuleType($reflected)) ->setActivate(0) ->save($con); @@ -76,7 +75,7 @@ class ModuleManagement $this->saveDescription($module, $content, $con); $con->commit(); - } catch(PropelException $e) { + } catch (PropelException $e) { $con->rollBack(); throw $e; } @@ -88,8 +87,7 @@ class ModuleManagement private function saveDescription(Module $module,\SimpleXMLElement $content, ConnectionInterface $con) { - foreach($content->descriptive as $description) - { + foreach ($content->descriptive as $description) { $locale = $description->attributes()->locale; $moduleI18n = new ModuleI18n(); @@ -107,15 +105,14 @@ class ModuleManagement private function getModuleType(\ReflectionClass $reflected) { - if($reflected->implementsInterface('Thelia\Module\DeliveryModuleInterface')) { + if ($reflected->implementsInterface('Thelia\Module\DeliveryModuleInterface')) { return BaseModule::DELIVERY_MODULE_TYPE; - } else if($reflected->implementsInterface('Thelia\Module\PaymentModuleInterface')) { + } elseif ($reflected->implementsInterface('Thelia\Module\PaymentModuleInterface')) { return BaseModule::PAYMENT_MODULE_TYPE; } else { return BaseModule::CLASSIC_MODULE_TYPE; } - } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Action/BaseAction.php b/core/lib/Thelia/Tests/Action/BaseAction.php index f0027fd21..c07c07115 100644 --- a/core/lib/Thelia/Tests/Action/BaseAction.php +++ b/core/lib/Thelia/Tests/Action/BaseAction.php @@ -23,7 +23,6 @@ namespace Thelia\Tests\Action; - /** * Class BaseAction * @package Thelia\Tests\Action\ImageTest @@ -41,4 +40,4 @@ class BaseAction extends \PHPUnit_Framework_TestCase return $container; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Action/ContentTest.php b/core/lib/Thelia/Tests/Action/ContentTest.php index 7aa819346..f527026bf 100644 --- a/core/lib/Thelia/Tests/Action/ContentTest.php +++ b/core/lib/Thelia/Tests/Action/ContentTest.php @@ -36,7 +36,6 @@ use Thelia\Model\ContentFolderQuery; use Thelia\Model\ContentQuery; use Thelia\Model\FolderQuery; - /** * Class ContentTest * @package Thelia\Tests\Action @@ -205,7 +204,7 @@ class ContentTest extends BaseAction $test = ContentFolderQuery::create() ->filterByContent($content) ->filterByFolder($folder); - } while($test->count() > 0); + } while ($test->count() > 0); $event = new ContentAddFolderEvent($content, $folder->getId()); @@ -267,10 +266,10 @@ class ContentTest extends BaseAction ->addAscendingOrderByColumn('RAND()') ->findOne(); - if(null === $folder) { + if (null === $folder) { $this->fail('use fixtures before launching test, there is no folder in database'); } return $folder; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/Action/FolderTest.php b/core/lib/Thelia/Tests/Action/FolderTest.php index 903e1b77b..7ef88aa0d 100644 --- a/core/lib/Thelia/Tests/Action/FolderTest.php +++ b/core/lib/Thelia/Tests/Action/FolderTest.php @@ -31,7 +31,6 @@ use Thelia\Core\Event\Folder\FolderUpdateEvent; use Thelia\Core\Event\UpdatePositionEvent; use Thelia\Model\FolderQuery; - /** * Class FolderTest * @package Thelia\Tests\Action\ImageTest @@ -73,8 +72,6 @@ class FolderTest extends BaseAction { $folder = $this->getRandomFolder(); - - $visible = !$folder->getVisible(); $event = new FolderUpdateEvent($folder->getId()); @@ -147,7 +144,7 @@ class FolderTest extends BaseAction ->filterByPosition(1, Criteria::GREATER_THAN) ->findOne(); - if(null === $folder) { + if (null === $folder) { $this->fail('use fixtures before launching test, there is no folder in database'); } @@ -169,7 +166,7 @@ class FolderTest extends BaseAction ->filterByPosition(1) ->findOne(); - if(null === $folder) { + if (null === $folder) { $this->fail('use fixtures before launching test, there is no folder in database'); } @@ -191,7 +188,7 @@ class FolderTest extends BaseAction ->filterByPosition(1, Criteria::GREATER_THAN) ->findOne(); - if(null === $folder) { + if (null === $folder) { $this->fail('use fixtures before launching test, there is no folder in database'); } @@ -215,10 +212,10 @@ class FolderTest extends BaseAction ->addAscendingOrderByColumn('RAND()') ->findOne(); - if(null === $folder) { + if (null === $folder) { $this->fail('use fixtures before launching test, there is no folder in database'); } return $folder; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php index 0dbbc73bb..1e6f6f258 100755 --- a/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php +++ b/core/lib/Thelia/Tests/TaxEngine/CalculatorTest.php @@ -127,7 +127,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRulesCollection = new ObjectCollection(); $aProduct = ProductQuery::create()->findOne(); - if(null === $aProduct) { + if (null === $aProduct) { return; } @@ -169,7 +169,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRulesCollection->setModel('\Thelia\Model\Tax'); $aProduct = ProductQuery::create()->findOne(); - if(null === $aProduct) { + if (null === $aProduct) { return; } @@ -214,7 +214,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRulesCollection->append($tax); $aProduct = ProductQuery::create()->findOne(); - if(null === $aProduct) { + if (null === $aProduct) { return; } @@ -270,7 +270,7 @@ class CalculatorTest extends \PHPUnit_Framework_TestCase $taxRulesCollection->append($tax); $aProduct = ProductQuery::create()->findOne(); - if(null === $aProduct) { + if (null === $aProduct) { return; } diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html index 57bb14bf1..c94ba8789 100644 --- a/templates/admin/default/modules.html +++ b/templates/admin/default/modules.html @@ -88,7 +88,7 @@ }).done(function(){ $("#loading-event").remove(); }) - .fail(function(jqXHR, textStatus, errorThrown){ + .fail(function(jqXHR, textStatus, errorThrown){ $("#loading-event").remove(); $('#module-failed-body').html(jqXHR.responseJSON.error); $("#module-failed").modal("show"); From e602884ce019167781416423aba85438af3f57f0 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 10:06:42 +0200 Subject: [PATCH 22/50] end module activation --- core/lib/Thelia/Action/Module.php | 4 +--- core/lib/Thelia/Module/BaseModule.php | 10 ++++++---- local/modules/Cheque/Cheque.php | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 213024e16..040c9f7b4 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -53,9 +53,7 @@ class Module extends BaseAction implements EventSubscriberInterface } } - if ($module->isModified()) { - $event->setModule($module); - } + $event->setModule($module); $this->cacheClear(); } diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 83636b921..598e25baa 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -135,17 +135,19 @@ abstract class BaseModule extends ContainerAware } } - public function deployImageFolder(Module $module, $folderPath) + public function deployImageFolder(Module $module, $folderPath, ConnectionInterface $con = null) { try { $directoryBrowser = new \DirectoryIterator($folderPath); } catch (\UnexpectedValueException $e) { throw $e; } + if(null === $con) { + $con = \Propel\Runtime\Propel::getConnection( + ModuleImageTableMap::DATABASE_NAME + ); + } - $con = \Propel\Runtime\Propel::getConnection( - ModuleImageTableMap::DATABASE_NAME - ); /* browse the directory */ $imagePosition = 1; diff --git a/local/modules/Cheque/Cheque.php b/local/modules/Cheque/Cheque.php index 324728990..cebaff146 100755 --- a/local/modules/Cheque/Cheque.php +++ b/local/modules/Cheque/Cheque.php @@ -66,7 +66,7 @@ class Cheque extends BaseModule implements PaymentModuleInterface /* insert the images from image folder if first module activation */ $module = $this->getModuleModel(); if(ModuleImageQuery::create()->filterByModule($module)->count() == 0) { - $this->deployImageFolder($module, sprintf('%s/images', __DIR__)); + $this->deployImageFolder($module, sprintf('%s/images', __DIR__), $con); } /* set module title */ From 392d8a35594b60627069bc2547fc226690ab3a76 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 11:24:19 +0200 Subject: [PATCH 23/50] decode url before searching if it's a rewritten url --- core/lib/Thelia/Rewriting/RewritingResolver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Rewriting/RewritingResolver.php b/core/lib/Thelia/Rewriting/RewritingResolver.php index 4c8bcba40..8edd0ebba 100755 --- a/core/lib/Thelia/Rewriting/RewritingResolver.php +++ b/core/lib/Thelia/Rewriting/RewritingResolver.php @@ -59,7 +59,7 @@ class RewritingResolver public function load($rewrittenUrl) { $rewrittenUrl = ltrim($rewrittenUrl, '/'); - + $rewrittenUrl = urldecode($rewrittenUrl); $this->search = $this->rewritingUrlQuery->getResolverSearch($rewrittenUrl); if($this->search->count() == 0) { From b24546a12c7428a3aef1ed884cd7f38f8251e1aa Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 15:45:11 +0200 Subject: [PATCH 24/50] fix product visibility comparaison parameter --- core/lib/Thelia/Core/Template/Loop/Product.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index f0bb95249..ef47fe3b8 100755 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -461,7 +461,7 @@ class Product extends BaseI18nLoop $visible = $this->getVisible(); - if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); + if ($visible !== BooleanOrBothType::ANY) $search->filterByVisible($visible ? 1 : 0); $exclude = $this->getExclude(); From d354ed96add7450d5719de0bb8a6f487f4d8c9cf Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 18 Oct 2013 15:59:49 +0200 Subject: [PATCH 25/50] don't use alternative Logger in debugbar if debug is disabled --- .../modules/TheliaDebugBar/Listeners/DebugBarListeners.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php b/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php index c7b9d015c..5ea75a1df 100755 --- a/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php +++ b/local/modules/TheliaDebugBar/Listeners/DebugBarListeners.php @@ -45,13 +45,17 @@ class DebugBarListeners extends BaseAction implements EventSubscriberInterface { { $debugBar = $this->container->get("debugBar"); + $alternativelogger = null; + if($this->container->getParameter('kernel.debug')) { + $alternativelogger = \Thelia\Log\Tlog::getInstance(); + } $debugBar->addCollector(new PhpInfoCollector()); //$debugBar->addCollector(new MessagesCollector()); //$debugBar->addCollector(new RequestDataCollector()); $debugBar->addCollector(new TimeDataCollector()); $debugBar->addCollector(new MemoryCollector()); - $debugBar->addCollector(new PropelCollector(\Thelia\Log\Tlog::getInstance())); + $debugBar->addCollector(new PropelCollector($alternativelogger)); } /** From 0300470f7d6665706e0261cc5285548a5ba329c7 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 21 Oct 2013 08:10:55 +0200 Subject: [PATCH 26/50] new model --- core/lib/Thelia/Action/Profile.php | 104 + core/lib/Thelia/Config/Resources/action.xml | 5 + core/lib/Thelia/Config/Resources/config.xml | 5 +- .../Thelia/Config/Resources/routing/admin.xml | 9 + .../Controller/Admin/ProfileController.php | 227 ++ .../Core/Event/Profile/ProfileEvent.php | 54 + core/lib/Thelia/Core/Event/TheliaEvents.php | 7 + core/lib/Thelia/Form/ProfileCreationForm.php | 72 + .../Thelia/Form/ProfileModificationForm.php | 101 +- core/lib/Thelia/Form/TaxCreationForm.php | 6 +- core/lib/Thelia/Form/TaxModificationForm.php | 5 + core/lib/Thelia/Model/AdminGroup.php | 9 - core/lib/Thelia/Model/AdminGroupQuery.php | 20 - core/lib/Thelia/Model/Base/Admin.php | 396 +-- core/lib/Thelia/Model/Base/AdminGroup.php | 1508 -------- .../lib/Thelia/Model/Base/AdminGroupQuery.php | 778 ---- core/lib/Thelia/Model/Base/AdminQuery.php | 54 +- core/lib/Thelia/Model/Base/Group.php | 3158 ----------------- core/lib/Thelia/Model/Base/GroupI18n.php | 1442 -------- core/lib/Thelia/Model/Base/GroupI18nQuery.php | 607 ---- core/lib/Thelia/Model/Base/GroupModule.php | 1575 -------- .../Thelia/Model/Base/GroupModuleQuery.php | 804 ----- core/lib/Thelia/Model/Base/GroupQuery.php | 940 ----- core/lib/Thelia/Model/Base/GroupResource.php | 1649 --------- .../Thelia/Model/Base/GroupResourceQuery.php | 868 ----- core/lib/Thelia/Model/Base/Module.php | 218 +- core/lib/Thelia/Model/Base/ModuleQuery.php | 42 +- core/lib/Thelia/Model/Base/OrderProduct.php | 106 +- .../Thelia/Model/Base/OrderProductQuery.php | 35 +- .../Thelia/Model/Base/ProductSaleElements.php | 76 +- .../Model/Base/ProductSaleElementsQuery.php | 35 +- core/lib/Thelia/Model/Base/Resource.php | 396 +-- core/lib/Thelia/Model/Base/ResourceQuery.php | 54 +- core/lib/Thelia/Model/Group.php | 9 - core/lib/Thelia/Model/GroupI18n.php | 9 - core/lib/Thelia/Model/GroupI18nQuery.php | 20 - core/lib/Thelia/Model/GroupModule.php | 9 - core/lib/Thelia/Model/GroupModuleQuery.php | 20 - core/lib/Thelia/Model/GroupQuery.php | 20 - core/lib/Thelia/Model/GroupResource.php | 9 - core/lib/Thelia/Model/GroupResourceQuery.php | 20 - .../Thelia/Model/Map/AdminGroupTableMap.php | 509 --- core/lib/Thelia/Model/Map/AdminTableMap.php | 6 +- .../Thelia/Model/Map/GroupI18nTableMap.php | 497 --- .../Thelia/Model/Map/GroupModuleTableMap.php | 456 --- .../Model/Map/GroupResourceTableMap.php | 525 --- core/lib/Thelia/Model/Map/GroupTableMap.php | 466 --- core/lib/Thelia/Model/Map/ModuleTableMap.php | 4 +- .../Thelia/Model/Map/OrderProductTableMap.php | 36 +- .../Model/Map/ProductSaleElementsTableMap.php | 36 +- .../lib/Thelia/Model/Map/ResourceTableMap.php | 6 +- install/thelia.sql | 84 +- local/config/schema.xml | 58 +- templates/admin/default/configuration.html | 6 +- templates/admin/default/profiles.html | 310 ++ 55 files changed, 1753 insertions(+), 16727 deletions(-) create mode 100644 core/lib/Thelia/Action/Profile.php create mode 100644 core/lib/Thelia/Controller/Admin/ProfileController.php create mode 100644 core/lib/Thelia/Core/Event/Profile/ProfileEvent.php create mode 100644 core/lib/Thelia/Form/ProfileCreationForm.php delete mode 100755 core/lib/Thelia/Model/AdminGroup.php delete mode 100755 core/lib/Thelia/Model/AdminGroupQuery.php delete mode 100644 core/lib/Thelia/Model/Base/AdminGroup.php delete mode 100644 core/lib/Thelia/Model/Base/AdminGroupQuery.php delete mode 100644 core/lib/Thelia/Model/Base/Group.php delete mode 100644 core/lib/Thelia/Model/Base/GroupI18n.php delete mode 100644 core/lib/Thelia/Model/Base/GroupI18nQuery.php delete mode 100644 core/lib/Thelia/Model/Base/GroupModule.php delete mode 100644 core/lib/Thelia/Model/Base/GroupModuleQuery.php delete mode 100644 core/lib/Thelia/Model/Base/GroupQuery.php delete mode 100644 core/lib/Thelia/Model/Base/GroupResource.php delete mode 100644 core/lib/Thelia/Model/Base/GroupResourceQuery.php delete mode 100755 core/lib/Thelia/Model/Group.php delete mode 100755 core/lib/Thelia/Model/GroupI18n.php delete mode 100755 core/lib/Thelia/Model/GroupI18nQuery.php delete mode 100755 core/lib/Thelia/Model/GroupModule.php delete mode 100755 core/lib/Thelia/Model/GroupModuleQuery.php delete mode 100755 core/lib/Thelia/Model/GroupQuery.php delete mode 100755 core/lib/Thelia/Model/GroupResource.php delete mode 100755 core/lib/Thelia/Model/GroupResourceQuery.php delete mode 100644 core/lib/Thelia/Model/Map/AdminGroupTableMap.php delete mode 100644 core/lib/Thelia/Model/Map/GroupI18nTableMap.php delete mode 100644 core/lib/Thelia/Model/Map/GroupModuleTableMap.php delete mode 100644 core/lib/Thelia/Model/Map/GroupResourceTableMap.php delete mode 100644 core/lib/Thelia/Model/Map/GroupTableMap.php create mode 100644 templates/admin/default/profiles.html diff --git a/core/lib/Thelia/Action/Profile.php b/core/lib/Thelia/Action/Profile.php new file mode 100644 index 000000000..58d5b20ac --- /dev/null +++ b/core/lib/Thelia/Action/Profile.php @@ -0,0 +1,104 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Action; + +use Propel\Runtime\ActiveQuery\Criteria; +use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Thelia\Core\Event\Profile\ProfileEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\Group as GroupModel; +use Thelia\Model\GroupQuery; + +class Profile extends BaseAction implements EventSubscriberInterface +{ + /** + * @param ProfileEvent $event + */ + public function create(ProfileEvent $event) + { + /*$group = new GroupModel(); + + $group + ->setDispatcher($this->getDispatcher()) + ->setRequirements($event->getRequirements()) + ->setType($event->getType()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ; + + $group->save(); + + $event->setGroup($group);*/ + } + + /** + * @param ProfileEvent $event + */ + public function update(ProfileEvent $event) + { + if (null !== $group = GroupQuery::create()->findPk($event->getId())) { + + /*$group + ->setDispatcher($this->getDispatcher()) + ->setRequirements($event->getRequirements()) + ->setType($event->getType()) + ->setLocale($event->getLocale()) + ->setTitle($event->getTitle()) + ->setDescription($event->getDescription()) + ; + + $group->save(); + + $event->setGroup($group);*/ + } + } + + /** + * @param ProfileEvent $event + */ + public function delete(ProfileEvent $event) + { + if (null !== $group = GroupQuery::create()->findPk($event->getId())) { + + /*$group + ->delete() + ; + + $event->setGroup($group);*/ + } + } + + /** + * {@inheritDoc} + */ + public static function getSubscribedEvents() + { + return array( + TheliaEvents::PROFILE_CREATE => array("create", 128), + TheliaEvents::PROFILE_UPDATE => array("update", 128), + TheliaEvents::PROFILE_DELETE => array("delete", 128), + ); + } +} diff --git a/core/lib/Thelia/Config/Resources/action.xml b/core/lib/Thelia/Config/Resources/action.xml index 2b0c8008a..41ded3741 100755 --- a/core/lib/Thelia/Config/Resources/action.xml +++ b/core/lib/Thelia/Config/Resources/action.xml @@ -141,6 +141,11 @@ + + + + + diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 97342c40b..89d93d733 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -122,14 +122,15 @@
+ + + - - diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 865c14484..144b94ab2 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -757,6 +757,15 @@ + + + + Thelia\Controller\Admin\ProfileController::defaultAction + \d+ + + + + diff --git a/core/lib/Thelia/Controller/Admin/ProfileController.php b/core/lib/Thelia/Controller/Admin/ProfileController.php new file mode 100644 index 000000000..542cafc04 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/ProfileController.php @@ -0,0 +1,227 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\Profile\ProfileEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Form\ProfileCreationForm; +use Thelia\Form\ProfileModificationForm; +use Thelia\Form\ProfileProfileListUpdateForm; +use Thelia\Model\ProfileQuery; + +class ProfileController extends AbstractCrudController +{ + public function __construct() + { + parent::__construct( + 'profile', + 'manual', + 'order', + + 'admin.configuration.profile.view', + 'admin.configuration.profile.create', + 'admin.configuration.profile.update', + 'admin.configuration.profile.delete', + + TheliaEvents::TAX_CREATE, + TheliaEvents::TAX_UPDATE, + TheliaEvents::TAX_DELETE + ); + } + + protected function getCreationForm() + { + return new ProfileCreationForm($this->getRequest()); + } + + protected function getUpdateForm() + { + return new ProfileModificationForm($this->getRequest()); + } + + protected function getCreationEvent($formData) + { + $event = new ProfileEvent(); + + $event->setLocale($formData['locale']); + $event->setTitle($formData['title']); + $event->setDescription($formData['description']); + $event->setType($formData['type']); + $event->setRequirements($this->getRequirements($formData['type'], $formData)); + + return $event; + } + + protected function getUpdateEvent($formData) + { + $event = new ProfileEvent(); + + $event->setLocale($formData['locale']); + $event->setId($formData['id']); + $event->setTitle($formData['title']); + $event->setDescription($formData['description']); + $event->setType($formData['type']); + $event->setRequirements($this->getRequirements($formData['type'], $formData)); + + return $event; + } + + protected function getDeleteEvent() + { + $event = new ProfileEvent(); + + $event->setId( + $this->getRequest()->get('profile_id', 0) + ); + + return $event; + } + + protected function eventContainsObject($event) + { + return $event->hasProfile(); + } + + protected function hydrateObjectForm($object) + { + $data = array( + 'id' => $object->getId(), + 'locale' => $object->getLocale(), + 'title' => $object->getTitle(), + 'description' => $object->getDescription(), + 'type' => $object->getType(), + ); + + // Setup the object form + return new ProfileModificationForm($this->getRequest(), "form", $data); + } + + protected function getObjectFromEvent($event) + { + return $event->hasProfile() ? $event->getProfile() : null; + } + + protected function getExistingObject() + { + return ProfileQuery::create() + ->joinWithI18n($this->getCurrentEditionLocale()) + ->findOneById($this->getRequest()->get('profile_id')); + } + + protected function getObjectLabel($object) + { + return $object->getTitle(); + } + + protected function getObjectId($object) + { + return $object->getId(); + } + + protected function getViewArguments() + { + return array(); + } + + protected function getRouteArguments($profile_id = null) + { + return array( + 'profile_id' => $profile_id === null ? $this->getRequest()->get('profile_id') : $profile_id, + ); + } + + protected function renderListTemplate($currentOrder) + { + // We always return to the feature edition form + return $this->render( + 'profiles', + array() + ); + } + + protected function renderEditionTemplate() + { + // We always return to the feature edition form + return $this->render('profile-edit', array_merge($this->getViewArguments(), $this->getRouteArguments())); + } + + protected function redirectToEditionTemplate($request = null, $country = null) + { + // We always return to the feature edition form + $this->redirectToRoute( + "admin.configuration.profilees.update", + $this->getViewArguments($country), + $this->getRouteArguments() + ); + } + + /** + * Put in this method post object creation processing if required. + * + * @param ProfileEvent $createEvent the create event + * @return Response a response, or null to continue normal processing + */ + protected function performAdditionalCreateAction($createEvent) + { + $this->redirectToRoute( + "admin.configuration.profiles.update", + $this->getViewArguments(), + $this->getRouteArguments($createEvent->getProfile()->getId()) + ); + } + + protected function redirectToListTemplate() + { + $this->redirectToRoute( + "admin.configuration.profiles.list" + ); + } + + protected function checkRequirements($formData) + { + $type = $formData['type']; + + + } + + protected function getRequirements($type, $formData) + { + $requirements = array(); + foreach($formData as $data => $value) { + if(!strstr($data, ':')) { + continue; + } + + $couple = explode(':', $data); + + if(count($couple) != 2 || $couple[0] != $type) { + continue; + } + + $requirements[$couple[1]] = $value; + } + + return $requirements; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/Profile/ProfileEvent.php b/core/lib/Thelia/Core/Event/Profile/ProfileEvent.php new file mode 100644 index 000000000..f5cd44e76 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Profile/ProfileEvent.php @@ -0,0 +1,54 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Profile; + +use Thelia\Core\Event\ActionEvent; +use Thelia\Model\Group; + +class ProfileEvent extends ActionEvent +{ + protected $group = null; + + public function __construct(Group $group = null) + { + $this->group = $group; + } + + public function hasGroup() + { + return ! is_null($this->group); + } + + public function getGroup() + { + return $this->group; + } + + public function setGroup(Group $group) + { + $this->group = $group; + + return $this; + } +} diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 66d36bb1d..febcb8672 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -549,6 +549,13 @@ final class TheliaEvents const TAX_UPDATE = "action.updateTax"; const TAX_DELETE = "action.deleteTax"; + + // -- Profile management --------------------------------------------- + + const PROFILE_CREATE = "action.createProfile"; + const PROFILE_UPDATE = "action.updateProfile"; + const PROFILE_DELETE = "action.deleteProfile"; + // -- Tax Rules management --------------------------------------------- const TAX_RULE_CREATE = "action.createTaxRule"; diff --git a/core/lib/Thelia/Form/ProfileCreationForm.php b/core/lib/Thelia/Form/ProfileCreationForm.php new file mode 100644 index 000000000..6aaae8043 --- /dev/null +++ b/core/lib/Thelia/Form/ProfileCreationForm.php @@ -0,0 +1,72 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Form; + +use Symfony\Component\Validator\Constraints; +use Symfony\Component\Validator\Constraints\NotBlank; +use Thelia\Core\Translation\Translator; + +/** + * Class ProfileCreationForm + * @package Thelia\Form + * @author Etienne Roudeix + */ +class ProfileCreationForm extends BaseForm +{ + use StandardDescriptionFieldsTrait; + + protected function buildForm($change_mode = false) + { + $types = ProfileEngine::getInstance()->getProfileTypeList(); + $typeList = array(); + $requirementList = array(); + foreach($types as $type) { + $classPath = "\\Thelia\\ProfileEngine\\ProfileType\\$type"; + $instance = new $classPath(); + $typeList[$type] = $instance->getTitle(); + $requirementList[$type] = $instance->getRequirementsList(); + } + + $this->formBuilder + ->add("locale", "text", array( + "constraints" => array(new NotBlank()) + )) + ->add("type", "choice", array( + "choices" => $typeList, + "required" => true, + "constraints" => array( + new Constraints\NotBlank(), + ), + "label" => Translator::getInstance()->trans("Type"), + "label_attr" => array("for" => "type_field"), + )) + ; + + $this->addStandardDescFields(array('postscriptum', 'chapo', 'locale')); + } + + public function getName() + { + return "thelia_profile_creation"; + } +} diff --git a/core/lib/Thelia/Form/ProfileModificationForm.php b/core/lib/Thelia/Form/ProfileModificationForm.php index 618fbdfb4..6865b1109 100644 --- a/core/lib/Thelia/Form/ProfileModificationForm.php +++ b/core/lib/Thelia/Form/ProfileModificationForm.php @@ -1,7 +1,7 @@ . */ +/* along with this program. If not, see . */ /* */ /*************************************************************************************/ - namespace Thelia\Form; use Symfony\Component\Validator\Constraints; -use Thelia\Core\Translation\Translator; -use Thelia\Model\ConfigQuery; +use Symfony\Component\Validator\ExecutionContextInterface; +use Thelia\Model\ProfileQuery; /** - * Class ProfileModification + * Class ProfileModificationForm * @package Thelia\Form - * @author Manuel Raynaud + * @author Etienne Roudeix */ -class ProfileModificationForm extends BaseForm +class ProfileModificationForm extends ProfileCreationForm { - protected function buildForm() { + parent::buildForm(true); $this->formBuilder - ->add("firstname", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("First Name"), - "label_attr" => array( - "for" => "firstname" - ) - )) - ->add("lastname", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Last Name"), - "label_attr" => array( - "for" => "lastname" - ) - )) - ->add("default_language", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Default language"), - "label_attr" => array( - "for" => "default_language" - ) - )) - ->add("editing_language_default", "text", array( - "constraints" => array( - new Constraints\NotBlank() - ), - "label" => Translator::getInstance()->trans("Editing language default"), - "label_attr" => array( - "for" => "editing_language_default" - ) - )) - ->add("old_password", "password", array( + ->add("id", "hidden", array( + "required" => true, "constraints" => array( new Constraints\NotBlank(), - new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) - ), - "label" => Translator::getInstance()->trans("Old password"), - "label_attr" => array( - "for" => "old_password" - ) - )) - ->add("password", "password", array( - "constraints" => array( - new Constraints\NotBlank(), - new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))) - ), - "label" => Translator::getInstance()->trans("Password"), - "label_attr" => array( - "for" => "password" - ) - )) - ->add("password_confirm", "password", array( - "constraints" => array( - new Constraints\NotBlank(), - new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))), - new Constraints\Callback(array("methods" => array( - array($this, "verifyPasswordField") - ))) - ), - "label" => "Password confirmation", - "label_attr" => array( - "for" => "password_confirmation" + new Constraints\Callback( + array( + "methods" => array( + array($this, "verifyProfileId"), + ), + ) + ), ) )) ; @@ -115,4 +58,14 @@ class ProfileModificationForm extends BaseForm { return "thelia_profile_modification"; } + + public function verifyProfileId($value, ExecutionContextInterface $context) + { + $profile = ProfileQuery::create() + ->findPk($value); + + if (null === $profile) { + $context->addViolation("Profile ID not found"); + } + } } diff --git a/core/lib/Thelia/Form/TaxCreationForm.php b/core/lib/Thelia/Form/TaxCreationForm.php index 37cc80a92..abc8fa316 100644 --- a/core/lib/Thelia/Form/TaxCreationForm.php +++ b/core/lib/Thelia/Form/TaxCreationForm.php @@ -24,12 +24,16 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraints\NotBlank; -use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Form\Type\TheliaType; use Thelia\Core\Translation\Translator; use Thelia\TaxEngine\TaxEngine; use Thelia\TaxEngine\TaxType; +/** + * Class TaxCreationForm + * @package Thelia\Form + * @author Etienne Roudeix + */ class TaxCreationForm extends BaseForm { use StandardDescriptionFieldsTrait; diff --git a/core/lib/Thelia/Form/TaxModificationForm.php b/core/lib/Thelia/Form/TaxModificationForm.php index 1c496440e..8cfacdd0c 100644 --- a/core/lib/Thelia/Form/TaxModificationForm.php +++ b/core/lib/Thelia/Form/TaxModificationForm.php @@ -26,6 +26,11 @@ use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Model\TaxQuery; +/** + * Class TaxModificationForm + * @package Thelia\Form + * @author Etienne Roudeix + */ class TaxModificationForm extends TaxCreationForm { protected function buildForm() diff --git a/core/lib/Thelia/Model/AdminGroup.php b/core/lib/Thelia/Model/AdminGroup.php deleted file mode 100755 index 4f84ca894..000000000 --- a/core/lib/Thelia/Model/AdminGroup.php +++ /dev/null @@ -1,9 +0,0 @@ -collAdminGroups = null; + $this->collAdminProfiles = null; - $this->collGroups = null; + $this->collProfiles = null; } // if (deep) } @@ -1064,44 +1064,44 @@ abstract class Admin implements ActiveRecordInterface $this->resetModified(); } - if ($this->groupsScheduledForDeletion !== null) { - if (!$this->groupsScheduledForDeletion->isEmpty()) { + if ($this->profilesScheduledForDeletion !== null) { + if (!$this->profilesScheduledForDeletion->isEmpty()) { $pks = array(); $pk = $this->getPrimaryKey(); - foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + foreach ($this->profilesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } - AdminGroupQuery::create() + AdminProfileQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); - $this->groupsScheduledForDeletion = null; + $this->profilesScheduledForDeletion = null; } - foreach ($this->getGroups() as $group) { - if ($group->isModified()) { - $group->save($con); + foreach ($this->getProfiles() as $profile) { + if ($profile->isModified()) { + $profile->save($con); } } - } elseif ($this->collGroups) { - foreach ($this->collGroups as $group) { - if ($group->isModified()) { - $group->save($con); + } elseif ($this->collProfiles) { + foreach ($this->collProfiles as $profile) { + if ($profile->isModified()) { + $profile->save($con); } } } - if ($this->adminGroupsScheduledForDeletion !== null) { - if (!$this->adminGroupsScheduledForDeletion->isEmpty()) { - \Thelia\Model\AdminGroupQuery::create() - ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false)) + if ($this->adminProfilesScheduledForDeletion !== null) { + if (!$this->adminProfilesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AdminProfileQuery::create() + ->filterByPrimaryKeys($this->adminProfilesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->adminGroupsScheduledForDeletion = null; + $this->adminProfilesScheduledForDeletion = null; } } - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { + if ($this->collAdminProfiles !== null) { + foreach ($this->collAdminProfiles as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1353,8 +1353,8 @@ abstract class Admin implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collAdminGroups) { - $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collAdminProfiles) { + $result['AdminProfiles'] = $this->collAdminProfiles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } } @@ -1559,9 +1559,9 @@ abstract class Admin implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getAdminGroups() as $relObj) { + foreach ($this->getAdminProfiles() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAdminGroup($relObj->copy($deepCopy)); + $copyObj->addAdminProfile($relObj->copy($deepCopy)); } } @@ -1606,37 +1606,37 @@ abstract class Admin implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('AdminGroup' == $relationName) { - return $this->initAdminGroups(); + if ('AdminProfile' == $relationName) { + return $this->initAdminProfiles(); } } /** - * Clears out the collAdminGroups collection + * Clears out the collAdminProfiles collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addAdminGroups() + * @see addAdminProfiles() */ - public function clearAdminGroups() + public function clearAdminProfiles() { - $this->collAdminGroups = null; // important to set this to NULL since that means it is uninitialized + $this->collAdminProfiles = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collAdminGroups collection loaded partially. + * Reset is the collAdminProfiles collection loaded partially. */ - public function resetPartialAdminGroups($v = true) + public function resetPartialAdminProfiles($v = true) { - $this->collAdminGroupsPartial = $v; + $this->collAdminProfilesPartial = $v; } /** - * Initializes the collAdminGroups collection. + * Initializes the collAdminProfiles collection. * - * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups()); + * By default this just sets the collAdminProfiles collection to an empty array (like clearcollAdminProfiles()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1645,17 +1645,17 @@ abstract class Admin implements ActiveRecordInterface * * @return void */ - public function initAdminGroups($overrideExisting = true) + public function initAdminProfiles($overrideExisting = true) { - if (null !== $this->collAdminGroups && !$overrideExisting) { + if (null !== $this->collAdminProfiles && !$overrideExisting) { return; } - $this->collAdminGroups = new ObjectCollection(); - $this->collAdminGroups->setModel('\Thelia\Model\AdminGroup'); + $this->collAdminProfiles = new ObjectCollection(); + $this->collAdminProfiles->setModel('\Thelia\Model\AdminProfile'); } /** - * Gets an array of ChildAdminGroup objects which contain a foreign key that references this object. + * Gets an array of ChildAdminProfile objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1665,112 +1665,112 @@ abstract class Admin implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects + * @return Collection|ChildAdminProfile[] List of ChildAdminProfile objects * @throws PropelException */ - public function getAdminGroups($criteria = null, ConnectionInterface $con = null) + public function getAdminProfiles($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { + $partial = $this->collAdminProfilesPartial && !$this->isNew(); + if (null === $this->collAdminProfiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAdminProfiles) { // return empty collection - $this->initAdminGroups(); + $this->initAdminProfiles(); } else { - $collAdminGroups = ChildAdminGroupQuery::create(null, $criteria) + $collAdminProfiles = ChildAdminProfileQuery::create(null, $criteria) ->filterByAdmin($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) { - $this->initAdminGroups(false); + if (false !== $this->collAdminProfilesPartial && count($collAdminProfiles)) { + $this->initAdminProfiles(false); - foreach ($collAdminGroups as $obj) { - if (false == $this->collAdminGroups->contains($obj)) { - $this->collAdminGroups->append($obj); + foreach ($collAdminProfiles as $obj) { + if (false == $this->collAdminProfiles->contains($obj)) { + $this->collAdminProfiles->append($obj); } } - $this->collAdminGroupsPartial = true; + $this->collAdminProfilesPartial = true; } - $collAdminGroups->getInternalIterator()->rewind(); + $collAdminProfiles->getInternalIterator()->rewind(); - return $collAdminGroups; + return $collAdminProfiles; } - if ($partial && $this->collAdminGroups) { - foreach ($this->collAdminGroups as $obj) { + if ($partial && $this->collAdminProfiles) { + foreach ($this->collAdminProfiles as $obj) { if ($obj->isNew()) { - $collAdminGroups[] = $obj; + $collAdminProfiles[] = $obj; } } } - $this->collAdminGroups = $collAdminGroups; - $this->collAdminGroupsPartial = false; + $this->collAdminProfiles = $collAdminProfiles; + $this->collAdminProfilesPartial = false; } } - return $this->collAdminGroups; + return $this->collAdminProfiles; } /** - * Sets a collection of AdminGroup objects related by a one-to-many relationship + * Sets a collection of AdminProfile objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $adminGroups A Propel collection. + * @param Collection $adminProfiles A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildAdmin The current object (for fluent API support) */ - public function setAdminGroups(Collection $adminGroups, ConnectionInterface $con = null) + public function setAdminProfiles(Collection $adminProfiles, ConnectionInterface $con = null) { - $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); + $adminProfilesToDelete = $this->getAdminProfiles(new Criteria(), $con)->diff($adminProfiles); //since at least one column in the foreign key is at the same time a PK //we can not just set a PK to NULL in the lines below. We have to store //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->adminGroupsScheduledForDeletion = clone $adminGroupsToDelete; + $this->adminProfilesScheduledForDeletion = clone $adminProfilesToDelete; - foreach ($adminGroupsToDelete as $adminGroupRemoved) { - $adminGroupRemoved->setAdmin(null); + foreach ($adminProfilesToDelete as $adminProfileRemoved) { + $adminProfileRemoved->setAdmin(null); } - $this->collAdminGroups = null; - foreach ($adminGroups as $adminGroup) { - $this->addAdminGroup($adminGroup); + $this->collAdminProfiles = null; + foreach ($adminProfiles as $adminProfile) { + $this->addAdminProfile($adminProfile); } - $this->collAdminGroups = $adminGroups; - $this->collAdminGroupsPartial = false; + $this->collAdminProfiles = $adminProfiles; + $this->collAdminProfilesPartial = false; return $this; } /** - * Returns the number of related AdminGroup objects. + * Returns the number of related AdminProfile objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related AdminGroup objects. + * @return int Count of related AdminProfile objects. * @throws PropelException */ - public function countAdminGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countAdminProfiles(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { + $partial = $this->collAdminProfilesPartial && !$this->isNew(); + if (null === $this->collAdminProfiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAdminProfiles) { return 0; } if ($partial && !$criteria) { - return count($this->getAdminGroups()); + return count($this->getAdminProfiles()); } - $query = ChildAdminGroupQuery::create(null, $criteria); + $query = ChildAdminProfileQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1780,53 +1780,53 @@ abstract class Admin implements ActiveRecordInterface ->count($con); } - return count($this->collAdminGroups); + return count($this->collAdminProfiles); } /** - * Method called to associate a ChildAdminGroup object to this object - * through the ChildAdminGroup foreign key attribute. + * Method called to associate a ChildAdminProfile object to this object + * through the ChildAdminProfile foreign key attribute. * - * @param ChildAdminGroup $l ChildAdminGroup + * @param ChildAdminProfile $l ChildAdminProfile * @return \Thelia\Model\Admin The current object (for fluent API support) */ - public function addAdminGroup(ChildAdminGroup $l) + public function addAdminProfile(ChildAdminProfile $l) { - if ($this->collAdminGroups === null) { - $this->initAdminGroups(); - $this->collAdminGroupsPartial = true; + if ($this->collAdminProfiles === null) { + $this->initAdminProfiles(); + $this->collAdminProfilesPartial = true; } - if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAdminGroup($l); + if (!in_array($l, $this->collAdminProfiles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAdminProfile($l); } return $this; } /** - * @param AdminGroup $adminGroup The adminGroup object to add. + * @param AdminProfile $adminProfile The adminProfile object to add. */ - protected function doAddAdminGroup($adminGroup) + protected function doAddAdminProfile($adminProfile) { - $this->collAdminGroups[]= $adminGroup; - $adminGroup->setAdmin($this); + $this->collAdminProfiles[]= $adminProfile; + $adminProfile->setAdmin($this); } /** - * @param AdminGroup $adminGroup The adminGroup object to remove. + * @param AdminProfile $adminProfile The adminProfile object to remove. * @return ChildAdmin The current object (for fluent API support) */ - public function removeAdminGroup($adminGroup) + public function removeAdminProfile($adminProfile) { - if ($this->getAdminGroups()->contains($adminGroup)) { - $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup)); - if (null === $this->adminGroupsScheduledForDeletion) { - $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups; - $this->adminGroupsScheduledForDeletion->clear(); + if ($this->getAdminProfiles()->contains($adminProfile)) { + $this->collAdminProfiles->remove($this->collAdminProfiles->search($adminProfile)); + if (null === $this->adminProfilesScheduledForDeletion) { + $this->adminProfilesScheduledForDeletion = clone $this->collAdminProfiles; + $this->adminProfilesScheduledForDeletion->clear(); } - $this->adminGroupsScheduledForDeletion[]= clone $adminGroup; - $adminGroup->setAdmin(null); + $this->adminProfilesScheduledForDeletion[]= clone $adminProfile; + $adminProfile->setAdmin(null); } return $this; @@ -1838,7 +1838,7 @@ abstract class Admin implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this Admin is new, it will return * an empty collection; or if this Admin has previously - * been saved, it will retrieve related AdminGroups from storage. + * been saved, it will retrieve related AdminProfiles from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -1847,49 +1847,49 @@ abstract class Admin implements ActiveRecordInterface * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects + * @return Collection|ChildAdminProfile[] List of ChildAdminProfile objects */ - public function getAdminGroupsJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getAdminProfilesJoinProfile($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ChildAdminGroupQuery::create(null, $criteria); - $query->joinWith('Group', $joinBehavior); + $query = ChildAdminProfileQuery::create(null, $criteria); + $query->joinWith('Profile', $joinBehavior); - return $this->getAdminGroups($query, $con); + return $this->getAdminProfiles($query, $con); } /** - * Clears out the collGroups collection + * Clears out the collProfiles collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addGroups() + * @see addProfiles() */ - public function clearGroups() + public function clearProfiles() { - $this->collGroups = null; // important to set this to NULL since that means it is uninitialized - $this->collGroupsPartial = null; + $this->collProfiles = null; // important to set this to NULL since that means it is uninitialized + $this->collProfilesPartial = null; } /** - * Initializes the collGroups collection. + * Initializes the collProfiles collection. * - * By default this just sets the collGroups collection to an empty collection (like clearGroups()); + * By default this just sets the collProfiles collection to an empty collection (like clearProfiles()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * * @return void */ - public function initGroups() + public function initProfiles() { - $this->collGroups = new ObjectCollection(); - $this->collGroups->setModel('\Thelia\Model\Group'); + $this->collProfiles = new ObjectCollection(); + $this->collProfiles->setModel('\Thelia\Model\Profile'); } /** - * Gets a collection of ChildGroup objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. + * Gets a collection of ChildProfile objects related by a many-to-many relationship + * to the current object by way of the admin_profile cross-reference table. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1900,73 +1900,73 @@ abstract class Admin implements ActiveRecordInterface * @param Criteria $criteria Optional query object to filter the query * @param ConnectionInterface $con Optional connection object * - * @return ObjectCollection|ChildGroup[] List of ChildGroup objects + * @return ObjectCollection|ChildProfile[] List of ChildProfile objects */ - public function getGroups($criteria = null, ConnectionInterface $con = null) + public function getProfiles($criteria = null, ConnectionInterface $con = null) { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { + if (null === $this->collProfiles || null !== $criteria) { + if ($this->isNew() && null === $this->collProfiles) { // return empty collection - $this->initGroups(); + $this->initProfiles(); } else { - $collGroups = ChildGroupQuery::create(null, $criteria) + $collProfiles = ChildProfileQuery::create(null, $criteria) ->filterByAdmin($this) ->find($con); if (null !== $criteria) { - return $collGroups; + return $collProfiles; } - $this->collGroups = $collGroups; + $this->collProfiles = $collProfiles; } } - return $this->collGroups; + return $this->collProfiles; } /** - * Sets a collection of Group objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. + * Sets a collection of Profile objects related by a many-to-many relationship + * to the current object by way of the admin_profile cross-reference table. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $groups A Propel collection. + * @param Collection $profiles A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildAdmin The current object (for fluent API support) */ - public function setGroups(Collection $groups, ConnectionInterface $con = null) + public function setProfiles(Collection $profiles, ConnectionInterface $con = null) { - $this->clearGroups(); - $currentGroups = $this->getGroups(); + $this->clearProfiles(); + $currentProfiles = $this->getProfiles(); - $this->groupsScheduledForDeletion = $currentGroups->diff($groups); + $this->profilesScheduledForDeletion = $currentProfiles->diff($profiles); - foreach ($groups as $group) { - if (!$currentGroups->contains($group)) { - $this->doAddGroup($group); + foreach ($profiles as $profile) { + if (!$currentProfiles->contains($profile)) { + $this->doAddProfile($profile); } } - $this->collGroups = $groups; + $this->collProfiles = $profiles; return $this; } /** - * Gets the number of ChildGroup objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. + * Gets the number of ChildProfile objects related by a many-to-many relationship + * to the current object by way of the admin_profile cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param ConnectionInterface $con Optional connection object * - * @return int the number of related ChildGroup objects + * @return int the number of related ChildProfile objects */ - public function countGroups($criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProfiles($criteria = null, $distinct = false, ConnectionInterface $con = null) { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { + if (null === $this->collProfiles || null !== $criteria) { + if ($this->isNew() && null === $this->collProfiles) { return 0; } else { - $query = ChildGroupQuery::create(null, $criteria); + $query = ChildProfileQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1976,65 +1976,65 @@ abstract class Admin implements ActiveRecordInterface ->count($con); } } else { - return count($this->collGroups); + return count($this->collProfiles); } } /** - * Associate a ChildGroup object to this object - * through the admin_group cross reference table. + * Associate a ChildProfile object to this object + * through the admin_profile cross reference table. * - * @param ChildGroup $group The ChildAdminGroup object to relate + * @param ChildProfile $profile The ChildAdminProfile object to relate * @return ChildAdmin The current object (for fluent API support) */ - public function addGroup(ChildGroup $group) + public function addProfile(ChildProfile $profile) { - if ($this->collGroups === null) { - $this->initGroups(); + if ($this->collProfiles === null) { + $this->initProfiles(); } - if (!$this->collGroups->contains($group)) { // only add it if the **same** object is not already associated - $this->doAddGroup($group); - $this->collGroups[] = $group; + if (!$this->collProfiles->contains($profile)) { // only add it if the **same** object is not already associated + $this->doAddProfile($profile); + $this->collProfiles[] = $profile; } return $this; } /** - * @param Group $group The group object to add. + * @param Profile $profile The profile object to add. */ - protected function doAddGroup($group) + protected function doAddProfile($profile) { - $adminGroup = new ChildAdminGroup(); - $adminGroup->setGroup($group); - $this->addAdminGroup($adminGroup); + $adminProfile = new ChildAdminProfile(); + $adminProfile->setProfile($profile); + $this->addAdminProfile($adminProfile); // set the back reference to this object directly as using provided method either results // in endless loop or in multiple relations - if (!$group->getAdmins()->contains($this)) { - $foreignCollection = $group->getAdmins(); + if (!$profile->getAdmins()->contains($this)) { + $foreignCollection = $profile->getAdmins(); $foreignCollection[] = $this; } } /** - * Remove a ChildGroup object to this object - * through the admin_group cross reference table. + * Remove a ChildProfile object to this object + * through the admin_profile cross reference table. * - * @param ChildGroup $group The ChildAdminGroup object to relate + * @param ChildProfile $profile The ChildAdminProfile object to relate * @return ChildAdmin The current object (for fluent API support) */ - public function removeGroup(ChildGroup $group) + public function removeProfile(ChildProfile $profile) { - if ($this->getGroups()->contains($group)) { - $this->collGroups->remove($this->collGroups->search($group)); + if ($this->getProfiles()->contains($profile)) { + $this->collProfiles->remove($this->collProfiles->search($profile)); - if (null === $this->groupsScheduledForDeletion) { - $this->groupsScheduledForDeletion = clone $this->collGroups; - $this->groupsScheduledForDeletion->clear(); + if (null === $this->profilesScheduledForDeletion) { + $this->profilesScheduledForDeletion = clone $this->collProfiles; + $this->profilesScheduledForDeletion->clear(); } - $this->groupsScheduledForDeletion[] = $group; + $this->profilesScheduledForDeletion[] = $profile; } return $this; @@ -2075,26 +2075,26 @@ abstract class Admin implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collAdminGroups) { - foreach ($this->collAdminGroups as $o) { + if ($this->collAdminProfiles) { + foreach ($this->collAdminProfiles as $o) { $o->clearAllReferences($deep); } } - if ($this->collGroups) { - foreach ($this->collGroups as $o) { + if ($this->collProfiles) { + foreach ($this->collProfiles as $o) { $o->clearAllReferences($deep); } } } // if ($deep) - if ($this->collAdminGroups instanceof Collection) { - $this->collAdminGroups->clearIterator(); + if ($this->collAdminProfiles instanceof Collection) { + $this->collAdminProfiles->clearIterator(); } - $this->collAdminGroups = null; - if ($this->collGroups instanceof Collection) { - $this->collGroups->clearIterator(); + $this->collAdminProfiles = null; + if ($this->collProfiles instanceof Collection) { + $this->collProfiles->clearIterator(); } - $this->collGroups = null; + $this->collProfiles = null; } /** diff --git a/core/lib/Thelia/Model/Base/AdminGroup.php b/core/lib/Thelia/Model/Base/AdminGroup.php deleted file mode 100644 index 663e437a4..000000000 --- a/core/lib/Thelia/Model/Base/AdminGroup.php +++ /dev/null @@ -1,1508 +0,0 @@ -modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return boolean true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another AdminGroup instance. If - * obj is an instance of AdminGroup, delegates to - * equals(AdminGroup). Otherwise, returns false. - * - * @param mixed $obj The object to compare to. - * @return boolean Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @param string $name The virtual column name - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @param string $name The virtual column name - * @return mixed - * - * @throws PropelException - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return AdminGroup The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return AdminGroup The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - - return $this; - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getGroupId() - { - - return $this->group_id; - } - - /** - * Get the [admin_id] column value. - * - * @return int - */ - public function getAdminId() - { - - return $this->admin_id; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\AdminGroup The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = AdminGroupTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return \Thelia\Model\AdminGroup The current object (for fluent API support) - */ - public function setGroupId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = AdminGroupTableMap::GROUP_ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setGroupId() - - /** - * Set the value of [admin_id] column. - * - * @param int $v new value - * @return \Thelia\Model\AdminGroup The current object (for fluent API support) - */ - public function setAdminId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->admin_id !== $v) { - $this->admin_id = $v; - $this->modifiedColumns[] = AdminGroupTableMap::ADMIN_ID; - } - - if ($this->aAdmin !== null && $this->aAdmin->getId() !== $v) { - $this->aAdmin = null; - } - - - return $this; - } // setAdminId() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\AdminGroup The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = AdminGroupTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\AdminGroup The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = AdminGroupTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminGroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminGroupTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->group_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminGroupTableMap::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->admin_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminGroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminGroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 5; // 5 = AdminGroupTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\AdminGroup object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - if ($this->aAdmin !== null && $this->admin_id !== $this->aAdmin->getId()) { - $this->aAdmin = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(AdminGroupTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildAdminGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - $this->aAdmin = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see AdminGroup::setDeleted() - * @see AdminGroup::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildAdminGroupQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(AdminGroupTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - AdminGroupTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->aAdmin !== null) { - if ($this->aAdmin->isModified() || $this->aAdmin->isNew()) { - $affectedRows += $this->aAdmin->save($con); - } - $this->setAdmin($this->aAdmin); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = AdminGroupTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminGroupTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(AdminGroupTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(AdminGroupTableMap::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = 'GROUP_ID'; - } - if ($this->isColumnModified(AdminGroupTableMap::ADMIN_ID)) { - $modifiedColumns[':p' . $index++] = 'ADMIN_ID'; - } - if ($this->isColumnModified(AdminGroupTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO admin_group (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'GROUP_ID': - $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); - break; - case 'ADMIN_ID': - $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT); - break; - case 'CREATED_AT': - $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = AdminGroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getGroupId(); - break; - case 2: - return $this->getAdminId(); - break; - case 3: - return $this->getCreatedAt(); - break; - case 4: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['AdminGroup'][serialize($this->getPrimaryKey())] = true; - $keys = AdminGroupTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getGroupId(), - $keys[2] => $this->getAdminId(), - $keys[3] => $this->getCreatedAt(), - $keys[4] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach ($virtualColumns as $key => $virtualColumn) { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aAdmin) { - $result['Admin'] = $this->aAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = AdminGroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setGroupId($value); - break; - case 2: - $this->setAdminId($value); - break; - case 3: - $this->setCreatedAt($value); - break; - case 4: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = AdminGroupTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setAdminId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(AdminGroupTableMap::DATABASE_NAME); - - if ($this->isColumnModified(AdminGroupTableMap::ID)) $criteria->add(AdminGroupTableMap::ID, $this->id); - if ($this->isColumnModified(AdminGroupTableMap::GROUP_ID)) $criteria->add(AdminGroupTableMap::GROUP_ID, $this->group_id); - if ($this->isColumnModified(AdminGroupTableMap::ADMIN_ID)) $criteria->add(AdminGroupTableMap::ADMIN_ID, $this->admin_id); - if ($this->isColumnModified(AdminGroupTableMap::CREATED_AT)) $criteria->add(AdminGroupTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(AdminGroupTableMap::UPDATED_AT)) $criteria->add(AdminGroupTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(AdminGroupTableMap::DATABASE_NAME); - $criteria->add(AdminGroupTableMap::ID, $this->id); - $criteria->add(AdminGroupTableMap::GROUP_ID, $this->group_id); - $criteria->add(AdminGroupTableMap::ADMIN_ID, $this->admin_id); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getId(); - $pks[1] = $this->getGroupId(); - $pks[2] = $this->getAdminId(); - - return $pks; - } - - /** - * Set the [composite] primary key. - * - * @param array $keys The elements of the composite key (order must match the order in XML file). - * @return void - */ - public function setPrimaryKey($keys) - { - $this->setId($keys[0]); - $this->setGroupId($keys[1]); - $this->setAdminId($keys[2]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getGroupId()) && (null === $this->getAdminId()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\AdminGroup (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setGroupId($this->getGroupId()); - $copyObj->setAdminId($this->getAdminId()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\AdminGroup Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Declares an association between this object and a ChildGroup object. - * - * @param ChildGroup $v - * @return \Thelia\Model\AdminGroup The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(ChildGroup $v = null) - { - if ($v === null) { - $this->setGroupId(NULL); - } else { - $this->setGroupId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildGroup object, it will not be re-added. - if ($v !== null) { - $v->addAdminGroup($this); - } - - - return $this; - } - - - /** - * Get the associated ChildGroup object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildGroup The associated ChildGroup object. - * @throws PropelException - */ - public function getGroup(ConnectionInterface $con = null) - { - if ($this->aGroup === null && ($this->group_id !== null)) { - $this->aGroup = ChildGroupQuery::create()->findPk($this->group_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addAdminGroups($this); - */ - } - - return $this->aGroup; - } - - /** - * Declares an association between this object and a ChildAdmin object. - * - * @param ChildAdmin $v - * @return \Thelia\Model\AdminGroup The current object (for fluent API support) - * @throws PropelException - */ - public function setAdmin(ChildAdmin $v = null) - { - if ($v === null) { - $this->setAdminId(NULL); - } else { - $this->setAdminId($v->getId()); - } - - $this->aAdmin = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildAdmin object, it will not be re-added. - if ($v !== null) { - $v->addAdminGroup($this); - } - - - return $this; - } - - - /** - * Get the associated ChildAdmin object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildAdmin The associated ChildAdmin object. - * @throws PropelException - */ - public function getAdmin(ConnectionInterface $con = null) - { - if ($this->aAdmin === null && ($this->admin_id !== null)) { - $this->aAdmin = ChildAdminQuery::create()->findPk($this->admin_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aAdmin->addAdminGroups($this); - */ - } - - return $this->aAdmin; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->group_id = null; - $this->admin_id = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aGroup = null; - $this->aAdmin = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(AdminGroupTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildAdminGroup The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = AdminGroupTableMap::UPDATED_AT; - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/AdminGroupQuery.php b/core/lib/Thelia/Model/Base/AdminGroupQuery.php deleted file mode 100644 index 8d3353b4c..000000000 --- a/core/lib/Thelia/Model/Base/AdminGroupQuery.php +++ /dev/null @@ -1,778 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34, 56), $con); - * - * - * @param array[$id, $group_id, $admin_id] $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildAdminGroup|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = AdminGroupTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(AdminGroupTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildAdminGroup A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, GROUP_ID, ADMIN_ID, CREATED_AT, UPDATED_AT FROM admin_group WHERE ID = :p0 AND GROUP_ID = :p1 AND ADMIN_ID = :p2'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); - $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildAdminGroup(); - $obj->hydrate($row); - AdminGroupTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildAdminGroup|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(AdminGroupTableMap::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $key[1], Criteria::EQUAL); - $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $key[2], Criteria::EQUAL); - - return $this; - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - if (empty($keys)) { - return $this->add(null, '1<>1', Criteria::CUSTOM); - } - foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(AdminGroupTableMap::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(AdminGroupTableMap::GROUP_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(AdminGroupTableMap::ADMIN_ID, $key[2], Criteria::EQUAL); - $cton0->addAnd($cton2); - $this->addOr($cton0); - } - - return $this; - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(AdminGroupTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(AdminGroupTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the group_id column - * - * Example usage: - * - * $query->filterByGroupId(1234); // WHERE group_id = 1234 - * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 - * - * - * @see filterByGroup() - * - * @param mixed $groupId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByGroupId($groupId = null, $comparison = null) - { - if (is_array($groupId)) { - $useMinMax = false; - if (isset($groupId['min'])) { - $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($groupId['max'])) { - $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupTableMap::GROUP_ID, $groupId, $comparison); - } - - /** - * Filter the query on the admin_id column - * - * Example usage: - * - * $query->filterByAdminId(1234); // WHERE admin_id = 1234 - * $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34) - * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12 - * - * - * @see filterByAdmin() - * - * @param mixed $adminId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByAdminId($adminId = null, $comparison = null) - { - if (is_array($adminId)) { - $useMinMax = false; - if (isset($adminId['min'])) { - $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($adminId['max'])) { - $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $adminId, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Group object - * - * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof \Thelia\Model\Group) { - return $this - ->addUsingAlias(AdminGroupTableMap::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AdminGroupTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Admin object - * - * @param \Thelia\Model\Admin|ObjectCollection $admin The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function filterByAdmin($admin, $comparison = null) - { - if ($admin instanceof \Thelia\Model\Admin) { - return $this - ->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $admin->getId(), $comparison); - } elseif ($admin instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(AdminGroupTableMap::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByAdmin() only accepts arguments of type \Thelia\Model\Admin or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Admin relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function joinAdmin($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Admin'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Admin'); - } - - return $this; - } - - /** - * Use the Admin relation Admin object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AdminQuery A secondary query class using the current class as primary query - */ - public function useAdminQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAdmin($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery'); - } - - /** - * Exclude object from result - * - * @param ChildAdminGroup $adminGroup Object to remove from the list of results - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function prune($adminGroup = null) - { - if ($adminGroup) { - $this->addCond('pruneCond0', $this->getAliasedColName(AdminGroupTableMap::ID), $adminGroup->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(AdminGroupTableMap::GROUP_ID), $adminGroup->getGroupId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond2', $this->getAliasedColName(AdminGroupTableMap::ADMIN_ID), $adminGroup->getAdminId(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); - } - - return $this; - } - - /** - * Deletes all rows from the admin_group table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - AdminGroupTableMap::clearInstancePool(); - AdminGroupTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildAdminGroup or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildAdminGroup object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(AdminGroupTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - AdminGroupTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - AdminGroupTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(AdminGroupTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(AdminGroupTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(AdminGroupTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(AdminGroupTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(AdminGroupTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildAdminGroupQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(AdminGroupTableMap::CREATED_AT); - } - -} // AdminGroupQuery diff --git a/core/lib/Thelia/Model/Base/AdminQuery.php b/core/lib/Thelia/Model/Base/AdminQuery.php index 071832d9b..26ec46381 100644 --- a/core/lib/Thelia/Model/Base/AdminQuery.php +++ b/core/lib/Thelia/Model/Base/AdminQuery.php @@ -49,9 +49,9 @@ use Thelia\Model\Map\AdminTableMap; * @method ChildAdminQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildAdminQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildAdminQuery leftJoinAdminGroup($relationAlias = null) Adds a LEFT JOIN clause to the query using the AdminGroup relation - * @method ChildAdminQuery rightJoinAdminGroup($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AdminGroup relation - * @method ChildAdminQuery innerJoinAdminGroup($relationAlias = null) Adds a INNER JOIN clause to the query using the AdminGroup relation + * @method ChildAdminQuery leftJoinAdminProfile($relationAlias = null) Adds a LEFT JOIN clause to the query using the AdminProfile relation + * @method ChildAdminQuery rightJoinAdminProfile($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AdminProfile relation + * @method ChildAdminQuery innerJoinAdminProfile($relationAlias = null) Adds a INNER JOIN clause to the query using the AdminProfile relation * * @method ChildAdmin findOne(ConnectionInterface $con = null) Return the first ChildAdmin matching the query * @method ChildAdmin findOneOrCreate(ConnectionInterface $con = null) Return the first ChildAdmin matching the query, or a new ChildAdmin object populated from the query conditions when no match is found @@ -616,40 +616,40 @@ abstract class AdminQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\AdminGroup object + * Filter the query by a related \Thelia\Model\AdminProfile object * - * @param \Thelia\Model\AdminGroup|ObjectCollection $adminGroup the related object to use as filter + * @param \Thelia\Model\AdminProfile|ObjectCollection $adminProfile the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAdminQuery The current query, for fluid interface */ - public function filterByAdminGroup($adminGroup, $comparison = null) + public function filterByAdminProfile($adminProfile, $comparison = null) { - if ($adminGroup instanceof \Thelia\Model\AdminGroup) { + if ($adminProfile instanceof \Thelia\Model\AdminProfile) { return $this - ->addUsingAlias(AdminTableMap::ID, $adminGroup->getAdminId(), $comparison); - } elseif ($adminGroup instanceof ObjectCollection) { + ->addUsingAlias(AdminTableMap::ID, $adminProfile->getAdminId(), $comparison); + } elseif ($adminProfile instanceof ObjectCollection) { return $this - ->useAdminGroupQuery() - ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) + ->useAdminProfileQuery() + ->filterByPrimaryKeys($adminProfile->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByAdminGroup() only accepts arguments of type \Thelia\Model\AdminGroup or Collection'); + throw new PropelException('filterByAdminProfile() only accepts arguments of type \Thelia\Model\AdminProfile or Collection'); } } /** - * Adds a JOIN clause to the query using the AdminGroup relation + * Adds a JOIN clause to the query using the AdminProfile relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildAdminQuery The current query, for fluid interface */ - public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinAdminProfile($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AdminGroup'); + $relationMap = $tableMap->getRelation('AdminProfile'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -664,14 +664,14 @@ abstract class AdminQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'AdminGroup'); + $this->addJoinObject($join, 'AdminProfile'); } return $this; } /** - * Use the AdminGroup relation AdminGroup object + * Use the AdminProfile relation AdminProfile object * * @see useQuery() * @@ -679,29 +679,29 @@ abstract class AdminQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\AdminProfileQuery A secondary query class using the current class as primary query */ - public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useAdminProfileQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinAdminGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery'); + ->joinAdminProfile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AdminProfile', '\Thelia\Model\AdminProfileQuery'); } /** - * Filter the query by a related Group object - * using the admin_group table as cross reference + * Filter the query by a related Profile object + * using the admin_profile table as cross reference * - * @param Group $group the related object to use as filter + * @param Profile $profile the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildAdminQuery The current query, for fluid interface */ - public function filterByGroup($group, $comparison = Criteria::EQUAL) + public function filterByProfile($profile, $comparison = Criteria::EQUAL) { return $this - ->useAdminGroupQuery() - ->filterByGroup($group, $comparison) + ->useAdminProfileQuery() + ->filterByProfile($profile, $comparison) ->endUse(); } diff --git a/core/lib/Thelia/Model/Base/Group.php b/core/lib/Thelia/Model/Base/Group.php deleted file mode 100644 index 751111952..000000000 --- a/core/lib/Thelia/Model/Base/Group.php +++ /dev/null @@ -1,3158 +0,0 @@ -modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return boolean true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another Group instance. If - * obj is an instance of Group, delegates to - * equals(Group). Otherwise, returns false. - * - * @param mixed $obj The object to compare to. - * @return boolean Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @param string $name The virtual column name - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @param string $name The virtual column name - * @return mixed - * - * @throws PropelException - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return Group The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return Group The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - - return $this; - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [code] column value. - * - * @return string - */ - public function getCode() - { - - return $this->code; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [code] column. - * - * @param string $v new value - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function setCode($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->code !== $v) { - $this->code = $v; - $this->modifiedColumns[] = GroupTableMap::CODE; - } - - - return $this; - } // setCode() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = GroupTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = GroupTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; - $this->code = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 4; // 4 = GroupTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\Group object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildGroupQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->collAdminGroups = null; - - $this->collGroupResources = null; - - $this->collGroupModules = null; - - $this->collGroupI18ns = null; - - $this->collAdmins = null; - $this->collResources = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see Group::setDeleted() - * @see Group::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildGroupQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(GroupTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(GroupTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(GroupTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - GroupTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - if ($this->adminsScheduledForDeletion !== null) { - if (!$this->adminsScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->adminsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - - AdminGroupQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->adminsScheduledForDeletion = null; - } - - foreach ($this->getAdmins() as $admin) { - if ($admin->isModified()) { - $admin->save($con); - } - } - } elseif ($this->collAdmins) { - foreach ($this->collAdmins as $admin) { - if ($admin->isModified()) { - $admin->save($con); - } - } - } - - if ($this->resourcesScheduledForDeletion !== null) { - if (!$this->resourcesScheduledForDeletion->isEmpty()) { - $pks = array(); - $pk = $this->getPrimaryKey(); - foreach ($this->resourcesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { - $pks[] = array($pk, $remotePk); - } - - GroupResourceQuery::create() - ->filterByPrimaryKeys($pks) - ->delete($con); - $this->resourcesScheduledForDeletion = null; - } - - foreach ($this->getResources() as $resource) { - if ($resource->isModified()) { - $resource->save($con); - } - } - } elseif ($this->collResources) { - foreach ($this->collResources as $resource) { - if ($resource->isModified()) { - $resource->save($con); - } - } - } - - if ($this->adminGroupsScheduledForDeletion !== null) { - if (!$this->adminGroupsScheduledForDeletion->isEmpty()) { - \Thelia\Model\AdminGroupQuery::create() - ->filterByPrimaryKeys($this->adminGroupsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->adminGroupsScheduledForDeletion = null; - } - } - - if ($this->collAdminGroups !== null) { - foreach ($this->collAdminGroups as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->groupResourcesScheduledForDeletion !== null) { - if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - \Thelia\Model\GroupResourceQuery::create() - ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupResourcesScheduledForDeletion = null; - } - } - - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->groupModulesScheduledForDeletion !== null) { - if (!$this->groupModulesScheduledForDeletion->isEmpty()) { - \Thelia\Model\GroupModuleQuery::create() - ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupModulesScheduledForDeletion = null; - } - } - - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - if ($this->groupI18nsScheduledForDeletion !== null) { - if (!$this->groupI18nsScheduledForDeletion->isEmpty()) { - \Thelia\Model\GroupI18nQuery::create() - ->filterByPrimaryKeys($this->groupI18nsScheduledForDeletion->getPrimaryKeys(false)) - ->delete($con); - $this->groupI18nsScheduledForDeletion = null; - } - } - - if ($this->collGroupI18ns !== null) { - foreach ($this->collGroupI18ns as $referrerFK) { - if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { - $affectedRows += $referrerFK->save($con); - } - } - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = GroupTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(GroupTableMap::CODE)) { - $modifiedColumns[':p' . $index++] = 'CODE'; - } - if ($this->isColumnModified(GroupTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(GroupTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO group (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'CODE': - $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); - break; - case 'CREATED_AT': - $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getCode(); - break; - case 2: - return $this->getCreatedAt(); - break; - case 3: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['Group'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['Group'][$this->getPrimaryKey()] = true; - $keys = GroupTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getCode(), - $keys[2] => $this->getCreatedAt(), - $keys[3] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach ($virtualColumns as $key => $virtualColumn) { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->collAdminGroups) { - $result['AdminGroups'] = $this->collAdminGroups->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collGroupResources) { - $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collGroupModules) { - $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - if (null !== $this->collGroupI18ns) { - $result['GroupI18ns'] = $this->collGroupI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setCode($value); - break; - case 2: - $this->setCreatedAt($value); - break; - case 3: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = GroupTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupTableMap::DATABASE_NAME); - - if ($this->isColumnModified(GroupTableMap::ID)) $criteria->add(GroupTableMap::ID, $this->id); - if ($this->isColumnModified(GroupTableMap::CODE)) $criteria->add(GroupTableMap::CODE, $this->code); - if ($this->isColumnModified(GroupTableMap::CREATED_AT)) $criteria->add(GroupTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(GroupTableMap::UPDATED_AT)) $criteria->add(GroupTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(GroupTableMap::DATABASE_NAME); - $criteria->add(GroupTableMap::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\Group (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setCode($this->getCode()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - - if ($deepCopy) { - // important: temporarily setNew(false) because this affects the behavior of - // the getter/setter methods for fkey referrer objects. - $copyObj->setNew(false); - - foreach ($this->getAdminGroups() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addAdminGroup($relObj->copy($deepCopy)); - } - } - - foreach ($this->getGroupResources() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupResource($relObj->copy($deepCopy)); - } - } - - foreach ($this->getGroupModules() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupModule($relObj->copy($deepCopy)); - } - } - - foreach ($this->getGroupI18ns() as $relObj) { - if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupI18n($relObj->copy($deepCopy)); - } - } - - } // if ($deepCopy) - - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\Group Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - - /** - * Initializes a collection based on the name of a relation. - * Avoids crafting an 'init[$relationName]s' method name - * that wouldn't work when StandardEnglishPluralizer is used. - * - * @param string $relationName The name of the relation to initialize - * @return void - */ - public function initRelation($relationName) - { - if ('AdminGroup' == $relationName) { - return $this->initAdminGroups(); - } - if ('GroupResource' == $relationName) { - return $this->initGroupResources(); - } - if ('GroupModule' == $relationName) { - return $this->initGroupModules(); - } - if ('GroupI18n' == $relationName) { - return $this->initGroupI18ns(); - } - } - - /** - * Clears out the collAdminGroups collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addAdminGroups() - */ - public function clearAdminGroups() - { - $this->collAdminGroups = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collAdminGroups collection loaded partially. - */ - public function resetPartialAdminGroups($v = true) - { - $this->collAdminGroupsPartial = $v; - } - - /** - * Initializes the collAdminGroups collection. - * - * By default this just sets the collAdminGroups collection to an empty array (like clearcollAdminGroups()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initAdminGroups($overrideExisting = true) - { - if (null !== $this->collAdminGroups && !$overrideExisting) { - return; - } - $this->collAdminGroups = new ObjectCollection(); - $this->collAdminGroups->setModel('\Thelia\Model\AdminGroup'); - } - - /** - * Gets an array of ChildAdminGroup objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildGroup is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects - * @throws PropelException - */ - public function getAdminGroups($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { - // return empty collection - $this->initAdminGroups(); - } else { - $collAdminGroups = ChildAdminGroupQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collAdminGroupsPartial && count($collAdminGroups)) { - $this->initAdminGroups(false); - - foreach ($collAdminGroups as $obj) { - if (false == $this->collAdminGroups->contains($obj)) { - $this->collAdminGroups->append($obj); - } - } - - $this->collAdminGroupsPartial = true; - } - - $collAdminGroups->getInternalIterator()->rewind(); - - return $collAdminGroups; - } - - if ($partial && $this->collAdminGroups) { - foreach ($this->collAdminGroups as $obj) { - if ($obj->isNew()) { - $collAdminGroups[] = $obj; - } - } - } - - $this->collAdminGroups = $collAdminGroups; - $this->collAdminGroupsPartial = false; - } - } - - return $this->collAdminGroups; - } - - /** - * Sets a collection of AdminGroup objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $adminGroups A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildGroup The current object (for fluent API support) - */ - public function setAdminGroups(Collection $adminGroups, ConnectionInterface $con = null) - { - $adminGroupsToDelete = $this->getAdminGroups(new Criteria(), $con)->diff($adminGroups); - - - //since at least one column in the foreign key is at the same time a PK - //we can not just set a PK to NULL in the lines below. We have to store - //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->adminGroupsScheduledForDeletion = clone $adminGroupsToDelete; - - foreach ($adminGroupsToDelete as $adminGroupRemoved) { - $adminGroupRemoved->setGroup(null); - } - - $this->collAdminGroups = null; - foreach ($adminGroups as $adminGroup) { - $this->addAdminGroup($adminGroup); - } - - $this->collAdminGroups = $adminGroups; - $this->collAdminGroupsPartial = false; - - return $this; - } - - /** - * Returns the number of related AdminGroup objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related AdminGroup objects. - * @throws PropelException - */ - public function countAdminGroups(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collAdminGroupsPartial && !$this->isNew(); - if (null === $this->collAdminGroups || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collAdminGroups) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getAdminGroups()); - } - - $query = ChildAdminGroupQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collAdminGroups); - } - - /** - * Method called to associate a ChildAdminGroup object to this object - * through the ChildAdminGroup foreign key attribute. - * - * @param ChildAdminGroup $l ChildAdminGroup - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function addAdminGroup(ChildAdminGroup $l) - { - if ($this->collAdminGroups === null) { - $this->initAdminGroups(); - $this->collAdminGroupsPartial = true; - } - - if (!in_array($l, $this->collAdminGroups->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddAdminGroup($l); - } - - return $this; - } - - /** - * @param AdminGroup $adminGroup The adminGroup object to add. - */ - protected function doAddAdminGroup($adminGroup) - { - $this->collAdminGroups[]= $adminGroup; - $adminGroup->setGroup($this); - } - - /** - * @param AdminGroup $adminGroup The adminGroup object to remove. - * @return ChildGroup The current object (for fluent API support) - */ - public function removeAdminGroup($adminGroup) - { - if ($this->getAdminGroups()->contains($adminGroup)) { - $this->collAdminGroups->remove($this->collAdminGroups->search($adminGroup)); - if (null === $this->adminGroupsScheduledForDeletion) { - $this->adminGroupsScheduledForDeletion = clone $this->collAdminGroups; - $this->adminGroupsScheduledForDeletion->clear(); - } - $this->adminGroupsScheduledForDeletion[]= clone $adminGroup; - $adminGroup->setGroup(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Group is new, it will return - * an empty collection; or if this Group has previously - * been saved, it will retrieve related AdminGroups from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Group. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildAdminGroup[] List of ChildAdminGroup objects - */ - public function getAdminGroupsJoinAdmin($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildAdminGroupQuery::create(null, $criteria); - $query->joinWith('Admin', $joinBehavior); - - return $this->getAdminGroups($query, $con); - } - - /** - * Clears out the collGroupResources collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addGroupResources() - */ - public function clearGroupResources() - { - $this->collGroupResources = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collGroupResources collection loaded partially. - */ - public function resetPartialGroupResources($v = true) - { - $this->collGroupResourcesPartial = $v; - } - - /** - * Initializes the collGroupResources collection. - * - * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupResources($overrideExisting = true) - { - if (null !== $this->collGroupResources && !$overrideExisting) { - return; - } - $this->collGroupResources = new ObjectCollection(); - $this->collGroupResources->setModel('\Thelia\Model\GroupResource'); - } - - /** - * Gets an array of ChildGroupResource objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildGroup is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildGroupResource[] List of ChildGroupResource objects - * @throws PropelException - */ - public function getGroupResources($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { - // return empty collection - $this->initGroupResources(); - } else { - $collGroupResources = ChildGroupResourceQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { - $this->initGroupResources(false); - - foreach ($collGroupResources as $obj) { - if (false == $this->collGroupResources->contains($obj)) { - $this->collGroupResources->append($obj); - } - } - - $this->collGroupResourcesPartial = true; - } - - $collGroupResources->getInternalIterator()->rewind(); - - return $collGroupResources; - } - - if ($partial && $this->collGroupResources) { - foreach ($this->collGroupResources as $obj) { - if ($obj->isNew()) { - $collGroupResources[] = $obj; - } - } - } - - $this->collGroupResources = $collGroupResources; - $this->collGroupResourcesPartial = false; - } - } - - return $this->collGroupResources; - } - - /** - * Sets a collection of GroupResource objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $groupResources A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildGroup The current object (for fluent API support) - */ - public function setGroupResources(Collection $groupResources, ConnectionInterface $con = null) - { - $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); - - - //since at least one column in the foreign key is at the same time a PK - //we can not just set a PK to NULL in the lines below. We have to store - //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->groupResourcesScheduledForDeletion = clone $groupResourcesToDelete; - - foreach ($groupResourcesToDelete as $groupResourceRemoved) { - $groupResourceRemoved->setGroup(null); - } - - $this->collGroupResources = null; - foreach ($groupResources as $groupResource) { - $this->addGroupResource($groupResource); - } - - $this->collGroupResources = $groupResources; - $this->collGroupResourcesPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupResource objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related GroupResource objects. - * @throws PropelException - */ - public function countGroupResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getGroupResources()); - } - - $query = ChildGroupResourceQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collGroupResources); - } - - /** - * Method called to associate a ChildGroupResource object to this object - * through the ChildGroupResource foreign key attribute. - * - * @param ChildGroupResource $l ChildGroupResource - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function addGroupResource(ChildGroupResource $l) - { - if ($this->collGroupResources === null) { - $this->initGroupResources(); - $this->collGroupResourcesPartial = true; - } - - if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupResource($l); - } - - return $this; - } - - /** - * @param GroupResource $groupResource The groupResource object to add. - */ - protected function doAddGroupResource($groupResource) - { - $this->collGroupResources[]= $groupResource; - $groupResource->setGroup($this); - } - - /** - * @param GroupResource $groupResource The groupResource object to remove. - * @return ChildGroup The current object (for fluent API support) - */ - public function removeGroupResource($groupResource) - { - if ($this->getGroupResources()->contains($groupResource)) { - $this->collGroupResources->remove($this->collGroupResources->search($groupResource)); - if (null === $this->groupResourcesScheduledForDeletion) { - $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; - $this->groupResourcesScheduledForDeletion->clear(); - } - $this->groupResourcesScheduledForDeletion[]= clone $groupResource; - $groupResource->setGroup(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Group is new, it will return - * an empty collection; or if this Group has previously - * been saved, it will retrieve related GroupResources from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Group. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildGroupResource[] List of ChildGroupResource objects - */ - public function getGroupResourcesJoinResource($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildGroupResourceQuery::create(null, $criteria); - $query->joinWith('Resource', $joinBehavior); - - return $this->getGroupResources($query, $con); - } - - /** - * Clears out the collGroupModules collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addGroupModules() - */ - public function clearGroupModules() - { - $this->collGroupModules = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collGroupModules collection loaded partially. - */ - public function resetPartialGroupModules($v = true) - { - $this->collGroupModulesPartial = $v; - } - - /** - * Initializes the collGroupModules collection. - * - * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupModules($overrideExisting = true) - { - if (null !== $this->collGroupModules && !$overrideExisting) { - return; - } - $this->collGroupModules = new ObjectCollection(); - $this->collGroupModules->setModel('\Thelia\Model\GroupModule'); - } - - /** - * Gets an array of ChildGroupModule objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildGroup is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildGroupModule[] List of ChildGroupModule objects - * @throws PropelException - */ - public function getGroupModules($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { - // return empty collection - $this->initGroupModules(); - } else { - $collGroupModules = ChildGroupModuleQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collGroupModulesPartial && count($collGroupModules)) { - $this->initGroupModules(false); - - foreach ($collGroupModules as $obj) { - if (false == $this->collGroupModules->contains($obj)) { - $this->collGroupModules->append($obj); - } - } - - $this->collGroupModulesPartial = true; - } - - $collGroupModules->getInternalIterator()->rewind(); - - return $collGroupModules; - } - - if ($partial && $this->collGroupModules) { - foreach ($this->collGroupModules as $obj) { - if ($obj->isNew()) { - $collGroupModules[] = $obj; - } - } - } - - $this->collGroupModules = $collGroupModules; - $this->collGroupModulesPartial = false; - } - } - - return $this->collGroupModules; - } - - /** - * Sets a collection of GroupModule objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $groupModules A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildGroup The current object (for fluent API support) - */ - public function setGroupModules(Collection $groupModules, ConnectionInterface $con = null) - { - $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); - - - $this->groupModulesScheduledForDeletion = $groupModulesToDelete; - - foreach ($groupModulesToDelete as $groupModuleRemoved) { - $groupModuleRemoved->setGroup(null); - } - - $this->collGroupModules = null; - foreach ($groupModules as $groupModule) { - $this->addGroupModule($groupModule); - } - - $this->collGroupModules = $groupModules; - $this->collGroupModulesPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupModule objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related GroupModule objects. - * @throws PropelException - */ - public function countGroupModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getGroupModules()); - } - - $query = ChildGroupModuleQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collGroupModules); - } - - /** - * Method called to associate a ChildGroupModule object to this object - * through the ChildGroupModule foreign key attribute. - * - * @param ChildGroupModule $l ChildGroupModule - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function addGroupModule(ChildGroupModule $l) - { - if ($this->collGroupModules === null) { - $this->initGroupModules(); - $this->collGroupModulesPartial = true; - } - - if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupModule($l); - } - - return $this; - } - - /** - * @param GroupModule $groupModule The groupModule object to add. - */ - protected function doAddGroupModule($groupModule) - { - $this->collGroupModules[]= $groupModule; - $groupModule->setGroup($this); - } - - /** - * @param GroupModule $groupModule The groupModule object to remove. - * @return ChildGroup The current object (for fluent API support) - */ - public function removeGroupModule($groupModule) - { - if ($this->getGroupModules()->contains($groupModule)) { - $this->collGroupModules->remove($this->collGroupModules->search($groupModule)); - if (null === $this->groupModulesScheduledForDeletion) { - $this->groupModulesScheduledForDeletion = clone $this->collGroupModules; - $this->groupModulesScheduledForDeletion->clear(); - } - $this->groupModulesScheduledForDeletion[]= clone $groupModule; - $groupModule->setGroup(null); - } - - return $this; - } - - - /** - * If this collection has already been initialized with - * an identical criteria, it returns the collection. - * Otherwise if this Group is new, it will return - * an empty collection; or if this Group has previously - * been saved, it will retrieve related GroupModules from storage. - * - * This method is protected by default in order to keep the public - * api reasonable. You can provide public methods for those you - * actually need in Group. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildGroupModule[] List of ChildGroupModule objects - */ - public function getGroupModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) - { - $query = ChildGroupModuleQuery::create(null, $criteria); - $query->joinWith('Module', $joinBehavior); - - return $this->getGroupModules($query, $con); - } - - /** - * Clears out the collGroupI18ns collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addGroupI18ns() - */ - public function clearGroupI18ns() - { - $this->collGroupI18ns = null; // important to set this to NULL since that means it is uninitialized - } - - /** - * Reset is the collGroupI18ns collection loaded partially. - */ - public function resetPartialGroupI18ns($v = true) - { - $this->collGroupI18nsPartial = $v; - } - - /** - * Initializes the collGroupI18ns collection. - * - * By default this just sets the collGroupI18ns collection to an empty array (like clearcollGroupI18ns()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @param boolean $overrideExisting If set to true, the method call initializes - * the collection even if it is not empty - * - * @return void - */ - public function initGroupI18ns($overrideExisting = true) - { - if (null !== $this->collGroupI18ns && !$overrideExisting) { - return; - } - $this->collGroupI18ns = new ObjectCollection(); - $this->collGroupI18ns->setModel('\Thelia\Model\GroupI18n'); - } - - /** - * Gets an array of ChildGroupI18n objects which contain a foreign key that references this object. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildGroup is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria optional Criteria object to narrow the query - * @param ConnectionInterface $con optional connection object - * @return Collection|ChildGroupI18n[] List of ChildGroupI18n objects - * @throws PropelException - */ - public function getGroupI18ns($criteria = null, ConnectionInterface $con = null) - { - $partial = $this->collGroupI18nsPartial && !$this->isNew(); - if (null === $this->collGroupI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupI18ns) { - // return empty collection - $this->initGroupI18ns(); - } else { - $collGroupI18ns = ChildGroupI18nQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - - if (null !== $criteria) { - if (false !== $this->collGroupI18nsPartial && count($collGroupI18ns)) { - $this->initGroupI18ns(false); - - foreach ($collGroupI18ns as $obj) { - if (false == $this->collGroupI18ns->contains($obj)) { - $this->collGroupI18ns->append($obj); - } - } - - $this->collGroupI18nsPartial = true; - } - - $collGroupI18ns->getInternalIterator()->rewind(); - - return $collGroupI18ns; - } - - if ($partial && $this->collGroupI18ns) { - foreach ($this->collGroupI18ns as $obj) { - if ($obj->isNew()) { - $collGroupI18ns[] = $obj; - } - } - } - - $this->collGroupI18ns = $collGroupI18ns; - $this->collGroupI18nsPartial = false; - } - } - - return $this->collGroupI18ns; - } - - /** - * Sets a collection of GroupI18n objects related by a one-to-many relationship - * to the current object. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $groupI18ns A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildGroup The current object (for fluent API support) - */ - public function setGroupI18ns(Collection $groupI18ns, ConnectionInterface $con = null) - { - $groupI18nsToDelete = $this->getGroupI18ns(new Criteria(), $con)->diff($groupI18ns); - - - //since at least one column in the foreign key is at the same time a PK - //we can not just set a PK to NULL in the lines below. We have to store - //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->groupI18nsScheduledForDeletion = clone $groupI18nsToDelete; - - foreach ($groupI18nsToDelete as $groupI18nRemoved) { - $groupI18nRemoved->setGroup(null); - } - - $this->collGroupI18ns = null; - foreach ($groupI18ns as $groupI18n) { - $this->addGroupI18n($groupI18n); - } - - $this->collGroupI18ns = $groupI18ns; - $this->collGroupI18nsPartial = false; - - return $this; - } - - /** - * Returns the number of related GroupI18n objects. - * - * @param Criteria $criteria - * @param boolean $distinct - * @param ConnectionInterface $con - * @return int Count of related GroupI18n objects. - * @throws PropelException - */ - public function countGroupI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) - { - $partial = $this->collGroupI18nsPartial && !$this->isNew(); - if (null === $this->collGroupI18ns || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupI18ns) { - return 0; - } - - if ($partial && !$criteria) { - return count($this->getGroupI18ns()); - } - - $query = ChildGroupI18nQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - - return count($this->collGroupI18ns); - } - - /** - * Method called to associate a ChildGroupI18n object to this object - * through the ChildGroupI18n foreign key attribute. - * - * @param ChildGroupI18n $l ChildGroupI18n - * @return \Thelia\Model\Group The current object (for fluent API support) - */ - public function addGroupI18n(ChildGroupI18n $l) - { - if ($l && $locale = $l->getLocale()) { - $this->setLocale($locale); - $this->currentTranslations[$locale] = $l; - } - if ($this->collGroupI18ns === null) { - $this->initGroupI18ns(); - $this->collGroupI18nsPartial = true; - } - - if (!in_array($l, $this->collGroupI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupI18n($l); - } - - return $this; - } - - /** - * @param GroupI18n $groupI18n The groupI18n object to add. - */ - protected function doAddGroupI18n($groupI18n) - { - $this->collGroupI18ns[]= $groupI18n; - $groupI18n->setGroup($this); - } - - /** - * @param GroupI18n $groupI18n The groupI18n object to remove. - * @return ChildGroup The current object (for fluent API support) - */ - public function removeGroupI18n($groupI18n) - { - if ($this->getGroupI18ns()->contains($groupI18n)) { - $this->collGroupI18ns->remove($this->collGroupI18ns->search($groupI18n)); - if (null === $this->groupI18nsScheduledForDeletion) { - $this->groupI18nsScheduledForDeletion = clone $this->collGroupI18ns; - $this->groupI18nsScheduledForDeletion->clear(); - } - $this->groupI18nsScheduledForDeletion[]= clone $groupI18n; - $groupI18n->setGroup(null); - } - - return $this; - } - - /** - * Clears out the collAdmins collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addAdmins() - */ - public function clearAdmins() - { - $this->collAdmins = null; // important to set this to NULL since that means it is uninitialized - $this->collAdminsPartial = null; - } - - /** - * Initializes the collAdmins collection. - * - * By default this just sets the collAdmins collection to an empty collection (like clearAdmins()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @return void - */ - public function initAdmins() - { - $this->collAdmins = new ObjectCollection(); - $this->collAdmins->setModel('\Thelia\Model\Admin'); - } - - /** - * Gets a collection of ChildAdmin objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildGroup is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param ConnectionInterface $con Optional connection object - * - * @return ObjectCollection|ChildAdmin[] List of ChildAdmin objects - */ - public function getAdmins($criteria = null, ConnectionInterface $con = null) - { - if (null === $this->collAdmins || null !== $criteria) { - if ($this->isNew() && null === $this->collAdmins) { - // return empty collection - $this->initAdmins(); - } else { - $collAdmins = ChildAdminQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - return $collAdmins; - } - $this->collAdmins = $collAdmins; - } - } - - return $this->collAdmins; - } - - /** - * Sets a collection of Admin objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $admins A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildGroup The current object (for fluent API support) - */ - public function setAdmins(Collection $admins, ConnectionInterface $con = null) - { - $this->clearAdmins(); - $currentAdmins = $this->getAdmins(); - - $this->adminsScheduledForDeletion = $currentAdmins->diff($admins); - - foreach ($admins as $admin) { - if (!$currentAdmins->contains($admin)) { - $this->doAddAdmin($admin); - } - } - - $this->collAdmins = $admins; - - return $this; - } - - /** - * Gets the number of ChildAdmin objects related by a many-to-many relationship - * to the current object by way of the admin_group cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param ConnectionInterface $con Optional connection object - * - * @return int the number of related ChildAdmin objects - */ - public function countAdmins($criteria = null, $distinct = false, ConnectionInterface $con = null) - { - if (null === $this->collAdmins || null !== $criteria) { - if ($this->isNew() && null === $this->collAdmins) { - return 0; - } else { - $query = ChildAdminQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - } else { - return count($this->collAdmins); - } - } - - /** - * Associate a ChildAdmin object to this object - * through the admin_group cross reference table. - * - * @param ChildAdmin $admin The ChildAdminGroup object to relate - * @return ChildGroup The current object (for fluent API support) - */ - public function addAdmin(ChildAdmin $admin) - { - if ($this->collAdmins === null) { - $this->initAdmins(); - } - - if (!$this->collAdmins->contains($admin)) { // only add it if the **same** object is not already associated - $this->doAddAdmin($admin); - $this->collAdmins[] = $admin; - } - - return $this; - } - - /** - * @param Admin $admin The admin object to add. - */ - protected function doAddAdmin($admin) - { - $adminGroup = new ChildAdminGroup(); - $adminGroup->setAdmin($admin); - $this->addAdminGroup($adminGroup); - // set the back reference to this object directly as using provided method either results - // in endless loop or in multiple relations - if (!$admin->getGroups()->contains($this)) { - $foreignCollection = $admin->getGroups(); - $foreignCollection[] = $this; - } - } - - /** - * Remove a ChildAdmin object to this object - * through the admin_group cross reference table. - * - * @param ChildAdmin $admin The ChildAdminGroup object to relate - * @return ChildGroup The current object (for fluent API support) - */ - public function removeAdmin(ChildAdmin $admin) - { - if ($this->getAdmins()->contains($admin)) { - $this->collAdmins->remove($this->collAdmins->search($admin)); - - if (null === $this->adminsScheduledForDeletion) { - $this->adminsScheduledForDeletion = clone $this->collAdmins; - $this->adminsScheduledForDeletion->clear(); - } - - $this->adminsScheduledForDeletion[] = $admin; - } - - return $this; - } - - /** - * Clears out the collResources collection - * - * This does not modify the database; however, it will remove any associated objects, causing - * them to be refetched by subsequent calls to accessor method. - * - * @return void - * @see addResources() - */ - public function clearResources() - { - $this->collResources = null; // important to set this to NULL since that means it is uninitialized - $this->collResourcesPartial = null; - } - - /** - * Initializes the collResources collection. - * - * By default this just sets the collResources collection to an empty collection (like clearResources()); - * however, you may wish to override this method in your stub class to provide setting appropriate - * to your application -- for example, setting the initial array to the values stored in database. - * - * @return void - */ - public function initResources() - { - $this->collResources = new ObjectCollection(); - $this->collResources->setModel('\Thelia\Model\Resource'); - } - - /** - * Gets a collection of ChildResource objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * - * If the $criteria is not null, it is used to always fetch the results from the database. - * Otherwise the results are fetched from the database the first time, then cached. - * Next time the same method is called without $criteria, the cached collection is returned. - * If this ChildGroup is new, it will return - * an empty collection or the current collection; the criteria is ignored on a new object. - * - * @param Criteria $criteria Optional query object to filter the query - * @param ConnectionInterface $con Optional connection object - * - * @return ObjectCollection|ChildResource[] List of ChildResource objects - */ - public function getResources($criteria = null, ConnectionInterface $con = null) - { - if (null === $this->collResources || null !== $criteria) { - if ($this->isNew() && null === $this->collResources) { - // return empty collection - $this->initResources(); - } else { - $collResources = ChildResourceQuery::create(null, $criteria) - ->filterByGroup($this) - ->find($con); - if (null !== $criteria) { - return $collResources; - } - $this->collResources = $collResources; - } - } - - return $this->collResources; - } - - /** - * Sets a collection of Resource objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * It will also schedule objects for deletion based on a diff between old objects (aka persisted) - * and new objects from the given Propel collection. - * - * @param Collection $resources A Propel collection. - * @param ConnectionInterface $con Optional connection object - * @return ChildGroup The current object (for fluent API support) - */ - public function setResources(Collection $resources, ConnectionInterface $con = null) - { - $this->clearResources(); - $currentResources = $this->getResources(); - - $this->resourcesScheduledForDeletion = $currentResources->diff($resources); - - foreach ($resources as $resource) { - if (!$currentResources->contains($resource)) { - $this->doAddResource($resource); - } - } - - $this->collResources = $resources; - - return $this; - } - - /** - * Gets the number of ChildResource objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. - * - * @param Criteria $criteria Optional query object to filter the query - * @param boolean $distinct Set to true to force count distinct - * @param ConnectionInterface $con Optional connection object - * - * @return int the number of related ChildResource objects - */ - public function countResources($criteria = null, $distinct = false, ConnectionInterface $con = null) - { - if (null === $this->collResources || null !== $criteria) { - if ($this->isNew() && null === $this->collResources) { - return 0; - } else { - $query = ChildResourceQuery::create(null, $criteria); - if ($distinct) { - $query->distinct(); - } - - return $query - ->filterByGroup($this) - ->count($con); - } - } else { - return count($this->collResources); - } - } - - /** - * Associate a ChildResource object to this object - * through the group_resource cross reference table. - * - * @param ChildResource $resource The ChildGroupResource object to relate - * @return ChildGroup The current object (for fluent API support) - */ - public function addResource(ChildResource $resource) - { - if ($this->collResources === null) { - $this->initResources(); - } - - if (!$this->collResources->contains($resource)) { // only add it if the **same** object is not already associated - $this->doAddResource($resource); - $this->collResources[] = $resource; - } - - return $this; - } - - /** - * @param Resource $resource The resource object to add. - */ - protected function doAddResource($resource) - { - $groupResource = new ChildGroupResource(); - $groupResource->setResource($resource); - $this->addGroupResource($groupResource); - // set the back reference to this object directly as using provided method either results - // in endless loop or in multiple relations - if (!$resource->getGroups()->contains($this)) { - $foreignCollection = $resource->getGroups(); - $foreignCollection[] = $this; - } - } - - /** - * Remove a ChildResource object to this object - * through the group_resource cross reference table. - * - * @param ChildResource $resource The ChildGroupResource object to relate - * @return ChildGroup The current object (for fluent API support) - */ - public function removeResource(ChildResource $resource) - { - if ($this->getResources()->contains($resource)) { - $this->collResources->remove($this->collResources->search($resource)); - - if (null === $this->resourcesScheduledForDeletion) { - $this->resourcesScheduledForDeletion = clone $this->collResources; - $this->resourcesScheduledForDeletion->clear(); - } - - $this->resourcesScheduledForDeletion[] = $resource; - } - - return $this; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->code = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - if ($this->collAdminGroups) { - foreach ($this->collAdminGroups as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroupResources) { - foreach ($this->collGroupResources as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroupModules) { - foreach ($this->collGroupModules as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collGroupI18ns) { - foreach ($this->collGroupI18ns as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collAdmins) { - foreach ($this->collAdmins as $o) { - $o->clearAllReferences($deep); - } - } - if ($this->collResources) { - foreach ($this->collResources as $o) { - $o->clearAllReferences($deep); - } - } - } // if ($deep) - - // i18n behavior - $this->currentLocale = 'en_US'; - $this->currentTranslations = null; - - if ($this->collAdminGroups instanceof Collection) { - $this->collAdminGroups->clearIterator(); - } - $this->collAdminGroups = null; - if ($this->collGroupResources instanceof Collection) { - $this->collGroupResources->clearIterator(); - } - $this->collGroupResources = null; - if ($this->collGroupModules instanceof Collection) { - $this->collGroupModules->clearIterator(); - } - $this->collGroupModules = null; - if ($this->collGroupI18ns instanceof Collection) { - $this->collGroupI18ns->clearIterator(); - } - $this->collGroupI18ns = null; - if ($this->collAdmins instanceof Collection) { - $this->collAdmins->clearIterator(); - } - $this->collAdmins = null; - if ($this->collResources instanceof Collection) { - $this->collResources->clearIterator(); - } - $this->collResources = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildGroup The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = GroupTableMap::UPDATED_AT; - - return $this; - } - - // i18n behavior - - /** - * Sets the locale for translations - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * - * @return ChildGroup The current object (for fluent API support) - */ - public function setLocale($locale = 'en_US') - { - $this->currentLocale = $locale; - - return $this; - } - - /** - * Gets the locale for translations - * - * @return string $locale Locale to use for the translation, e.g. 'fr_FR' - */ - public function getLocale() - { - return $this->currentLocale; - } - - /** - * Returns the current translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param ConnectionInterface $con an optional connection object - * - * @return ChildGroupI18n */ - public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) - { - if (!isset($this->currentTranslations[$locale])) { - if (null !== $this->collGroupI18ns) { - foreach ($this->collGroupI18ns as $translation) { - if ($translation->getLocale() == $locale) { - $this->currentTranslations[$locale] = $translation; - - return $translation; - } - } - } - if ($this->isNew()) { - $translation = new ChildGroupI18n(); - $translation->setLocale($locale); - } else { - $translation = ChildGroupI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->findOneOrCreate($con); - $this->currentTranslations[$locale] = $translation; - } - $this->addGroupI18n($translation); - } - - return $this->currentTranslations[$locale]; - } - - /** - * Remove the translation for a given locale - * - * @param string $locale Locale to use for the translation, e.g. 'fr_FR' - * @param ConnectionInterface $con an optional connection object - * - * @return ChildGroup The current object (for fluent API support) - */ - public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) - { - if (!$this->isNew()) { - ChildGroupI18nQuery::create() - ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) - ->delete($con); - } - if (isset($this->currentTranslations[$locale])) { - unset($this->currentTranslations[$locale]); - } - foreach ($this->collGroupI18ns as $key => $translation) { - if ($translation->getLocale() == $locale) { - unset($this->collGroupI18ns[$key]); - break; - } - } - - return $this; - } - - /** - * Returns the current translation - * - * @param ConnectionInterface $con an optional connection object - * - * @return ChildGroupI18n */ - public function getCurrentTranslation(ConnectionInterface $con = null) - { - return $this->getTranslation($this->getLocale(), $con); - } - - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - return $this->getCurrentTranslation()->getTitle(); - } - - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setTitle($v) - { $this->getCurrentTranslation()->setTitle($v); - - return $this; - } - - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - return $this->getCurrentTranslation()->getDescription(); - } - - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setDescription($v) - { $this->getCurrentTranslation()->setDescription($v); - - return $this; - } - - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - return $this->getCurrentTranslation()->getChapo(); - } - - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setChapo($v) - { $this->getCurrentTranslation()->setChapo($v); - - return $this; - } - - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - return $this->getCurrentTranslation()->getPostscriptum(); - } - - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { $this->getCurrentTranslation()->setPostscriptum($v); - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/GroupI18n.php b/core/lib/Thelia/Model/Base/GroupI18n.php deleted file mode 100644 index 07274e969..000000000 --- a/core/lib/Thelia/Model/Base/GroupI18n.php +++ /dev/null @@ -1,1442 +0,0 @@ -locale = 'en_US'; - } - - /** - * Initializes internal state of Thelia\Model\Base\GroupI18n object. - * @see applyDefaults() - */ - public function __construct() - { - $this->applyDefaultValues(); - } - - /** - * Returns whether the object has been modified. - * - * @return boolean True if the object has been modified. - */ - public function isModified() - { - return !empty($this->modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return boolean true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another GroupI18n instance. If - * obj is an instance of GroupI18n, delegates to - * equals(GroupI18n). Otherwise, returns false. - * - * @param mixed $obj The object to compare to. - * @return boolean Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @param string $name The virtual column name - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @param string $name The virtual column name - * @return mixed - * - * @throws PropelException - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return GroupI18n The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return GroupI18n The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - - return $this; - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [locale] column value. - * - * @return string - */ - public function getLocale() - { - - return $this->locale; - } - - /** - * Get the [title] column value. - * - * @return string - */ - public function getTitle() - { - - return $this->title; - } - - /** - * Get the [description] column value. - * - * @return string - */ - public function getDescription() - { - - return $this->description; - } - - /** - * Get the [chapo] column value. - * - * @return string - */ - public function getChapo() - { - - return $this->chapo; - } - - /** - * Get the [postscriptum] column value. - * - * @return string - */ - public function getPostscriptum() - { - - return $this->postscriptum; - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupI18nTableMap::ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setId() - - /** - * Set the value of [locale] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setLocale($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->locale !== $v) { - $this->locale = $v; - $this->modifiedColumns[] = GroupI18nTableMap::LOCALE; - } - - - return $this; - } // setLocale() - - /** - * Set the value of [title] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setTitle($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->title !== $v) { - $this->title = $v; - $this->modifiedColumns[] = GroupI18nTableMap::TITLE; - } - - - return $this; - } // setTitle() - - /** - * Set the value of [description] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setDescription($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->description !== $v) { - $this->description = $v; - $this->modifiedColumns[] = GroupI18nTableMap::DESCRIPTION; - } - - - return $this; - } // setDescription() - - /** - * Set the value of [chapo] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setChapo($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->chapo !== $v) { - $this->chapo = $v; - $this->modifiedColumns[] = GroupI18nTableMap::CHAPO; - } - - - return $this; - } // setChapo() - - /** - * Set the value of [postscriptum] column. - * - * @param string $v new value - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - */ - public function setPostscriptum($v) - { - if ($v !== null) { - $v = (string) $v; - } - - if ($this->postscriptum !== $v) { - $this->postscriptum = $v; - $this->modifiedColumns[] = GroupI18nTableMap::POSTSCRIPTUM; - } - - - return $this; - } // setPostscriptum() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->locale !== 'en_US') { - return false; - } - - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; - $this->locale = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; - $this->title = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; - $this->description = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; - $this->chapo = (null !== $col) ? (string) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; - $this->postscriptum = (null !== $col) ? (string) $col : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 6; // 6 = GroupI18nTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\GroupI18n object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - if ($this->aGroup !== null && $this->id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupI18nTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildGroupI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see GroupI18n::setDeleted() - * @see GroupI18n::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildGroupI18nQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - } else { - $ret = $ret && $this->preUpdate($con); - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - GroupI18nTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupI18nTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(GroupI18nTableMap::LOCALE)) { - $modifiedColumns[':p' . $index++] = 'LOCALE'; - } - if ($this->isColumnModified(GroupI18nTableMap::TITLE)) { - $modifiedColumns[':p' . $index++] = 'TITLE'; - } - if ($this->isColumnModified(GroupI18nTableMap::DESCRIPTION)) { - $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; - } - if ($this->isColumnModified(GroupI18nTableMap::CHAPO)) { - $modifiedColumns[':p' . $index++] = 'CHAPO'; - } - if ($this->isColumnModified(GroupI18nTableMap::POSTSCRIPTUM)) { - $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; - } - - $sql = sprintf( - 'INSERT INTO group_i18n (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'LOCALE': - $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); - break; - case 'TITLE': - $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); - break; - case 'DESCRIPTION': - $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); - break; - case 'CHAPO': - $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); - break; - case 'POSTSCRIPTUM': - $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getLocale(); - break; - case 2: - return $this->getTitle(); - break; - case 3: - return $this->getDescription(); - break; - case 4: - return $this->getChapo(); - break; - case 5: - return $this->getPostscriptum(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['GroupI18n'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['GroupI18n'][serialize($this->getPrimaryKey())] = true; - $keys = GroupI18nTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getLocale(), - $keys[2] => $this->getTitle(), - $keys[3] => $this->getDescription(), - $keys[4] => $this->getChapo(), - $keys[5] => $this->getPostscriptum(), - ); - $virtualColumns = $this->virtualColumns; - foreach ($virtualColumns as $key => $virtualColumn) { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setLocale($value); - break; - case 2: - $this->setTitle($value); - break; - case 3: - $this->setDescription($value); - break; - case 4: - $this->setChapo($value); - break; - case 5: - $this->setPostscriptum($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = GroupI18nTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupI18nTableMap::DATABASE_NAME); - - if ($this->isColumnModified(GroupI18nTableMap::ID)) $criteria->add(GroupI18nTableMap::ID, $this->id); - if ($this->isColumnModified(GroupI18nTableMap::LOCALE)) $criteria->add(GroupI18nTableMap::LOCALE, $this->locale); - if ($this->isColumnModified(GroupI18nTableMap::TITLE)) $criteria->add(GroupI18nTableMap::TITLE, $this->title); - if ($this->isColumnModified(GroupI18nTableMap::DESCRIPTION)) $criteria->add(GroupI18nTableMap::DESCRIPTION, $this->description); - if ($this->isColumnModified(GroupI18nTableMap::CHAPO)) $criteria->add(GroupI18nTableMap::CHAPO, $this->chapo); - if ($this->isColumnModified(GroupI18nTableMap::POSTSCRIPTUM)) $criteria->add(GroupI18nTableMap::POSTSCRIPTUM, $this->postscriptum); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(GroupI18nTableMap::DATABASE_NAME); - $criteria->add(GroupI18nTableMap::ID, $this->id); - $criteria->add(GroupI18nTableMap::LOCALE, $this->locale); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getId(); - $pks[1] = $this->getLocale(); - - return $pks; - } - - /** - * Set the [composite] primary key. - * - * @param array $keys The elements of the composite key (order must match the order in XML file). - * @return void - */ - public function setPrimaryKey($keys) - { - $this->setId($keys[0]); - $this->setLocale($keys[1]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getLocale()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\GroupI18n (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setId($this->getId()); - $copyObj->setLocale($this->getLocale()); - $copyObj->setTitle($this->getTitle()); - $copyObj->setDescription($this->getDescription()); - $copyObj->setChapo($this->getChapo()); - $copyObj->setPostscriptum($this->getPostscriptum()); - if ($makeNew) { - $copyObj->setNew(true); - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\GroupI18n Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Declares an association between this object and a ChildGroup object. - * - * @param ChildGroup $v - * @return \Thelia\Model\GroupI18n The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(ChildGroup $v = null) - { - if ($v === null) { - $this->setId(NULL); - } else { - $this->setId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildGroup object, it will not be re-added. - if ($v !== null) { - $v->addGroupI18n($this); - } - - - return $this; - } - - - /** - * Get the associated ChildGroup object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildGroup The associated ChildGroup object. - * @throws PropelException - */ - public function getGroup(ConnectionInterface $con = null) - { - if ($this->aGroup === null && ($this->id !== null)) { - $this->aGroup = ChildGroupQuery::create()->findPk($this->id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addGroupI18ns($this); - */ - } - - return $this->aGroup; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->locale = null; - $this->title = null; - $this->description = null; - $this->chapo = null; - $this->postscriptum = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->applyDefaultValues(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aGroup = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupI18nTableMap::DEFAULT_STRING_FORMAT); - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/GroupI18nQuery.php b/core/lib/Thelia/Model/Base/GroupI18nQuery.php deleted file mode 100644 index 8dc7b44ec..000000000 --- a/core/lib/Thelia/Model/Base/GroupI18nQuery.php +++ /dev/null @@ -1,607 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34), $con); - * - * - * @param array[$id, $locale] $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildGroupI18n|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupI18nTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroupI18n A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM group_i18n WHERE ID = :p0 AND LOCALE = :p1'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildGroupI18n(); - $obj->hydrate($row); - GroupI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroupI18n|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(GroupI18nTableMap::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(GroupI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); - - return $this; - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - if (empty($keys)) { - return $this->add(null, '1<>1', Criteria::CUSTOM); - } - foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(GroupI18nTableMap::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(GroupI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $this->addOr($cton0); - } - - return $this; - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @see filterByGroup() - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupI18nTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the locale column - * - * Example usage: - * - * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' - * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' - * - * - * @param string $locale The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByLocale($locale = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($locale)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $locale)) { - $locale = str_replace('*', '%', $locale); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nTableMap::LOCALE, $locale, $comparison); - } - - /** - * Filter the query on the title column - * - * Example usage: - * - * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' - * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' - * - * - * @param string $title The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByTitle($title = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($title)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $title)) { - $title = str_replace('*', '%', $title); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nTableMap::TITLE, $title, $comparison); - } - - /** - * Filter the query on the description column - * - * Example usage: - * - * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' - * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' - * - * - * @param string $description The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByDescription($description = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($description)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $description)) { - $description = str_replace('*', '%', $description); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nTableMap::DESCRIPTION, $description, $comparison); - } - - /** - * Filter the query on the chapo column - * - * Example usage: - * - * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' - * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' - * - * - * @param string $chapo The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByChapo($chapo = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($chapo)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $chapo)) { - $chapo = str_replace('*', '%', $chapo); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nTableMap::CHAPO, $chapo, $comparison); - } - - /** - * Filter the query on the postscriptum column - * - * Example usage: - * - * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' - * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' - * - * - * @param string $postscriptum The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByPostscriptum($postscriptum = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($postscriptum)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $postscriptum)) { - $postscriptum = str_replace('*', '%', $postscriptum); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Group object - * - * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof \Thelia\Model\Group) { - return $this - ->addUsingAlias(GroupI18nTableMap::ID, $group->getId(), $comparison); - } elseif ($group instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupI18nTableMap::ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Exclude object from result - * - * @param ChildGroupI18n $groupI18n Object to remove from the list of results - * - * @return ChildGroupI18nQuery The current query, for fluid interface - */ - public function prune($groupI18n = null) - { - if ($groupI18n) { - $this->addCond('pruneCond0', $this->getAliasedColName(GroupI18nTableMap::ID), $groupI18n->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(GroupI18nTableMap::LOCALE), $groupI18n->getLocale(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); - } - - return $this; - } - - /** - * Deletes all rows from the group_i18n table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - GroupI18nTableMap::clearInstancePool(); - GroupI18nTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildGroupI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildGroupI18n object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(GroupI18nTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - GroupI18nTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - GroupI18nTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - -} // GroupI18nQuery diff --git a/core/lib/Thelia/Model/Base/GroupModule.php b/core/lib/Thelia/Model/Base/GroupModule.php deleted file mode 100644 index e3f9d9e15..000000000 --- a/core/lib/Thelia/Model/Base/GroupModule.php +++ /dev/null @@ -1,1575 +0,0 @@ -access = 0; - } - - /** - * Initializes internal state of Thelia\Model\Base\GroupModule object. - * @see applyDefaults() - */ - public function __construct() - { - $this->applyDefaultValues(); - } - - /** - * Returns whether the object has been modified. - * - * @return boolean True if the object has been modified. - */ - public function isModified() - { - return !empty($this->modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return boolean true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another GroupModule instance. If - * obj is an instance of GroupModule, delegates to - * equals(GroupModule). Otherwise, returns false. - * - * @param mixed $obj The object to compare to. - * @return boolean Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @param string $name The virtual column name - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @param string $name The virtual column name - * @return mixed - * - * @throws PropelException - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return GroupModule The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return GroupModule The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - - return $this; - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getGroupId() - { - - return $this->group_id; - } - - /** - * Get the [module_id] column value. - * - * @return int - */ - public function getModuleId() - { - - return $this->module_id; - } - - /** - * Get the [access] column value. - * - * @return int - */ - public function getAccess() - { - - return $this->access; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupModuleTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - */ - public function setGroupId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = GroupModuleTableMap::GROUP_ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setGroupId() - - /** - * Set the value of [module_id] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - */ - public function setModuleId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->module_id !== $v) { - $this->module_id = $v; - $this->modifiedColumns[] = GroupModuleTableMap::MODULE_ID; - } - - if ($this->aModule !== null && $this->aModule->getId() !== $v) { - $this->aModule = null; - } - - - return $this; - } // setModuleId() - - /** - * Set the value of [access] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - */ - public function setAccess($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->access !== $v) { - $this->access = $v; - $this->modifiedColumns[] = GroupModuleTableMap::ACCESS; - } - - - return $this; - } // setAccess() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = GroupModuleTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = GroupModuleTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->access !== 0) { - return false; - } - - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupModuleTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->group_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupModuleTableMap::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->module_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupModuleTableMap::translateFieldName('Access', TableMap::TYPE_PHPNAME, $indexType)]; - $this->access = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 6; // 6 = GroupModuleTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\GroupModule object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) { - $this->aModule = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupModuleTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildGroupModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - $this->aModule = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see GroupModule::setDeleted() - * @see GroupModule::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildGroupModuleQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(GroupModuleTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - GroupModuleTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->aModule !== null) { - if ($this->aModule->isModified() || $this->aModule->isNew()) { - $affectedRows += $this->aModule->save($con); - } - $this->setModule($this->aModule); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = GroupModuleTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupModuleTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupModuleTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(GroupModuleTableMap::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = 'GROUP_ID'; - } - if ($this->isColumnModified(GroupModuleTableMap::MODULE_ID)) { - $modifiedColumns[':p' . $index++] = 'MODULE_ID'; - } - if ($this->isColumnModified(GroupModuleTableMap::ACCESS)) { - $modifiedColumns[':p' . $index++] = 'ACCESS'; - } - if ($this->isColumnModified(GroupModuleTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO group_module (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'GROUP_ID': - $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); - break; - case 'MODULE_ID': - $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT); - break; - case 'ACCESS': - $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT); - break; - case 'CREATED_AT': - $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getGroupId(); - break; - case 2: - return $this->getModuleId(); - break; - case 3: - return $this->getAccess(); - break; - case 4: - return $this->getCreatedAt(); - break; - case 5: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['GroupModule'][$this->getPrimaryKey()] = true; - $keys = GroupModuleTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getGroupId(), - $keys[2] => $this->getModuleId(), - $keys[3] => $this->getAccess(), - $keys[4] => $this->getCreatedAt(), - $keys[5] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach ($virtualColumns as $key => $virtualColumn) { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aModule) { - $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setGroupId($value); - break; - case 2: - $this->setModuleId($value); - break; - case 3: - $this->setAccess($value); - break; - case 4: - $this->setCreatedAt($value); - break; - case 5: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = GroupModuleTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setModuleId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setAccess($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupModuleTableMap::DATABASE_NAME); - - if ($this->isColumnModified(GroupModuleTableMap::ID)) $criteria->add(GroupModuleTableMap::ID, $this->id); - if ($this->isColumnModified(GroupModuleTableMap::GROUP_ID)) $criteria->add(GroupModuleTableMap::GROUP_ID, $this->group_id); - if ($this->isColumnModified(GroupModuleTableMap::MODULE_ID)) $criteria->add(GroupModuleTableMap::MODULE_ID, $this->module_id); - if ($this->isColumnModified(GroupModuleTableMap::ACCESS)) $criteria->add(GroupModuleTableMap::ACCESS, $this->access); - if ($this->isColumnModified(GroupModuleTableMap::CREATED_AT)) $criteria->add(GroupModuleTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(GroupModuleTableMap::UPDATED_AT)) $criteria->add(GroupModuleTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(GroupModuleTableMap::DATABASE_NAME); - $criteria->add(GroupModuleTableMap::ID, $this->id); - - return $criteria; - } - - /** - * Returns the primary key for this object (row). - * @return int - */ - public function getPrimaryKey() - { - return $this->getId(); - } - - /** - * Generic method to set the primary key (id column). - * - * @param int $key Primary key. - * @return void - */ - public function setPrimaryKey($key) - { - $this->setId($key); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return null === $this->getId(); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\GroupModule (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setGroupId($this->getGroupId()); - $copyObj->setModuleId($this->getModuleId()); - $copyObj->setAccess($this->getAccess()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\GroupModule Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Declares an association between this object and a ChildGroup object. - * - * @param ChildGroup $v - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(ChildGroup $v = null) - { - if ($v === null) { - $this->setGroupId(NULL); - } else { - $this->setGroupId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildGroup object, it will not be re-added. - if ($v !== null) { - $v->addGroupModule($this); - } - - - return $this; - } - - - /** - * Get the associated ChildGroup object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildGroup The associated ChildGroup object. - * @throws PropelException - */ - public function getGroup(ConnectionInterface $con = null) - { - if ($this->aGroup === null && ($this->group_id !== null)) { - $this->aGroup = ChildGroupQuery::create()->findPk($this->group_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addGroupModules($this); - */ - } - - return $this->aGroup; - } - - /** - * Declares an association between this object and a ChildModule object. - * - * @param ChildModule $v - * @return \Thelia\Model\GroupModule The current object (for fluent API support) - * @throws PropelException - */ - public function setModule(ChildModule $v = null) - { - if ($v === null) { - $this->setModuleId(NULL); - } else { - $this->setModuleId($v->getId()); - } - - $this->aModule = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildModule object, it will not be re-added. - if ($v !== null) { - $v->addGroupModule($this); - } - - - return $this; - } - - - /** - * Get the associated ChildModule object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildModule The associated ChildModule object. - * @throws PropelException - */ - public function getModule(ConnectionInterface $con = null) - { - if ($this->aModule === null && ($this->module_id !== null)) { - $this->aModule = ChildModuleQuery::create()->findPk($this->module_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aModule->addGroupModules($this); - */ - } - - return $this->aModule; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->group_id = null; - $this->module_id = null; - $this->access = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->applyDefaultValues(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aGroup = null; - $this->aModule = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupModuleTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildGroupModule The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = GroupModuleTableMap::UPDATED_AT; - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/GroupModuleQuery.php b/core/lib/Thelia/Model/Base/GroupModuleQuery.php deleted file mode 100644 index 531342ec9..000000000 --- a/core/lib/Thelia/Model/Base/GroupModuleQuery.php +++ /dev/null @@ -1,804 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildGroupModule|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupModuleTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroupModule A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, GROUP_ID, MODULE_ID, ACCESS, CREATED_AT, UPDATED_AT FROM group_module WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildGroupModule(); - $obj->hydrate($row); - GroupModuleTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroupModule|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(GroupModuleTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(GroupModuleTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModuleTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the group_id column - * - * Example usage: - * - * $query->filterByGroupId(1234); // WHERE group_id = 1234 - * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 - * - * - * @see filterByGroup() - * - * @param mixed $groupId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByGroupId($groupId = null, $comparison = null) - { - if (is_array($groupId)) { - $useMinMax = false; - if (isset($groupId['min'])) { - $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($groupId['max'])) { - $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModuleTableMap::GROUP_ID, $groupId, $comparison); - } - - /** - * Filter the query on the module_id column - * - * Example usage: - * - * $query->filterByModuleId(1234); // WHERE module_id = 1234 - * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34) - * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12 - * - * - * @see filterByModule() - * - * @param mixed $moduleId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByModuleId($moduleId = null, $comparison = null) - { - if (is_array($moduleId)) { - $useMinMax = false; - if (isset($moduleId['min'])) { - $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($moduleId['max'])) { - $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModuleTableMap::MODULE_ID, $moduleId, $comparison); - } - - /** - * Filter the query on the access column - * - * Example usage: - * - * $query->filterByAccess(1234); // WHERE access = 1234 - * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34) - * $query->filterByAccess(array('min' => 12)); // WHERE access > 12 - * - * - * @param mixed $access The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByAccess($access = null, $comparison = null) - { - if (is_array($access)) { - $useMinMax = false; - if (isset($access['min'])) { - $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($access['max'])) { - $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModuleTableMap::ACCESS, $access, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Group object - * - * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof \Thelia\Model\Group) { - return $this - ->addUsingAlias(GroupModuleTableMap::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupModuleTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Module object - * - * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function filterByModule($module, $comparison = null) - { - if ($module instanceof \Thelia\Model\Module) { - return $this - ->addUsingAlias(GroupModuleTableMap::MODULE_ID, $module->getId(), $comparison); - } elseif ($module instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupModuleTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Module relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function joinModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Module'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Module'); - } - - return $this; - } - - /** - * Use the Module relation Module object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query - */ - public function useModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); - } - - /** - * Exclude object from result - * - * @param ChildGroupModule $groupModule Object to remove from the list of results - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function prune($groupModule = null) - { - if ($groupModule) { - $this->addUsingAlias(GroupModuleTableMap::ID, $groupModule->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the group_module table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - GroupModuleTableMap::clearInstancePool(); - GroupModuleTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildGroupModule or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildGroupModule object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(GroupModuleTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - GroupModuleTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - GroupModuleTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(GroupModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(GroupModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(GroupModuleTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(GroupModuleTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(GroupModuleTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildGroupModuleQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(GroupModuleTableMap::CREATED_AT); - } - -} // GroupModuleQuery diff --git a/core/lib/Thelia/Model/Base/GroupQuery.php b/core/lib/Thelia/Model/Base/GroupQuery.php deleted file mode 100644 index d0eded79b..000000000 --- a/core/lib/Thelia/Model/Base/GroupQuery.php +++ /dev/null @@ -1,940 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(12, $con); - * - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildGroup|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroup A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, CODE, CREATED_AT, UPDATED_AT FROM group WHERE ID = :p0'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key, PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildGroup(); - $obj->hydrate($row); - GroupTableMap::addInstanceToPool($obj, (string) $key); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroup|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(12, 56, 832), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - - return $this->addUsingAlias(GroupTableMap::ID, $key, Criteria::EQUAL); - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - - return $this->addUsingAlias(GroupTableMap::ID, $keys, Criteria::IN); - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the code column - * - * Example usage: - * - * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' - * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' - * - * - * @param string $code The value to use as filter. - * Accepts wildcards (* and % trigger a LIKE) - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByCode($code = null, $comparison = null) - { - if (null === $comparison) { - if (is_array($code)) { - $comparison = Criteria::IN; - } elseif (preg_match('/[\%\*]/', $code)) { - $code = str_replace('*', '%', $code); - $comparison = Criteria::LIKE; - } - } - - return $this->addUsingAlias(GroupTableMap::CODE, $code, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\AdminGroup object - * - * @param \Thelia\Model\AdminGroup|ObjectCollection $adminGroup the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByAdminGroup($adminGroup, $comparison = null) - { - if ($adminGroup instanceof \Thelia\Model\AdminGroup) { - return $this - ->addUsingAlias(GroupTableMap::ID, $adminGroup->getGroupId(), $comparison); - } elseif ($adminGroup instanceof ObjectCollection) { - return $this - ->useAdminGroupQuery() - ->filterByPrimaryKeys($adminGroup->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByAdminGroup() only accepts arguments of type \Thelia\Model\AdminGroup or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the AdminGroup relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function joinAdminGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('AdminGroup'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'AdminGroup'); - } - - return $this; - } - - /** - * Use the AdminGroup relation AdminGroup object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\AdminGroupQuery A secondary query class using the current class as primary query - */ - public function useAdminGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinAdminGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'AdminGroup', '\Thelia\Model\AdminGroupQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\GroupResource object - * - * @param \Thelia\Model\GroupResource|ObjectCollection $groupResource the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByGroupResource($groupResource, $comparison = null) - { - if ($groupResource instanceof \Thelia\Model\GroupResource) { - return $this - ->addUsingAlias(GroupTableMap::ID, $groupResource->getGroupId(), $comparison); - } elseif ($groupResource instanceof ObjectCollection) { - return $this - ->useGroupResourceQuery() - ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupResource() only accepts arguments of type \Thelia\Model\GroupResource or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupResource relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupResource'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupResource'); - } - - return $this; - } - - /** - * Use the GroupResource relation GroupResource object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query - */ - public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroupResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\GroupModule object - * - * @param \Thelia\Model\GroupModule|ObjectCollection $groupModule the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByGroupModule($groupModule, $comparison = null) - { - if ($groupModule instanceof \Thelia\Model\GroupModule) { - return $this - ->addUsingAlias(GroupTableMap::ID, $groupModule->getGroupId(), $comparison); - } elseif ($groupModule instanceof ObjectCollection) { - return $this - ->useGroupModuleQuery() - ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type \Thelia\Model\GroupModule or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupModule relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function joinGroupModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupModule'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupModule'); - } - - return $this; - } - - /** - * Use the GroupModule relation GroupModule object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query - */ - public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroupModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\GroupI18n object - * - * @param \Thelia\Model\GroupI18n|ObjectCollection $groupI18n the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByGroupI18n($groupI18n, $comparison = null) - { - if ($groupI18n instanceof \Thelia\Model\GroupI18n) { - return $this - ->addUsingAlias(GroupTableMap::ID, $groupI18n->getId(), $comparison); - } elseif ($groupI18n instanceof ObjectCollection) { - return $this - ->useGroupI18nQuery() - ->filterByPrimaryKeys($groupI18n->getPrimaryKeys()) - ->endUse(); - } else { - throw new PropelException('filterByGroupI18n() only accepts arguments of type \Thelia\Model\GroupI18n or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the GroupI18n relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function joinGroupI18n($relationAlias = null, $joinType = 'LEFT JOIN') - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupI18n'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'GroupI18n'); - } - - return $this; - } - - /** - * Use the GroupI18n relation GroupI18n object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupI18nQuery A secondary query class using the current class as primary query - */ - public function useGroupI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') - { - return $this - ->joinGroupI18n($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', '\Thelia\Model\GroupI18nQuery'); - } - - /** - * Filter the query by a related Admin object - * using the admin_group table as cross reference - * - * @param Admin $admin the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByAdmin($admin, $comparison = Criteria::EQUAL) - { - return $this - ->useAdminGroupQuery() - ->filterByAdmin($admin, $comparison) - ->endUse(); - } - - /** - * Filter the query by a related Resource object - * using the group_resource table as cross reference - * - * @param Resource $resource the related object to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function filterByResource($resource, $comparison = Criteria::EQUAL) - { - return $this - ->useGroupResourceQuery() - ->filterByResource($resource, $comparison) - ->endUse(); - } - - /** - * Exclude object from result - * - * @param ChildGroup $group Object to remove from the list of results - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function prune($group = null) - { - if ($group) { - $this->addUsingAlias(GroupTableMap::ID, $group->getId(), Criteria::NOT_EQUAL); - } - - return $this; - } - - /** - * Deletes all rows from the group table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - GroupTableMap::clearInstancePool(); - GroupTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildGroup or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildGroup object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(GroupTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - GroupTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - GroupTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(GroupTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(GroupTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(GroupTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(GroupTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(GroupTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(GroupTableMap::CREATED_AT); - } - - // i18n behavior - - /** - * Adds a JOIN clause to the query using the i18n relation - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - $relationName = $relationAlias ? $relationAlias : 'GroupI18n'; - - return $this - ->joinGroupI18n($relationAlias, $joinType) - ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); - } - - /** - * Adds a JOIN clause to the query and hydrates the related I18n object. - * Shortcut for $c->joinI18n($locale)->with() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildGroupQuery The current query, for fluid interface - */ - public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) - { - $this - ->joinI18n($locale, null, $joinType) - ->with('GroupI18n'); - $this->with['GroupI18n']->setIsWithOneToMany(false); - - return $this; - } - - /** - * Use the I18n relation query object - * - * @see useQuery() - * - * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. - * - * @return ChildGroupI18nQuery A secondary query class using the current class as primary query - */ - public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) - { - return $this - ->joinI18n($locale, $relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupI18n', '\Thelia\Model\GroupI18nQuery'); - } - -} // GroupQuery diff --git a/core/lib/Thelia/Model/Base/GroupResource.php b/core/lib/Thelia/Model/Base/GroupResource.php deleted file mode 100644 index 8bfcd442f..000000000 --- a/core/lib/Thelia/Model/Base/GroupResource.php +++ /dev/null @@ -1,1649 +0,0 @@ -read = 0; - $this->write = 0; - } - - /** - * Initializes internal state of Thelia\Model\Base\GroupResource object. - * @see applyDefaults() - */ - public function __construct() - { - $this->applyDefaultValues(); - } - - /** - * Returns whether the object has been modified. - * - * @return boolean True if the object has been modified. - */ - public function isModified() - { - return !empty($this->modifiedColumns); - } - - /** - * Has specified column been modified? - * - * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID - * @return boolean True if $col has been modified. - */ - public function isColumnModified($col) - { - return in_array($col, $this->modifiedColumns); - } - - /** - * Get the columns that have been modified in this object. - * @return array A unique list of the modified column names for this object. - */ - public function getModifiedColumns() - { - return array_unique($this->modifiedColumns); - } - - /** - * Returns whether the object has ever been saved. This will - * be false, if the object was retrieved from storage or was created - * and then saved. - * - * @return boolean true, if the object has never been persisted. - */ - public function isNew() - { - return $this->new; - } - - /** - * Setter for the isNew attribute. This method will be called - * by Propel-generated children and objects. - * - * @param boolean $b the state of the object. - */ - public function setNew($b) - { - $this->new = (Boolean) $b; - } - - /** - * Whether this object has been deleted. - * @return boolean The deleted state of this object. - */ - public function isDeleted() - { - return $this->deleted; - } - - /** - * Specify whether this object has been deleted. - * @param boolean $b The deleted state of this object. - * @return void - */ - public function setDeleted($b) - { - $this->deleted = (Boolean) $b; - } - - /** - * Sets the modified state for the object to be false. - * @param string $col If supplied, only the specified column is reset. - * @return void - */ - public function resetModified($col = null) - { - if (null !== $col) { - while (false !== ($offset = array_search($col, $this->modifiedColumns))) { - array_splice($this->modifiedColumns, $offset, 1); - } - } else { - $this->modifiedColumns = array(); - } - } - - /** - * Compares this with another GroupResource instance. If - * obj is an instance of GroupResource, delegates to - * equals(GroupResource). Otherwise, returns false. - * - * @param mixed $obj The object to compare to. - * @return boolean Whether equal to the object specified. - */ - public function equals($obj) - { - $thisclazz = get_class($this); - if (!is_object($obj) || !($obj instanceof $thisclazz)) { - return false; - } - - if ($this === $obj) { - return true; - } - - if (null === $this->getPrimaryKey() - || null === $obj->getPrimaryKey()) { - return false; - } - - return $this->getPrimaryKey() === $obj->getPrimaryKey(); - } - - /** - * If the primary key is not null, return the hashcode of the - * primary key. Otherwise, return the hash code of the object. - * - * @return int Hashcode - */ - public function hashCode() - { - if (null !== $this->getPrimaryKey()) { - return crc32(serialize($this->getPrimaryKey())); - } - - return crc32(serialize(clone $this)); - } - - /** - * Get the associative array of the virtual columns in this object - * - * @return array - */ - public function getVirtualColumns() - { - return $this->virtualColumns; - } - - /** - * Checks the existence of a virtual column in this object - * - * @param string $name The virtual column name - * @return boolean - */ - public function hasVirtualColumn($name) - { - return array_key_exists($name, $this->virtualColumns); - } - - /** - * Get the value of a virtual column in this object - * - * @param string $name The virtual column name - * @return mixed - * - * @throws PropelException - */ - public function getVirtualColumn($name) - { - if (!$this->hasVirtualColumn($name)) { - throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); - } - - return $this->virtualColumns[$name]; - } - - /** - * Set the value of a virtual column in this object - * - * @param string $name The virtual column name - * @param mixed $value The value to give to the virtual column - * - * @return GroupResource The current object, for fluid interface - */ - public function setVirtualColumn($name, $value) - { - $this->virtualColumns[$name] = $value; - - return $this; - } - - /** - * Logs a message using Propel::log(). - * - * @param string $msg - * @param int $priority One of the Propel::LOG_* logging levels - * @return boolean - */ - protected function log($msg, $priority = Propel::LOG_INFO) - { - return Propel::log(get_class($this) . ': ' . $msg, $priority); - } - - /** - * Populate the current object from a string, using a given parser format - * - * $book = new Book(); - * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, - * or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param string $data The source data to import from - * - * @return GroupResource The current object, for fluid interface - */ - public function importFrom($parser, $data) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); - - return $this; - } - - /** - * Export the current object properties to a string, using a given parser format - * - * $book = BookQuery::create()->findPk(9012); - * echo $book->exportTo('JSON'); - * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); - * - * - * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. - * @return string The exported data - */ - public function exportTo($parser, $includeLazyLoadColumns = true) - { - if (!$parser instanceof AbstractParser) { - $parser = AbstractParser::getParser($parser); - } - - return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); - } - - /** - * Clean up internal collections prior to serializing - * Avoids recursive loops that turn into segmentation faults when serializing - */ - public function __sleep() - { - $this->clearAllReferences(); - - return array_keys(get_object_vars($this)); - } - - /** - * Get the [id] column value. - * - * @return int - */ - public function getId() - { - - return $this->id; - } - - /** - * Get the [group_id] column value. - * - * @return int - */ - public function getGroupId() - { - - return $this->group_id; - } - - /** - * Get the [resource_id] column value. - * - * @return int - */ - public function getResourceId() - { - - return $this->resource_id; - } - - /** - * Get the [read] column value. - * - * @return int - */ - public function getRead() - { - - return $this->read; - } - - /** - * Get the [write] column value. - * - * @return int - */ - public function getWrite() - { - - return $this->write; - } - - /** - * Get the [optionally formatted] temporal [created_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getCreatedAt($format = NULL) - { - if ($format === null) { - return $this->created_at; - } else { - return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; - } - } - - /** - * Get the [optionally formatted] temporal [updated_at] column value. - * - * - * @param string $format The date/time format string (either date()-style or strftime()-style). - * If format is NULL, then the raw \DateTime object will be returned. - * - * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 - * - * @throws PropelException - if unable to parse/validate the date/time value. - */ - public function getUpdatedAt($format = NULL) - { - if ($format === null) { - return $this->updated_at; - } else { - return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; - } - } - - /** - * Set the value of [id] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - */ - public function setId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->id !== $v) { - $this->id = $v; - $this->modifiedColumns[] = GroupResourceTableMap::ID; - } - - - return $this; - } // setId() - - /** - * Set the value of [group_id] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - */ - public function setGroupId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->group_id !== $v) { - $this->group_id = $v; - $this->modifiedColumns[] = GroupResourceTableMap::GROUP_ID; - } - - if ($this->aGroup !== null && $this->aGroup->getId() !== $v) { - $this->aGroup = null; - } - - - return $this; - } // setGroupId() - - /** - * Set the value of [resource_id] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - */ - public function setResourceId($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->resource_id !== $v) { - $this->resource_id = $v; - $this->modifiedColumns[] = GroupResourceTableMap::RESOURCE_ID; - } - - if ($this->aResource !== null && $this->aResource->getId() !== $v) { - $this->aResource = null; - } - - - return $this; - } // setResourceId() - - /** - * Set the value of [read] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - */ - public function setRead($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->read !== $v) { - $this->read = $v; - $this->modifiedColumns[] = GroupResourceTableMap::READ; - } - - - return $this; - } // setRead() - - /** - * Set the value of [write] column. - * - * @param int $v new value - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - */ - public function setWrite($v) - { - if ($v !== null) { - $v = (int) $v; - } - - if ($this->write !== $v) { - $this->write = $v; - $this->modifiedColumns[] = GroupResourceTableMap::WRITE; - } - - - return $this; - } // setWrite() - - /** - * Sets the value of [created_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - */ - public function setCreatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->created_at !== null || $dt !== null) { - if ($dt !== $this->created_at) { - $this->created_at = $dt; - $this->modifiedColumns[] = GroupResourceTableMap::CREATED_AT; - } - } // if either are not null - - - return $this; - } // setCreatedAt() - - /** - * Sets the value of [updated_at] column to a normalized version of the date/time value specified. - * - * @param mixed $v string, integer (timestamp), or \DateTime value. - * Empty strings are treated as NULL. - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - */ - public function setUpdatedAt($v) - { - $dt = PropelDateTime::newInstance($v, null, '\DateTime'); - if ($this->updated_at !== null || $dt !== null) { - if ($dt !== $this->updated_at) { - $this->updated_at = $dt; - $this->modifiedColumns[] = GroupResourceTableMap::UPDATED_AT; - } - } // if either are not null - - - return $this; - } // setUpdatedAt() - - /** - * Indicates whether the columns in this object are only set to default values. - * - * This method can be used in conjunction with isModified() to indicate whether an object is both - * modified _and_ has some values set which are non-default. - * - * @return boolean Whether the columns in this object are only been set with default values. - */ - public function hasOnlyDefaultValues() - { - if ($this->read !== 0) { - return false; - } - - if ($this->write !== 0) { - return false; - } - - // otherwise, everything was equal, so return TRUE - return true; - } // hasOnlyDefaultValues() - - /** - * Hydrates (populates) the object variables with values from the database resultset. - * - * An offset (0-based "start column") is specified so that objects can be hydrated - * with a subset of the columns in the resultset rows. This is needed, for example, - * for results of JOIN queries where the resultset row includes columns from two or - * more tables. - * - * @param array $row The row returned by DataFetcher->fetch(). - * @param int $startcol 0-based offset column which indicates which restultset column to start with. - * @param boolean $rehydrate Whether this object is being re-hydrated from the database. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @return int next starting column - * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. - */ - public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) - { - try { - - - $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : GroupResourceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - $this->id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : GroupResourceTableMap::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->group_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : GroupResourceTableMap::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)]; - $this->resource_id = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : GroupResourceTableMap::translateFieldName('Read', TableMap::TYPE_PHPNAME, $indexType)]; - $this->read = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : GroupResourceTableMap::translateFieldName('Write', TableMap::TYPE_PHPNAME, $indexType)]; - $this->write = (null !== $col) ? (int) $col : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : GroupResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - - $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : GroupResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; - if ($col === '0000-00-00 00:00:00') { - $col = null; - } - $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $this->resetModified(); - - $this->setNew(false); - - if ($rehydrate) { - $this->ensureConsistency(); - } - - return $startcol + 7; // 7 = GroupResourceTableMap::NUM_HYDRATE_COLUMNS. - - } catch (Exception $e) { - throw new PropelException("Error populating \Thelia\Model\GroupResource object", 0, $e); - } - } - - /** - * Checks and repairs the internal consistency of the object. - * - * This method is executed after an already-instantiated object is re-hydrated - * from the database. It exists to check any foreign keys to make sure that - * the objects related to the current object are correct based on foreign key. - * - * You can override this method in the stub class, but you should always invoke - * the base method from the overridden method (i.e. parent::ensureConsistency()), - * in case your model changes. - * - * @throws PropelException - */ - public function ensureConsistency() - { - if ($this->aGroup !== null && $this->group_id !== $this->aGroup->getId()) { - $this->aGroup = null; - } - if ($this->aResource !== null && $this->resource_id !== $this->aResource->getId()) { - $this->aResource = null; - } - } // ensureConsistency - - /** - * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. - * - * This will only work if the object has been saved and has a valid primary key set. - * - * @param boolean $deep (optional) Whether to also de-associated any related objects. - * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. - * @return void - * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db - */ - public function reload($deep = false, ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("Cannot reload a deleted object."); - } - - if ($this->isNew()) { - throw new PropelException("Cannot reload an unsaved object."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupResourceTableMap::DATABASE_NAME); - } - - // We don't need to alter the object instance pool; we're just modifying this instance - // already in the pool. - - $dataFetcher = ChildGroupResourceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); - $row = $dataFetcher->fetch(); - $dataFetcher->close(); - if (!$row) { - throw new PropelException('Cannot find matching row in the database to reload object values.'); - } - $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate - - if ($deep) { // also de-associate any related objects? - - $this->aGroup = null; - $this->aResource = null; - } // if (deep) - } - - /** - * Removes this object from datastore and sets delete attribute. - * - * @param ConnectionInterface $con - * @return void - * @throws PropelException - * @see GroupResource::setDeleted() - * @see GroupResource::isDeleted() - */ - public function delete(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("This object has already been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - try { - $deleteQuery = ChildGroupResourceQuery::create() - ->filterByPrimaryKey($this->getPrimaryKey()); - $ret = $this->preDelete($con); - if ($ret) { - $deleteQuery->delete($con); - $this->postDelete($con); - $con->commit(); - $this->setDeleted(true); - } else { - $con->commit(); - } - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Persists this object to the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All modified related objects will also be persisted in the doSave() - * method. This method wraps all precipitate database operations in a - * single transaction. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see doSave() - */ - public function save(ConnectionInterface $con = null) - { - if ($this->isDeleted()) { - throw new PropelException("You cannot save an object that has been deleted."); - } - - if ($con === null) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); - } - - $con->beginTransaction(); - $isInsert = $this->isNew(); - try { - $ret = $this->preSave($con); - if ($isInsert) { - $ret = $ret && $this->preInsert($con); - // timestampable behavior - if (!$this->isColumnModified(GroupResourceTableMap::CREATED_AT)) { - $this->setCreatedAt(time()); - } - if (!$this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } else { - $ret = $ret && $this->preUpdate($con); - // timestampable behavior - if ($this->isModified() && !$this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) { - $this->setUpdatedAt(time()); - } - } - if ($ret) { - $affectedRows = $this->doSave($con); - if ($isInsert) { - $this->postInsert($con); - } else { - $this->postUpdate($con); - } - $this->postSave($con); - GroupResourceTableMap::addInstanceToPool($this); - } else { - $affectedRows = 0; - } - $con->commit(); - - return $affectedRows; - } catch (Exception $e) { - $con->rollBack(); - throw $e; - } - } - - /** - * Performs the work of inserting or updating the row in the database. - * - * If the object is new, it inserts it; otherwise an update is performed. - * All related objects are also updated in this method. - * - * @param ConnectionInterface $con - * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. - * @throws PropelException - * @see save() - */ - protected function doSave(ConnectionInterface $con) - { - $affectedRows = 0; // initialize var to track total num of affected rows - if (!$this->alreadyInSave) { - $this->alreadyInSave = true; - - // We call the save method on the following object(s) if they - // were passed to this object by their corresponding set - // method. This object relates to these object(s) by a - // foreign key reference. - - if ($this->aGroup !== null) { - if ($this->aGroup->isModified() || $this->aGroup->isNew()) { - $affectedRows += $this->aGroup->save($con); - } - $this->setGroup($this->aGroup); - } - - if ($this->aResource !== null) { - if ($this->aResource->isModified() || $this->aResource->isNew()) { - $affectedRows += $this->aResource->save($con); - } - $this->setResource($this->aResource); - } - - if ($this->isNew() || $this->isModified()) { - // persist changes - if ($this->isNew()) { - $this->doInsert($con); - } else { - $this->doUpdate($con); - } - $affectedRows += 1; - $this->resetModified(); - } - - $this->alreadyInSave = false; - - } - - return $affectedRows; - } // doSave() - - /** - * Insert the row in the database. - * - * @param ConnectionInterface $con - * - * @throws PropelException - * @see doSave() - */ - protected function doInsert(ConnectionInterface $con) - { - $modifiedColumns = array(); - $index = 0; - - $this->modifiedColumns[] = GroupResourceTableMap::ID; - if (null !== $this->id) { - throw new PropelException('Cannot insert a value for auto-increment primary key (' . GroupResourceTableMap::ID . ')'); - } - - // check the columns in natural order for more readable SQL queries - if ($this->isColumnModified(GroupResourceTableMap::ID)) { - $modifiedColumns[':p' . $index++] = 'ID'; - } - if ($this->isColumnModified(GroupResourceTableMap::GROUP_ID)) { - $modifiedColumns[':p' . $index++] = 'GROUP_ID'; - } - if ($this->isColumnModified(GroupResourceTableMap::RESOURCE_ID)) { - $modifiedColumns[':p' . $index++] = 'RESOURCE_ID'; - } - if ($this->isColumnModified(GroupResourceTableMap::READ)) { - $modifiedColumns[':p' . $index++] = 'READ'; - } - if ($this->isColumnModified(GroupResourceTableMap::WRITE)) { - $modifiedColumns[':p' . $index++] = 'WRITE'; - } - if ($this->isColumnModified(GroupResourceTableMap::CREATED_AT)) { - $modifiedColumns[':p' . $index++] = 'CREATED_AT'; - } - if ($this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) { - $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; - } - - $sql = sprintf( - 'INSERT INTO group_resource (%s) VALUES (%s)', - implode(', ', $modifiedColumns), - implode(', ', array_keys($modifiedColumns)) - ); - - try { - $stmt = $con->prepare($sql); - foreach ($modifiedColumns as $identifier => $columnName) { - switch ($columnName) { - case 'ID': - $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); - break; - case 'GROUP_ID': - $stmt->bindValue($identifier, $this->group_id, PDO::PARAM_INT); - break; - case 'RESOURCE_ID': - $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT); - break; - case 'READ': - $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT); - break; - case 'WRITE': - $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT); - break; - case 'CREATED_AT': - $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - case 'UPDATED_AT': - $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); - break; - } - } - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); - } - - try { - $pk = $con->lastInsertId(); - } catch (Exception $e) { - throw new PropelException('Unable to get autoincrement id.', 0, $e); - } - $this->setId($pk); - - $this->setNew(false); - } - - /** - * Update the row in the database. - * - * @param ConnectionInterface $con - * - * @return Integer Number of updated rows - * @see doSave() - */ - protected function doUpdate(ConnectionInterface $con) - { - $selectCriteria = $this->buildPkeyCriteria(); - $valuesCriteria = $this->buildCriteria(); - - return $selectCriteria->doUpdate($valuesCriteria, $con); - } - - /** - * Retrieves a field from the object by name passed in as a string. - * - * @param string $name name - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return mixed Value of field. - */ - public function getByName($name, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - $field = $this->getByPosition($pos); - - return $field; - } - - /** - * Retrieves a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @return mixed Value of field at $pos - */ - public function getByPosition($pos) - { - switch ($pos) { - case 0: - return $this->getId(); - break; - case 1: - return $this->getGroupId(); - break; - case 2: - return $this->getResourceId(); - break; - case 3: - return $this->getRead(); - break; - case 4: - return $this->getWrite(); - break; - case 5: - return $this->getCreatedAt(); - break; - case 6: - return $this->getUpdatedAt(); - break; - default: - return null; - break; - } // switch() - } - - /** - * Exports the object as an array. - * - * You can specify the key type of the array by passing one of the class - * type constants. - * - * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. - * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion - * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. - * - * @return array an associative array containing the field names (as keys) and field values - */ - public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) - { - if (isset($alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())])) { - return '*RECURSION*'; - } - $alreadyDumpedObjects['GroupResource'][serialize($this->getPrimaryKey())] = true; - $keys = GroupResourceTableMap::getFieldNames($keyType); - $result = array( - $keys[0] => $this->getId(), - $keys[1] => $this->getGroupId(), - $keys[2] => $this->getResourceId(), - $keys[3] => $this->getRead(), - $keys[4] => $this->getWrite(), - $keys[5] => $this->getCreatedAt(), - $keys[6] => $this->getUpdatedAt(), - ); - $virtualColumns = $this->virtualColumns; - foreach ($virtualColumns as $key => $virtualColumn) { - $result[$key] = $virtualColumn; - } - - if ($includeForeignObjects) { - if (null !== $this->aGroup) { - $result['Group'] = $this->aGroup->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - if (null !== $this->aResource) { - $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); - } - } - - return $result; - } - - /** - * Sets a field from the object by name passed in as a string. - * - * @param string $name - * @param mixed $value field value - * @param string $type The type of fieldname the $name is of: - * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * Defaults to TableMap::TYPE_PHPNAME. - * @return void - */ - public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) - { - $pos = GroupResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); - - return $this->setByPosition($pos, $value); - } - - /** - * Sets a field from the object by Position as specified in the xml schema. - * Zero-based. - * - * @param int $pos position in xml schema - * @param mixed $value field value - * @return void - */ - public function setByPosition($pos, $value) - { - switch ($pos) { - case 0: - $this->setId($value); - break; - case 1: - $this->setGroupId($value); - break; - case 2: - $this->setResourceId($value); - break; - case 3: - $this->setRead($value); - break; - case 4: - $this->setWrite($value); - break; - case 5: - $this->setCreatedAt($value); - break; - case 6: - $this->setUpdatedAt($value); - break; - } // switch() - } - - /** - * Populates the object using an array. - * - * This is particularly useful when populating an object from one of the - * request arrays (e.g. $_POST). This method goes through the column - * names, checking to see whether a matching key exists in populated - * array. If so the setByName() method is called for that column. - * - * You can specify the key type of the array by additionally passing one - * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * The default key type is the column's TableMap::TYPE_PHPNAME. - * - * @param array $arr An array to populate the object from. - * @param string $keyType The type of keys the array uses. - * @return void - */ - public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) - { - $keys = GroupResourceTableMap::getFieldNames($keyType); - - if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); - if (array_key_exists($keys[1], $arr)) $this->setGroupId($arr[$keys[1]]); - if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]); - if (array_key_exists($keys[3], $arr)) $this->setRead($arr[$keys[3]]); - if (array_key_exists($keys[4], $arr)) $this->setWrite($arr[$keys[4]]); - if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); - if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); - } - - /** - * Build a Criteria object containing the values of all modified columns in this object. - * - * @return Criteria The Criteria object containing all modified values. - */ - public function buildCriteria() - { - $criteria = new Criteria(GroupResourceTableMap::DATABASE_NAME); - - if ($this->isColumnModified(GroupResourceTableMap::ID)) $criteria->add(GroupResourceTableMap::ID, $this->id); - if ($this->isColumnModified(GroupResourceTableMap::GROUP_ID)) $criteria->add(GroupResourceTableMap::GROUP_ID, $this->group_id); - if ($this->isColumnModified(GroupResourceTableMap::RESOURCE_ID)) $criteria->add(GroupResourceTableMap::RESOURCE_ID, $this->resource_id); - if ($this->isColumnModified(GroupResourceTableMap::READ)) $criteria->add(GroupResourceTableMap::READ, $this->read); - if ($this->isColumnModified(GroupResourceTableMap::WRITE)) $criteria->add(GroupResourceTableMap::WRITE, $this->write); - if ($this->isColumnModified(GroupResourceTableMap::CREATED_AT)) $criteria->add(GroupResourceTableMap::CREATED_AT, $this->created_at); - if ($this->isColumnModified(GroupResourceTableMap::UPDATED_AT)) $criteria->add(GroupResourceTableMap::UPDATED_AT, $this->updated_at); - - return $criteria; - } - - /** - * Builds a Criteria object containing the primary key for this object. - * - * Unlike buildCriteria() this method includes the primary key values regardless - * of whether or not they have been modified. - * - * @return Criteria The Criteria object containing value(s) for primary key(s). - */ - public function buildPkeyCriteria() - { - $criteria = new Criteria(GroupResourceTableMap::DATABASE_NAME); - $criteria->add(GroupResourceTableMap::ID, $this->id); - $criteria->add(GroupResourceTableMap::GROUP_ID, $this->group_id); - $criteria->add(GroupResourceTableMap::RESOURCE_ID, $this->resource_id); - - return $criteria; - } - - /** - * Returns the composite primary key for this object. - * The array elements will be in same order as specified in XML. - * @return array - */ - public function getPrimaryKey() - { - $pks = array(); - $pks[0] = $this->getId(); - $pks[1] = $this->getGroupId(); - $pks[2] = $this->getResourceId(); - - return $pks; - } - - /** - * Set the [composite] primary key. - * - * @param array $keys The elements of the composite key (order must match the order in XML file). - * @return void - */ - public function setPrimaryKey($keys) - { - $this->setId($keys[0]); - $this->setGroupId($keys[1]); - $this->setResourceId($keys[2]); - } - - /** - * Returns true if the primary key for this object is null. - * @return boolean - */ - public function isPrimaryKeyNull() - { - - return (null === $this->getId()) && (null === $this->getGroupId()) && (null === $this->getResourceId()); - } - - /** - * Sets contents of passed object to values from current object. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param object $copyObj An object of \Thelia\Model\GroupResource (or compatible) type. - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. - * @throws PropelException - */ - public function copyInto($copyObj, $deepCopy = false, $makeNew = true) - { - $copyObj->setGroupId($this->getGroupId()); - $copyObj->setResourceId($this->getResourceId()); - $copyObj->setRead($this->getRead()); - $copyObj->setWrite($this->getWrite()); - $copyObj->setCreatedAt($this->getCreatedAt()); - $copyObj->setUpdatedAt($this->getUpdatedAt()); - if ($makeNew) { - $copyObj->setNew(true); - $copyObj->setId(NULL); // this is a auto-increment column, so set to default value - } - } - - /** - * Makes a copy of this object that will be inserted as a new row in table when saved. - * It creates a new object filling in the simple attributes, but skipping any primary - * keys that are defined for the table. - * - * If desired, this method can also make copies of all associated (fkey referrers) - * objects. - * - * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. - * @return \Thelia\Model\GroupResource Clone of current object. - * @throws PropelException - */ - public function copy($deepCopy = false) - { - // we use get_class(), because this might be a subclass - $clazz = get_class($this); - $copyObj = new $clazz(); - $this->copyInto($copyObj, $deepCopy); - - return $copyObj; - } - - /** - * Declares an association between this object and a ChildGroup object. - * - * @param ChildGroup $v - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - * @throws PropelException - */ - public function setGroup(ChildGroup $v = null) - { - if ($v === null) { - $this->setGroupId(NULL); - } else { - $this->setGroupId($v->getId()); - } - - $this->aGroup = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildGroup object, it will not be re-added. - if ($v !== null) { - $v->addGroupResource($this); - } - - - return $this; - } - - - /** - * Get the associated ChildGroup object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildGroup The associated ChildGroup object. - * @throws PropelException - */ - public function getGroup(ConnectionInterface $con = null) - { - if ($this->aGroup === null && ($this->group_id !== null)) { - $this->aGroup = ChildGroupQuery::create()->findPk($this->group_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aGroup->addGroupResources($this); - */ - } - - return $this->aGroup; - } - - /** - * Declares an association between this object and a ChildResource object. - * - * @param ChildResource $v - * @return \Thelia\Model\GroupResource The current object (for fluent API support) - * @throws PropelException - */ - public function setResource(ChildResource $v = null) - { - if ($v === null) { - $this->setResourceId(NULL); - } else { - $this->setResourceId($v->getId()); - } - - $this->aResource = $v; - - // Add binding for other direction of this n:n relationship. - // If this object has already been added to the ChildResource object, it will not be re-added. - if ($v !== null) { - $v->addGroupResource($this); - } - - - return $this; - } - - - /** - * Get the associated ChildResource object - * - * @param ConnectionInterface $con Optional Connection object. - * @return ChildResource The associated ChildResource object. - * @throws PropelException - */ - public function getResource(ConnectionInterface $con = null) - { - if ($this->aResource === null && ($this->resource_id !== null)) { - $this->aResource = ChildResourceQuery::create()->findPk($this->resource_id, $con); - /* The following can be used additionally to - guarantee the related object contains a reference - to this object. This level of coupling may, however, be - undesirable since it could result in an only partially populated collection - in the referenced object. - $this->aResource->addGroupResources($this); - */ - } - - return $this->aResource; - } - - /** - * Clears the current object and sets all attributes to their default values - */ - public function clear() - { - $this->id = null; - $this->group_id = null; - $this->resource_id = null; - $this->read = null; - $this->write = null; - $this->created_at = null; - $this->updated_at = null; - $this->alreadyInSave = false; - $this->clearAllReferences(); - $this->applyDefaultValues(); - $this->resetModified(); - $this->setNew(true); - $this->setDeleted(false); - } - - /** - * Resets all references to other model objects or collections of model objects. - * - * This method is a user-space workaround for PHP's inability to garbage collect - * objects with circular references (even in PHP 5.3). This is currently necessary - * when using Propel in certain daemon or large-volume/high-memory operations. - * - * @param boolean $deep Whether to also clear the references on all referrer objects. - */ - public function clearAllReferences($deep = false) - { - if ($deep) { - } // if ($deep) - - $this->aGroup = null; - $this->aResource = null; - } - - /** - * Return the string representation of this object - * - * @return string - */ - public function __toString() - { - return (string) $this->exportTo(GroupResourceTableMap::DEFAULT_STRING_FORMAT); - } - - // timestampable behavior - - /** - * Mark the current object so that the update date doesn't get updated during next save - * - * @return ChildGroupResource The current object (for fluent API support) - */ - public function keepUpdateDateUnchanged() - { - $this->modifiedColumns[] = GroupResourceTableMap::UPDATED_AT; - - return $this; - } - - /** - * Code to be run before persisting the object - * @param ConnectionInterface $con - * @return boolean - */ - public function preSave(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after persisting the object - * @param ConnectionInterface $con - */ - public function postSave(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before inserting to database - * @param ConnectionInterface $con - * @return boolean - */ - public function preInsert(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after inserting to database - * @param ConnectionInterface $con - */ - public function postInsert(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before updating the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preUpdate(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after updating the object in database - * @param ConnectionInterface $con - */ - public function postUpdate(ConnectionInterface $con = null) - { - - } - - /** - * Code to be run before deleting the object in database - * @param ConnectionInterface $con - * @return boolean - */ - public function preDelete(ConnectionInterface $con = null) - { - return true; - } - - /** - * Code to be run after deleting the object in database - * @param ConnectionInterface $con - */ - public function postDelete(ConnectionInterface $con = null) - { - - } - - - /** - * Derived method to catches calls to undefined methods. - * - * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). - * Allows to define default __call() behavior if you overwrite __call() - * - * @param string $name - * @param mixed $params - * - * @return array|string - */ - public function __call($name, $params) - { - if (0 === strpos($name, 'get')) { - $virtualColumn = substr($name, 3); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - - $virtualColumn = lcfirst($virtualColumn); - if ($this->hasVirtualColumn($virtualColumn)) { - return $this->getVirtualColumn($virtualColumn); - } - } - - if (0 === strpos($name, 'from')) { - $format = substr($name, 4); - - return $this->importFrom($format, reset($params)); - } - - if (0 === strpos($name, 'to')) { - $format = substr($name, 2); - $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; - - return $this->exportTo($format, $includeLazyLoadColumns); - } - - throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); - } - -} diff --git a/core/lib/Thelia/Model/Base/GroupResourceQuery.php b/core/lib/Thelia/Model/Base/GroupResourceQuery.php deleted file mode 100644 index e57894707..000000000 --- a/core/lib/Thelia/Model/Base/GroupResourceQuery.php +++ /dev/null @@ -1,868 +0,0 @@ -setModelAlias($modelAlias); - } - if ($criteria instanceof Criteria) { - $query->mergeWith($criteria); - } - - return $query; - } - - /** - * Find object by primary key. - * Propel uses the instance pool to skip the database if the object exists. - * Go fast if the query is untouched. - * - * - * $obj = $c->findPk(array(12, 34, 56), $con); - * - * - * @param array[$id, $group_id, $resource_id] $key Primary key to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ChildGroupResource|array|mixed the result, formatted by the current formatter - */ - public function findPk($key, $con = null) - { - if ($key === null) { - return null; - } - if ((null !== ($obj = GroupResourceTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { - // the object is already in the instance pool - return $obj; - } - if ($con === null) { - $con = Propel::getServiceContainer()->getReadConnection(GroupResourceTableMap::DATABASE_NAME); - } - $this->basePreSelect($con); - if ($this->formatter || $this->modelAlias || $this->with || $this->select - || $this->selectColumns || $this->asColumns || $this->selectModifiers - || $this->map || $this->having || $this->joins) { - return $this->findPkComplex($key, $con); - } else { - return $this->findPkSimple($key, $con); - } - } - - /** - * Find object by primary key using raw SQL to go fast. - * Bypass doSelect() and the object formatter by using generated code. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroupResource A model object, or null if the key is not found - */ - protected function findPkSimple($key, $con) - { - $sql = 'SELECT ID, GROUP_ID, RESOURCE_ID, READ, WRITE, CREATED_AT, UPDATED_AT FROM group_resource WHERE ID = :p0 AND GROUP_ID = :p1 AND RESOURCE_ID = :p2'; - try { - $stmt = $con->prepare($sql); - $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); - $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); - $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT); - $stmt->execute(); - } catch (Exception $e) { - Propel::log($e->getMessage(), Propel::LOG_ERR); - throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); - } - $obj = null; - if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { - $obj = new ChildGroupResource(); - $obj->hydrate($row); - GroupResourceTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); - } - $stmt->closeCursor(); - - return $obj; - } - - /** - * Find object by primary key. - * - * @param mixed $key Primary key to use for the query - * @param ConnectionInterface $con A connection object - * - * @return ChildGroupResource|array|mixed the result, formatted by the current formatter - */ - protected function findPkComplex($key, $con) - { - // As the query uses a PK condition, no limit(1) is necessary. - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKey($key) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); - } - - /** - * Find objects by primary key - * - * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); - * - * @param array $keys Primary keys to use for the query - * @param ConnectionInterface $con an optional connection object - * - * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter - */ - public function findPks($keys, $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); - } - $this->basePreSelect($con); - $criteria = $this->isKeepQuery() ? clone $this : $this; - $dataFetcher = $criteria - ->filterByPrimaryKeys($keys) - ->doSelect($con); - - return $criteria->getFormatter()->init($criteria)->format($dataFetcher); - } - - /** - * Filter the query by primary key - * - * @param mixed $key Primary key to use for the query - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByPrimaryKey($key) - { - $this->addUsingAlias(GroupResourceTableMap::ID, $key[0], Criteria::EQUAL); - $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $key[1], Criteria::EQUAL); - $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL); - - return $this; - } - - /** - * Filter the query by a list of primary keys - * - * @param array $keys The list of primary key to use for the query - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByPrimaryKeys($keys) - { - if (empty($keys)) { - return $this->add(null, '1<>1', Criteria::CUSTOM); - } - foreach ($keys as $key) { - $cton0 = $this->getNewCriterion(GroupResourceTableMap::ID, $key[0], Criteria::EQUAL); - $cton1 = $this->getNewCriterion(GroupResourceTableMap::GROUP_ID, $key[1], Criteria::EQUAL); - $cton0->addAnd($cton1); - $cton2 = $this->getNewCriterion(GroupResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL); - $cton0->addAnd($cton2); - $this->addOr($cton0); - } - - return $this; - } - - /** - * Filter the query on the id column - * - * Example usage: - * - * $query->filterById(1234); // WHERE id = 1234 - * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) - * $query->filterById(array('min' => 12)); // WHERE id > 12 - * - * - * @param mixed $id The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterById($id = null, $comparison = null) - { - if (is_array($id)) { - $useMinMax = false; - if (isset($id['min'])) { - $this->addUsingAlias(GroupResourceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($id['max'])) { - $this->addUsingAlias(GroupResourceTableMap::ID, $id['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourceTableMap::ID, $id, $comparison); - } - - /** - * Filter the query on the group_id column - * - * Example usage: - * - * $query->filterByGroupId(1234); // WHERE group_id = 1234 - * $query->filterByGroupId(array(12, 34)); // WHERE group_id IN (12, 34) - * $query->filterByGroupId(array('min' => 12)); // WHERE group_id > 12 - * - * - * @see filterByGroup() - * - * @param mixed $groupId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByGroupId($groupId = null, $comparison = null) - { - if (is_array($groupId)) { - $useMinMax = false; - if (isset($groupId['min'])) { - $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($groupId['max'])) { - $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourceTableMap::GROUP_ID, $groupId, $comparison); - } - - /** - * Filter the query on the resource_id column - * - * Example usage: - * - * $query->filterByResourceId(1234); // WHERE resource_id = 1234 - * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34) - * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12 - * - * - * @see filterByResource() - * - * @param mixed $resourceId The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByResourceId($resourceId = null, $comparison = null) - { - if (is_array($resourceId)) { - $useMinMax = false; - if (isset($resourceId['min'])) { - $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($resourceId['max'])) { - $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resourceId, $comparison); - } - - /** - * Filter the query on the read column - * - * Example usage: - * - * $query->filterByRead(1234); // WHERE read = 1234 - * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34) - * $query->filterByRead(array('min' => 12)); // WHERE read > 12 - * - * - * @param mixed $read The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByRead($read = null, $comparison = null) - { - if (is_array($read)) { - $useMinMax = false; - if (isset($read['min'])) { - $this->addUsingAlias(GroupResourceTableMap::READ, $read['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($read['max'])) { - $this->addUsingAlias(GroupResourceTableMap::READ, $read['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourceTableMap::READ, $read, $comparison); - } - - /** - * Filter the query on the write column - * - * Example usage: - * - * $query->filterByWrite(1234); // WHERE write = 1234 - * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34) - * $query->filterByWrite(array('min' => 12)); // WHERE write > 12 - * - * - * @param mixed $write The value to use as filter. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByWrite($write = null, $comparison = null) - { - if (is_array($write)) { - $useMinMax = false; - if (isset($write['min'])) { - $this->addUsingAlias(GroupResourceTableMap::WRITE, $write['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($write['max'])) { - $this->addUsingAlias(GroupResourceTableMap::WRITE, $write['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourceTableMap::WRITE, $write, $comparison); - } - - /** - * Filter the query on the created_at column - * - * Example usage: - * - * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' - * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' - * - * - * @param mixed $createdAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByCreatedAt($createdAt = null, $comparison = null) - { - if (is_array($createdAt)) { - $useMinMax = false; - if (isset($createdAt['min'])) { - $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($createdAt['max'])) { - $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, $createdAt, $comparison); - } - - /** - * Filter the query on the updated_at column - * - * Example usage: - * - * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' - * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' - * - * - * @param mixed $updatedAt The value to use as filter. - * Values can be integers (unix timestamps), DateTime objects, or strings. - * Empty strings are treated as NULL. - * Use scalar values for equality. - * Use array values for in_array() equivalent. - * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByUpdatedAt($updatedAt = null, $comparison = null) - { - if (is_array($updatedAt)) { - $useMinMax = false; - if (isset($updatedAt['min'])) { - $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); - $useMinMax = true; - } - if (isset($updatedAt['max'])) { - $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); - $useMinMax = true; - } - if ($useMinMax) { - return $this; - } - if (null === $comparison) { - $comparison = Criteria::IN; - } - } - - return $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, $updatedAt, $comparison); - } - - /** - * Filter the query by a related \Thelia\Model\Group object - * - * @param \Thelia\Model\Group|ObjectCollection $group The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByGroup($group, $comparison = null) - { - if ($group instanceof \Thelia\Model\Group) { - return $this - ->addUsingAlias(GroupResourceTableMap::GROUP_ID, $group->getId(), $comparison); - } elseif ($group instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupResourceTableMap::GROUP_ID, $group->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByGroup() only accepts arguments of type \Thelia\Model\Group or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Group relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function joinGroup($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Group'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Group'); - } - - return $this; - } - - /** - * Use the Group relation Group object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\GroupQuery A secondary query class using the current class as primary query - */ - public function useGroupQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinGroup($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Group', '\Thelia\Model\GroupQuery'); - } - - /** - * Filter the query by a related \Thelia\Model\Resource object - * - * @param \Thelia\Model\Resource|ObjectCollection $resource The related object(s) to use as filter - * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function filterByResource($resource, $comparison = null) - { - if ($resource instanceof \Thelia\Model\Resource) { - return $this - ->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resource->getId(), $comparison); - } elseif ($resource instanceof ObjectCollection) { - if (null === $comparison) { - $comparison = Criteria::IN; - } - - return $this - ->addUsingAlias(GroupResourceTableMap::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); - } else { - throw new PropelException('filterByResource() only accepts arguments of type \Thelia\Model\Resource or Collection'); - } - } - - /** - * Adds a JOIN clause to the query using the Resource relation - * - * @param string $relationAlias optional alias for the relation - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('Resource'); - - // create a ModelJoin object for this join - $join = new ModelJoin(); - $join->setJoinType($joinType); - $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); - if ($previousJoin = $this->getPreviousJoin()) { - $join->setPreviousJoin($previousJoin); - } - - // add the ModelJoin to the current object - if ($relationAlias) { - $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); - $this->addJoinObject($join, $relationAlias); - } else { - $this->addJoinObject($join, 'Resource'); - } - - return $this; - } - - /** - * Use the Resource relation Resource object - * - * @see useQuery() - * - * @param string $relationAlias optional alias for the relation, - * to be used as main alias in the secondary query - * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' - * - * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query - */ - public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) - { - return $this - ->joinResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery'); - } - - /** - * Exclude object from result - * - * @param ChildGroupResource $groupResource Object to remove from the list of results - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function prune($groupResource = null) - { - if ($groupResource) { - $this->addCond('pruneCond0', $this->getAliasedColName(GroupResourceTableMap::ID), $groupResource->getId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond1', $this->getAliasedColName(GroupResourceTableMap::GROUP_ID), $groupResource->getGroupId(), Criteria::NOT_EQUAL); - $this->addCond('pruneCond2', $this->getAliasedColName(GroupResourceTableMap::RESOURCE_ID), $groupResource->getResourceId(), Criteria::NOT_EQUAL); - $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); - } - - return $this; - } - - /** - * Deletes all rows from the group_resource table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public function doDeleteAll(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); - } - $affectedRows = 0; // initialize var to track total num of affected rows - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - $affectedRows += parent::doDeleteAll($con); - // Because this db requires some delete cascade/set null emulation, we have to - // clear the cached instance *after* the emulation has happened (since - // instances get re-added by the select statement contained therein). - GroupResourceTableMap::clearInstancePool(); - GroupResourceTableMap::clearRelatedInstancePool(); - - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $affectedRows; - } - - /** - * Performs a DELETE on the database, given a ChildGroupResource or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or ChildGroupResource object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public function delete(ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); - } - - $criteria = $this; - - // Set the correct dbName - $criteria->setDbName(GroupResourceTableMap::DATABASE_NAME); - - $affectedRows = 0; // initialize var to track total num of affected rows - - try { - // use transaction because $criteria could contain info - // for more than one table or we could emulating ON DELETE CASCADE, etc. - $con->beginTransaction(); - - - GroupResourceTableMap::removeInstanceFromPool($criteria); - - $affectedRows += ModelCriteria::delete($con); - GroupResourceTableMap::clearRelatedInstancePool(); - $con->commit(); - - return $affectedRows; - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - } - - // timestampable behavior - - /** - * Filter by the latest updated - * - * @param int $nbDays Maximum age of the latest update in days - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function recentlyUpdated($nbDays = 7) - { - return $this->addUsingAlias(GroupResourceTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Filter by the latest created - * - * @param int $nbDays Maximum age of in days - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function recentlyCreated($nbDays = 7) - { - return $this->addUsingAlias(GroupResourceTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); - } - - /** - * Order by update date desc - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function lastUpdatedFirst() - { - return $this->addDescendingOrderByColumn(GroupResourceTableMap::UPDATED_AT); - } - - /** - * Order by update date asc - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function firstUpdatedFirst() - { - return $this->addAscendingOrderByColumn(GroupResourceTableMap::UPDATED_AT); - } - - /** - * Order by create date desc - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function lastCreatedFirst() - { - return $this->addDescendingOrderByColumn(GroupResourceTableMap::CREATED_AT); - } - - /** - * Order by create date asc - * - * @return ChildGroupResourceQuery The current query, for fluid interface - */ - public function firstCreatedFirst() - { - return $this->addAscendingOrderByColumn(GroupResourceTableMap::CREATED_AT); - } - -} // GroupResourceQuery diff --git a/core/lib/Thelia/Model/Base/Module.php b/core/lib/Thelia/Model/Base/Module.php index 09858a877..81ef0e128 100644 --- a/core/lib/Thelia/Model/Base/Module.php +++ b/core/lib/Thelia/Model/Base/Module.php @@ -19,8 +19,6 @@ use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; use Thelia\Model\AreaDeliveryModule as ChildAreaDeliveryModule; use Thelia\Model\AreaDeliveryModuleQuery as ChildAreaDeliveryModuleQuery; -use Thelia\Model\GroupModule as ChildGroupModule; -use Thelia\Model\GroupModuleQuery as ChildGroupModuleQuery; use Thelia\Model\Module as ChildModule; use Thelia\Model\ModuleI18n as ChildModuleI18n; use Thelia\Model\ModuleI18nQuery as ChildModuleI18nQuery; @@ -29,6 +27,8 @@ use Thelia\Model\ModuleImageQuery as ChildModuleImageQuery; use Thelia\Model\ModuleQuery as ChildModuleQuery; use Thelia\Model\Order as ChildOrder; use Thelia\Model\OrderQuery as ChildOrderQuery; +use Thelia\Model\ProfileModule as ChildProfileModule; +use Thelia\Model\ProfileModuleQuery as ChildProfileModuleQuery; use Thelia\Model\Map\ModuleTableMap; abstract class Module implements ActiveRecordInterface @@ -132,10 +132,10 @@ abstract class Module implements ActiveRecordInterface protected $collAreaDeliveryModulesPartial; /** - * @var ObjectCollection|ChildGroupModule[] Collection to store aggregation of ChildGroupModule objects. + * @var ObjectCollection|ChildProfileModule[] Collection to store aggregation of ChildProfileModule objects. */ - protected $collGroupModules; - protected $collGroupModulesPartial; + protected $collProfileModules; + protected $collProfileModulesPartial; /** * @var ObjectCollection|ChildModuleImage[] Collection to store aggregation of ChildModuleImage objects. @@ -193,7 +193,7 @@ abstract class Module implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $groupModulesScheduledForDeletion = null; + protected $profileModulesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -880,7 +880,7 @@ abstract class Module implements ActiveRecordInterface $this->collAreaDeliveryModules = null; - $this->collGroupModules = null; + $this->collProfileModules = null; $this->collModuleImages = null; @@ -1070,17 +1070,17 @@ abstract class Module implements ActiveRecordInterface } } - if ($this->groupModulesScheduledForDeletion !== null) { - if (!$this->groupModulesScheduledForDeletion->isEmpty()) { - \Thelia\Model\GroupModuleQuery::create() - ->filterByPrimaryKeys($this->groupModulesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->profileModulesScheduledForDeletion !== null) { + if (!$this->profileModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProfileModuleQuery::create() + ->filterByPrimaryKeys($this->profileModulesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->groupModulesScheduledForDeletion = null; + $this->profileModulesScheduledForDeletion = null; } } - if ($this->collGroupModules !== null) { - foreach ($this->collGroupModules as $referrerFK) { + if ($this->collProfileModules !== null) { + foreach ($this->collProfileModules as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1345,8 +1345,8 @@ abstract class Module implements ActiveRecordInterface if (null !== $this->collAreaDeliveryModules) { $result['AreaDeliveryModules'] = $this->collAreaDeliveryModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } - if (null !== $this->collGroupModules) { - $result['GroupModules'] = $this->collGroupModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProfileModules) { + $result['ProfileModules'] = $this->collProfileModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collModuleImages) { $result['ModuleImages'] = $this->collModuleImages->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1557,9 +1557,9 @@ abstract class Module implements ActiveRecordInterface } } - foreach ($this->getGroupModules() as $relObj) { + foreach ($this->getProfileModules() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupModule($relObj->copy($deepCopy)); + $copyObj->addProfileModule($relObj->copy($deepCopy)); } } @@ -1625,8 +1625,8 @@ abstract class Module implements ActiveRecordInterface if ('AreaDeliveryModule' == $relationName) { return $this->initAreaDeliveryModules(); } - if ('GroupModule' == $relationName) { - return $this->initGroupModules(); + if ('ProfileModule' == $relationName) { + return $this->initProfileModules(); } if ('ModuleImage' == $relationName) { return $this->initModuleImages(); @@ -2616,31 +2616,31 @@ abstract class Module implements ActiveRecordInterface } /** - * Clears out the collGroupModules collection + * Clears out the collProfileModules collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addGroupModules() + * @see addProfileModules() */ - public function clearGroupModules() + public function clearProfileModules() { - $this->collGroupModules = null; // important to set this to NULL since that means it is uninitialized + $this->collProfileModules = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collGroupModules collection loaded partially. + * Reset is the collProfileModules collection loaded partially. */ - public function resetPartialGroupModules($v = true) + public function resetPartialProfileModules($v = true) { - $this->collGroupModulesPartial = $v; + $this->collProfileModulesPartial = $v; } /** - * Initializes the collGroupModules collection. + * Initializes the collProfileModules collection. * - * By default this just sets the collGroupModules collection to an empty array (like clearcollGroupModules()); + * By default this just sets the collProfileModules collection to an empty array (like clearcollProfileModules()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -2649,17 +2649,17 @@ abstract class Module implements ActiveRecordInterface * * @return void */ - public function initGroupModules($overrideExisting = true) + public function initProfileModules($overrideExisting = true) { - if (null !== $this->collGroupModules && !$overrideExisting) { + if (null !== $this->collProfileModules && !$overrideExisting) { return; } - $this->collGroupModules = new ObjectCollection(); - $this->collGroupModules->setModel('\Thelia\Model\GroupModule'); + $this->collProfileModules = new ObjectCollection(); + $this->collProfileModules->setModel('\Thelia\Model\ProfileModule'); } /** - * Gets an array of ChildGroupModule objects which contain a foreign key that references this object. + * Gets an array of ChildProfileModule objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -2669,109 +2669,109 @@ abstract class Module implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildGroupModule[] List of ChildGroupModule objects + * @return Collection|ChildProfileModule[] List of ChildProfileModule objects * @throws PropelException */ - public function getGroupModules($criteria = null, ConnectionInterface $con = null) + public function getProfileModules($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { + $partial = $this->collProfileModulesPartial && !$this->isNew(); + if (null === $this->collProfileModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileModules) { // return empty collection - $this->initGroupModules(); + $this->initProfileModules(); } else { - $collGroupModules = ChildGroupModuleQuery::create(null, $criteria) + $collProfileModules = ChildProfileModuleQuery::create(null, $criteria) ->filterByModule($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collGroupModulesPartial && count($collGroupModules)) { - $this->initGroupModules(false); + if (false !== $this->collProfileModulesPartial && count($collProfileModules)) { + $this->initProfileModules(false); - foreach ($collGroupModules as $obj) { - if (false == $this->collGroupModules->contains($obj)) { - $this->collGroupModules->append($obj); + foreach ($collProfileModules as $obj) { + if (false == $this->collProfileModules->contains($obj)) { + $this->collProfileModules->append($obj); } } - $this->collGroupModulesPartial = true; + $this->collProfileModulesPartial = true; } - $collGroupModules->getInternalIterator()->rewind(); + $collProfileModules->getInternalIterator()->rewind(); - return $collGroupModules; + return $collProfileModules; } - if ($partial && $this->collGroupModules) { - foreach ($this->collGroupModules as $obj) { + if ($partial && $this->collProfileModules) { + foreach ($this->collProfileModules as $obj) { if ($obj->isNew()) { - $collGroupModules[] = $obj; + $collProfileModules[] = $obj; } } } - $this->collGroupModules = $collGroupModules; - $this->collGroupModulesPartial = false; + $this->collProfileModules = $collProfileModules; + $this->collProfileModulesPartial = false; } } - return $this->collGroupModules; + return $this->collProfileModules; } /** - * Sets a collection of GroupModule objects related by a one-to-many relationship + * Sets a collection of ProfileModule objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $groupModules A Propel collection. + * @param Collection $profileModules A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildModule The current object (for fluent API support) */ - public function setGroupModules(Collection $groupModules, ConnectionInterface $con = null) + public function setProfileModules(Collection $profileModules, ConnectionInterface $con = null) { - $groupModulesToDelete = $this->getGroupModules(new Criteria(), $con)->diff($groupModules); + $profileModulesToDelete = $this->getProfileModules(new Criteria(), $con)->diff($profileModules); - $this->groupModulesScheduledForDeletion = $groupModulesToDelete; + $this->profileModulesScheduledForDeletion = $profileModulesToDelete; - foreach ($groupModulesToDelete as $groupModuleRemoved) { - $groupModuleRemoved->setModule(null); + foreach ($profileModulesToDelete as $profileModuleRemoved) { + $profileModuleRemoved->setModule(null); } - $this->collGroupModules = null; - foreach ($groupModules as $groupModule) { - $this->addGroupModule($groupModule); + $this->collProfileModules = null; + foreach ($profileModules as $profileModule) { + $this->addProfileModule($profileModule); } - $this->collGroupModules = $groupModules; - $this->collGroupModulesPartial = false; + $this->collProfileModules = $profileModules; + $this->collProfileModulesPartial = false; return $this; } /** - * Returns the number of related GroupModule objects. + * Returns the number of related ProfileModule objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related GroupModule objects. + * @return int Count of related ProfileModule objects. * @throws PropelException */ - public function countGroupModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProfileModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collGroupModulesPartial && !$this->isNew(); - if (null === $this->collGroupModules || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupModules) { + $partial = $this->collProfileModulesPartial && !$this->isNew(); + if (null === $this->collProfileModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileModules) { return 0; } if ($partial && !$criteria) { - return count($this->getGroupModules()); + return count($this->getProfileModules()); } - $query = ChildGroupModuleQuery::create(null, $criteria); + $query = ChildProfileModuleQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -2781,53 +2781,53 @@ abstract class Module implements ActiveRecordInterface ->count($con); } - return count($this->collGroupModules); + return count($this->collProfileModules); } /** - * Method called to associate a ChildGroupModule object to this object - * through the ChildGroupModule foreign key attribute. + * Method called to associate a ChildProfileModule object to this object + * through the ChildProfileModule foreign key attribute. * - * @param ChildGroupModule $l ChildGroupModule + * @param ChildProfileModule $l ChildProfileModule * @return \Thelia\Model\Module The current object (for fluent API support) */ - public function addGroupModule(ChildGroupModule $l) + public function addProfileModule(ChildProfileModule $l) { - if ($this->collGroupModules === null) { - $this->initGroupModules(); - $this->collGroupModulesPartial = true; + if ($this->collProfileModules === null) { + $this->initProfileModules(); + $this->collProfileModulesPartial = true; } - if (!in_array($l, $this->collGroupModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupModule($l); + if (!in_array($l, $this->collProfileModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProfileModule($l); } return $this; } /** - * @param GroupModule $groupModule The groupModule object to add. + * @param ProfileModule $profileModule The profileModule object to add. */ - protected function doAddGroupModule($groupModule) + protected function doAddProfileModule($profileModule) { - $this->collGroupModules[]= $groupModule; - $groupModule->setModule($this); + $this->collProfileModules[]= $profileModule; + $profileModule->setModule($this); } /** - * @param GroupModule $groupModule The groupModule object to remove. + * @param ProfileModule $profileModule The profileModule object to remove. * @return ChildModule The current object (for fluent API support) */ - public function removeGroupModule($groupModule) + public function removeProfileModule($profileModule) { - if ($this->getGroupModules()->contains($groupModule)) { - $this->collGroupModules->remove($this->collGroupModules->search($groupModule)); - if (null === $this->groupModulesScheduledForDeletion) { - $this->groupModulesScheduledForDeletion = clone $this->collGroupModules; - $this->groupModulesScheduledForDeletion->clear(); + if ($this->getProfileModules()->contains($profileModule)) { + $this->collProfileModules->remove($this->collProfileModules->search($profileModule)); + if (null === $this->profileModulesScheduledForDeletion) { + $this->profileModulesScheduledForDeletion = clone $this->collProfileModules; + $this->profileModulesScheduledForDeletion->clear(); } - $this->groupModulesScheduledForDeletion[]= $groupModule; - $groupModule->setModule(null); + $this->profileModulesScheduledForDeletion[]= $profileModule; + $profileModule->setModule(null); } return $this; @@ -2839,7 +2839,7 @@ abstract class Module implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this Module is new, it will return * an empty collection; or if this Module has previously - * been saved, it will retrieve related GroupModules from storage. + * been saved, it will retrieve related ProfileModules from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -2848,14 +2848,14 @@ abstract class Module implements ActiveRecordInterface * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildGroupModule[] List of ChildGroupModule objects + * @return Collection|ChildProfileModule[] List of ChildProfileModule objects */ - public function getGroupModulesJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getProfileModulesJoinProfile($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ChildGroupModuleQuery::create(null, $criteria); - $query->joinWith('Group', $joinBehavior); + $query = ChildProfileModuleQuery::create(null, $criteria); + $query->joinWith('Profile', $joinBehavior); - return $this->getGroupModules($query, $con); + return $this->getProfileModules($query, $con); } /** @@ -3348,8 +3348,8 @@ abstract class Module implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collGroupModules) { - foreach ($this->collGroupModules as $o) { + if ($this->collProfileModules) { + foreach ($this->collProfileModules as $o) { $o->clearAllReferences($deep); } } @@ -3381,10 +3381,10 @@ abstract class Module implements ActiveRecordInterface $this->collAreaDeliveryModules->clearIterator(); } $this->collAreaDeliveryModules = null; - if ($this->collGroupModules instanceof Collection) { - $this->collGroupModules->clearIterator(); + if ($this->collProfileModules instanceof Collection) { + $this->collProfileModules->clearIterator(); } - $this->collGroupModules = null; + $this->collProfileModules = null; if ($this->collModuleImages instanceof Collection) { $this->collModuleImages->clearIterator(); } diff --git a/core/lib/Thelia/Model/Base/ModuleQuery.php b/core/lib/Thelia/Model/Base/ModuleQuery.php index 4031a4f63..4f953b97f 100644 --- a/core/lib/Thelia/Model/Base/ModuleQuery.php +++ b/core/lib/Thelia/Model/Base/ModuleQuery.php @@ -56,9 +56,9 @@ use Thelia\Model\Map\ModuleTableMap; * @method ChildModuleQuery rightJoinAreaDeliveryModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the AreaDeliveryModule relation * @method ChildModuleQuery innerJoinAreaDeliveryModule($relationAlias = null) Adds a INNER JOIN clause to the query using the AreaDeliveryModule relation * - * @method ChildModuleQuery leftJoinGroupModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupModule relation - * @method ChildModuleQuery rightJoinGroupModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupModule relation - * @method ChildModuleQuery innerJoinGroupModule($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupModule relation + * @method ChildModuleQuery leftJoinProfileModule($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProfileModule relation + * @method ChildModuleQuery rightJoinProfileModule($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProfileModule relation + * @method ChildModuleQuery innerJoinProfileModule($relationAlias = null) Adds a INNER JOIN clause to the query using the ProfileModule relation * * @method ChildModuleQuery leftJoinModuleImage($relationAlias = null) Adds a LEFT JOIN clause to the query using the ModuleImage relation * @method ChildModuleQuery rightJoinModuleImage($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ModuleImage relation @@ -793,40 +793,40 @@ abstract class ModuleQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\GroupModule object + * Filter the query by a related \Thelia\Model\ProfileModule object * - * @param \Thelia\Model\GroupModule|ObjectCollection $groupModule the related object to use as filter + * @param \Thelia\Model\ProfileModule|ObjectCollection $profileModule the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildModuleQuery The current query, for fluid interface */ - public function filterByGroupModule($groupModule, $comparison = null) + public function filterByProfileModule($profileModule, $comparison = null) { - if ($groupModule instanceof \Thelia\Model\GroupModule) { + if ($profileModule instanceof \Thelia\Model\ProfileModule) { return $this - ->addUsingAlias(ModuleTableMap::ID, $groupModule->getModuleId(), $comparison); - } elseif ($groupModule instanceof ObjectCollection) { + ->addUsingAlias(ModuleTableMap::ID, $profileModule->getModuleId(), $comparison); + } elseif ($profileModule instanceof ObjectCollection) { return $this - ->useGroupModuleQuery() - ->filterByPrimaryKeys($groupModule->getPrimaryKeys()) + ->useProfileModuleQuery() + ->filterByPrimaryKeys($profileModule->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupModule() only accepts arguments of type \Thelia\Model\GroupModule or Collection'); + throw new PropelException('filterByProfileModule() only accepts arguments of type \Thelia\Model\ProfileModule or Collection'); } } /** - * Adds a JOIN clause to the query using the GroupModule relation + * Adds a JOIN clause to the query using the ProfileModule relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildModuleQuery The current query, for fluid interface */ - public function joinGroupModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function joinProfileModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupModule'); + $relationMap = $tableMap->getRelation('ProfileModule'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -841,14 +841,14 @@ abstract class ModuleQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'GroupModule'); + $this->addJoinObject($join, 'ProfileModule'); } return $this; } /** - * Use the GroupModule relation GroupModule object + * Use the ProfileModule relation ProfileModule object * * @see useQuery() * @@ -856,13 +856,13 @@ abstract class ModuleQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\GroupModuleQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProfileModuleQuery A secondary query class using the current class as primary query */ - public function useGroupModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + public function useProfileModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) { return $this - ->joinGroupModule($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupModule', '\Thelia\Model\GroupModuleQuery'); + ->joinProfileModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProfileModule', '\Thelia\Model\ProfileModuleQuery'); } /** diff --git a/core/lib/Thelia/Model/Base/OrderProduct.php b/core/lib/Thelia/Model/Base/OrderProduct.php index 69e927214..0cf8c80b6 100644 --- a/core/lib/Thelia/Model/Base/OrderProduct.php +++ b/core/lib/Thelia/Model/Base/OrderProduct.php @@ -145,6 +145,12 @@ abstract class OrderProduct implements ActiveRecordInterface */ protected $weight; + /** + * The value for the ean_code field. + * @var string + */ + protected $ean_code; + /** * The value for the tax_rule_title field. * @var string @@ -624,6 +630,17 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->weight; } + /** + * Get the [ean_code] column value. + * + * @return string + */ + public function getEanCode() + { + + return $this->ean_code; + } + /** * Get the [tax_rule_title] column value. * @@ -995,6 +1012,27 @@ abstract class OrderProduct implements ActiveRecordInterface return $this; } // setWeight() + /** + * Set the value of [ean_code] column. + * + * @param string $v new value + * @return \Thelia\Model\OrderProduct The current object (for fluent API support) + */ + public function setEanCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->ean_code !== $v) { + $this->ean_code = $v; + $this->modifiedColumns[] = OrderProductTableMap::EAN_CODE; + } + + + return $this; + } // setEanCode() + /** * Set the value of [tax_rule_title] column. * @@ -1179,22 +1217,25 @@ abstract class OrderProduct implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 13 + $startcol : OrderProductTableMap::translateFieldName('Weight', TableMap::TYPE_PHPNAME, $indexType)]; $this->weight = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleTitle', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 14 + $startcol : OrderProductTableMap::translateFieldName('EanCode', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ean_code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleTitle', TableMap::TYPE_PHPNAME, $indexType)]; $this->tax_rule_title = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 15 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleDescription', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderProductTableMap::translateFieldName('TaxRuleDescription', TableMap::TYPE_PHPNAME, $indexType)]; $this->tax_rule_description = (null !== $col) ? (string) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 16 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderProductTableMap::translateFieldName('Parent', TableMap::TYPE_PHPNAME, $indexType)]; $this->parent = (null !== $col) ? (int) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 17 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : OrderProductTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 18 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 19 + $startcol : OrderProductTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -1207,7 +1248,7 @@ abstract class OrderProduct implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 19; // 19 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 20; // 20 = OrderProductTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\OrderProduct object", 0, $e); @@ -1523,6 +1564,9 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) { $modifiedColumns[':p' . $index++] = 'WEIGHT'; } + if ($this->isColumnModified(OrderProductTableMap::EAN_CODE)) { + $modifiedColumns[':p' . $index++] = 'EAN_CODE'; + } if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) { $modifiedColumns[':p' . $index++] = 'TAX_RULE_TITLE'; } @@ -1591,6 +1635,9 @@ abstract class OrderProduct implements ActiveRecordInterface case 'WEIGHT': $stmt->bindValue($identifier, $this->weight, PDO::PARAM_STR); break; + case 'EAN_CODE': + $stmt->bindValue($identifier, $this->ean_code, PDO::PARAM_STR); + break; case 'TAX_RULE_TITLE': $stmt->bindValue($identifier, $this->tax_rule_title, PDO::PARAM_STR); break; @@ -1711,18 +1758,21 @@ abstract class OrderProduct implements ActiveRecordInterface return $this->getWeight(); break; case 14: - return $this->getTaxRuleTitle(); + return $this->getEanCode(); break; case 15: - return $this->getTaxRuleDescription(); + return $this->getTaxRuleTitle(); break; case 16: - return $this->getParent(); + return $this->getTaxRuleDescription(); break; case 17: - return $this->getCreatedAt(); + return $this->getParent(); break; case 18: + return $this->getCreatedAt(); + break; + case 19: return $this->getUpdatedAt(); break; default: @@ -1768,11 +1818,12 @@ abstract class OrderProduct implements ActiveRecordInterface $keys[11] => $this->getWasNew(), $keys[12] => $this->getWasInPromo(), $keys[13] => $this->getWeight(), - $keys[14] => $this->getTaxRuleTitle(), - $keys[15] => $this->getTaxRuleDescription(), - $keys[16] => $this->getParent(), - $keys[17] => $this->getCreatedAt(), - $keys[18] => $this->getUpdatedAt(), + $keys[14] => $this->getEanCode(), + $keys[15] => $this->getTaxRuleTitle(), + $keys[16] => $this->getTaxRuleDescription(), + $keys[17] => $this->getParent(), + $keys[18] => $this->getCreatedAt(), + $keys[19] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1866,18 +1917,21 @@ abstract class OrderProduct implements ActiveRecordInterface $this->setWeight($value); break; case 14: - $this->setTaxRuleTitle($value); + $this->setEanCode($value); break; case 15: - $this->setTaxRuleDescription($value); + $this->setTaxRuleTitle($value); break; case 16: - $this->setParent($value); + $this->setTaxRuleDescription($value); break; case 17: - $this->setCreatedAt($value); + $this->setParent($value); break; case 18: + $this->setCreatedAt($value); + break; + case 19: $this->setUpdatedAt($value); break; } // switch() @@ -1918,11 +1972,12 @@ abstract class OrderProduct implements ActiveRecordInterface if (array_key_exists($keys[11], $arr)) $this->setWasNew($arr[$keys[11]]); if (array_key_exists($keys[12], $arr)) $this->setWasInPromo($arr[$keys[12]]); if (array_key_exists($keys[13], $arr)) $this->setWeight($arr[$keys[13]]); - if (array_key_exists($keys[14], $arr)) $this->setTaxRuleTitle($arr[$keys[14]]); - if (array_key_exists($keys[15], $arr)) $this->setTaxRuleDescription($arr[$keys[15]]); - if (array_key_exists($keys[16], $arr)) $this->setParent($arr[$keys[16]]); - if (array_key_exists($keys[17], $arr)) $this->setCreatedAt($arr[$keys[17]]); - if (array_key_exists($keys[18], $arr)) $this->setUpdatedAt($arr[$keys[18]]); + if (array_key_exists($keys[14], $arr)) $this->setEanCode($arr[$keys[14]]); + if (array_key_exists($keys[15], $arr)) $this->setTaxRuleTitle($arr[$keys[15]]); + if (array_key_exists($keys[16], $arr)) $this->setTaxRuleDescription($arr[$keys[16]]); + if (array_key_exists($keys[17], $arr)) $this->setParent($arr[$keys[17]]); + if (array_key_exists($keys[18], $arr)) $this->setCreatedAt($arr[$keys[18]]); + if (array_key_exists($keys[19], $arr)) $this->setUpdatedAt($arr[$keys[19]]); } /** @@ -1948,6 +2003,7 @@ abstract class OrderProduct implements ActiveRecordInterface if ($this->isColumnModified(OrderProductTableMap::WAS_NEW)) $criteria->add(OrderProductTableMap::WAS_NEW, $this->was_new); if ($this->isColumnModified(OrderProductTableMap::WAS_IN_PROMO)) $criteria->add(OrderProductTableMap::WAS_IN_PROMO, $this->was_in_promo); if ($this->isColumnModified(OrderProductTableMap::WEIGHT)) $criteria->add(OrderProductTableMap::WEIGHT, $this->weight); + if ($this->isColumnModified(OrderProductTableMap::EAN_CODE)) $criteria->add(OrderProductTableMap::EAN_CODE, $this->ean_code); if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_TITLE)) $criteria->add(OrderProductTableMap::TAX_RULE_TITLE, $this->tax_rule_title); if ($this->isColumnModified(OrderProductTableMap::TAX_RULE_DESCRIPTION)) $criteria->add(OrderProductTableMap::TAX_RULE_DESCRIPTION, $this->tax_rule_description); if ($this->isColumnModified(OrderProductTableMap::PARENT)) $criteria->add(OrderProductTableMap::PARENT, $this->parent); @@ -2029,6 +2085,7 @@ abstract class OrderProduct implements ActiveRecordInterface $copyObj->setWasNew($this->getWasNew()); $copyObj->setWasInPromo($this->getWasInPromo()); $copyObj->setWeight($this->getWeight()); + $copyObj->setEanCode($this->getEanCode()); $copyObj->setTaxRuleTitle($this->getTaxRuleTitle()); $copyObj->setTaxRuleDescription($this->getTaxRuleDescription()); $copyObj->setParent($this->getParent()); @@ -2607,6 +2664,7 @@ abstract class OrderProduct implements ActiveRecordInterface $this->was_new = null; $this->was_in_promo = null; $this->weight = null; + $this->ean_code = null; $this->tax_rule_title = null; $this->tax_rule_description = null; $this->parent = null; diff --git a/core/lib/Thelia/Model/Base/OrderProductQuery.php b/core/lib/Thelia/Model/Base/OrderProductQuery.php index f28102dfb..4bf32e83d 100644 --- a/core/lib/Thelia/Model/Base/OrderProductQuery.php +++ b/core/lib/Thelia/Model/Base/OrderProductQuery.php @@ -35,6 +35,7 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery orderByWasNew($order = Criteria::ASC) Order by the was_new column * @method ChildOrderProductQuery orderByWasInPromo($order = Criteria::ASC) Order by the was_in_promo column * @method ChildOrderProductQuery orderByWeight($order = Criteria::ASC) Order by the weight column + * @method ChildOrderProductQuery orderByEanCode($order = Criteria::ASC) Order by the ean_code column * @method ChildOrderProductQuery orderByTaxRuleTitle($order = Criteria::ASC) Order by the tax_rule_title column * @method ChildOrderProductQuery orderByTaxRuleDescription($order = Criteria::ASC) Order by the tax_rule_description column * @method ChildOrderProductQuery orderByParent($order = Criteria::ASC) Order by the parent column @@ -55,6 +56,7 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProductQuery groupByWasNew() Group by the was_new column * @method ChildOrderProductQuery groupByWasInPromo() Group by the was_in_promo column * @method ChildOrderProductQuery groupByWeight() Group by the weight column + * @method ChildOrderProductQuery groupByEanCode() Group by the ean_code column * @method ChildOrderProductQuery groupByTaxRuleTitle() Group by the tax_rule_title column * @method ChildOrderProductQuery groupByTaxRuleDescription() Group by the tax_rule_description column * @method ChildOrderProductQuery groupByParent() Group by the parent column @@ -94,6 +96,7 @@ use Thelia\Model\Map\OrderProductTableMap; * @method ChildOrderProduct findOneByWasNew(int $was_new) Return the first ChildOrderProduct filtered by the was_new column * @method ChildOrderProduct findOneByWasInPromo(int $was_in_promo) Return the first ChildOrderProduct filtered by the was_in_promo column * @method ChildOrderProduct findOneByWeight(string $weight) Return the first ChildOrderProduct filtered by the weight column + * @method ChildOrderProduct findOneByEanCode(string $ean_code) Return the first ChildOrderProduct filtered by the ean_code column * @method ChildOrderProduct findOneByTaxRuleTitle(string $tax_rule_title) Return the first ChildOrderProduct filtered by the tax_rule_title column * @method ChildOrderProduct findOneByTaxRuleDescription(string $tax_rule_description) Return the first ChildOrderProduct filtered by the tax_rule_description column * @method ChildOrderProduct findOneByParent(int $parent) Return the first ChildOrderProduct filtered by the parent column @@ -114,6 +117,7 @@ use Thelia\Model\Map\OrderProductTableMap; * @method array findByWasNew(int $was_new) Return ChildOrderProduct objects filtered by the was_new column * @method array findByWasInPromo(int $was_in_promo) Return ChildOrderProduct objects filtered by the was_in_promo column * @method array findByWeight(string $weight) Return ChildOrderProduct objects filtered by the weight column + * @method array findByEanCode(string $ean_code) Return ChildOrderProduct objects filtered by the ean_code column * @method array findByTaxRuleTitle(string $tax_rule_title) Return ChildOrderProduct objects filtered by the tax_rule_title column * @method array findByTaxRuleDescription(string $tax_rule_description) Return ChildOrderProduct objects filtered by the tax_rule_description column * @method array findByParent(int $parent) Return ChildOrderProduct objects filtered by the parent column @@ -207,7 +211,7 @@ abstract class OrderProductQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, TAX_RULE_TITLE, TAX_RULE_DESCRIPTION, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; + $sql = 'SELECT ID, ORDER_ID, PRODUCT_REF, PRODUCT_SALE_ELEMENTS_REF, TITLE, CHAPO, DESCRIPTION, POSTSCRIPTUM, QUANTITY, PRICE, PROMO_PRICE, WAS_NEW, WAS_IN_PROMO, WEIGHT, EAN_CODE, TAX_RULE_TITLE, TAX_RULE_DESCRIPTION, PARENT, CREATED_AT, UPDATED_AT FROM order_product WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -776,6 +780,35 @@ abstract class OrderProductQuery extends ModelCriteria return $this->addUsingAlias(OrderProductTableMap::WEIGHT, $weight, $comparison); } + /** + * Filter the query on the ean_code column + * + * Example usage: + * + * $query->filterByEanCode('fooValue'); // WHERE ean_code = 'fooValue' + * $query->filterByEanCode('%fooValue%'); // WHERE ean_code LIKE '%fooValue%' + * + * + * @param string $eanCode The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildOrderProductQuery The current query, for fluid interface + */ + public function filterByEanCode($eanCode = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($eanCode)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $eanCode)) { + $eanCode = str_replace('*', '%', $eanCode); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(OrderProductTableMap::EAN_CODE, $eanCode, $comparison); + } + /** * Filter the query on the tax_rule_title column * diff --git a/core/lib/Thelia/Model/Base/ProductSaleElements.php b/core/lib/Thelia/Model/Base/ProductSaleElements.php index e54b13155..7911b63f7 100644 --- a/core/lib/Thelia/Model/Base/ProductSaleElements.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElements.php @@ -115,6 +115,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface */ protected $is_default; + /** + * The value for the ean_code field. + * @var string + */ + protected $ean_code; + /** * The value for the created_at field. * @var string @@ -538,6 +544,17 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this->is_default; } + /** + * Get the [ean_code] column value. + * + * @return string + */ + public function getEanCode() + { + + return $this->ean_code; + } + /** * Get the [optionally formatted] temporal [created_at] column value. * @@ -758,6 +775,27 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this; } // setIsDefault() + /** + * Set the value of [ean_code] column. + * + * @param string $v new value + * @return \Thelia\Model\ProductSaleElements The current object (for fluent API support) + */ + public function setEanCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->ean_code !== $v) { + $this->ean_code = $v; + $this->modifiedColumns[] = ProductSaleElementsTableMap::EAN_CODE; + } + + + return $this; + } // setEanCode() + /** * Sets the value of [created_at] column to a normalized version of the date/time value specified. * @@ -877,13 +915,16 @@ abstract class ProductSaleElements implements ActiveRecordInterface $col = $row[TableMap::TYPE_NUM == $indexType ? 7 + $startcol : ProductSaleElementsTableMap::translateFieldName('IsDefault', TableMap::TYPE_PHPNAME, $indexType)]; $this->is_default = (null !== $col) ? (boolean) $col : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 8 + $startcol : ProductSaleElementsTableMap::translateFieldName('EanCode', TableMap::TYPE_PHPNAME, $indexType)]; + $this->ean_code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductSaleElementsTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; - $col = $row[TableMap::TYPE_NUM == $indexType ? 9 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + $col = $row[TableMap::TYPE_NUM == $indexType ? 10 + $startcol : ProductSaleElementsTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; if ($col === '0000-00-00 00:00:00') { $col = null; } @@ -896,7 +937,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->ensureConsistency(); } - return $startcol + 10; // 10 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. + return $startcol + 11; // 11 = ProductSaleElementsTableMap::NUM_HYDRATE_COLUMNS. } catch (Exception $e) { throw new PropelException("Error populating \Thelia\Model\ProductSaleElements object", 0, $e); @@ -1213,6 +1254,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) { $modifiedColumns[':p' . $index++] = 'IS_DEFAULT'; } + if ($this->isColumnModified(ProductSaleElementsTableMap::EAN_CODE)) { + $modifiedColumns[':p' . $index++] = 'EAN_CODE'; + } if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) { $modifiedColumns[':p' . $index++] = 'CREATED_AT'; } @@ -1254,6 +1298,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface case 'IS_DEFAULT': $stmt->bindValue($identifier, (int) $this->is_default, PDO::PARAM_INT); break; + case 'EAN_CODE': + $stmt->bindValue($identifier, $this->ean_code, PDO::PARAM_STR); + break; case 'CREATED_AT': $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); break; @@ -1347,9 +1394,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface return $this->getIsDefault(); break; case 8: - return $this->getCreatedAt(); + return $this->getEanCode(); break; case 9: + return $this->getCreatedAt(); + break; + case 10: return $this->getUpdatedAt(); break; default: @@ -1389,8 +1439,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface $keys[5] => $this->getNewness(), $keys[6] => $this->getWeight(), $keys[7] => $this->getIsDefault(), - $keys[8] => $this->getCreatedAt(), - $keys[9] => $this->getUpdatedAt(), + $keys[8] => $this->getEanCode(), + $keys[9] => $this->getCreatedAt(), + $keys[10] => $this->getUpdatedAt(), ); $virtualColumns = $this->virtualColumns; foreach ($virtualColumns as $key => $virtualColumn) { @@ -1469,9 +1520,12 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->setIsDefault($value); break; case 8: - $this->setCreatedAt($value); + $this->setEanCode($value); break; case 9: + $this->setCreatedAt($value); + break; + case 10: $this->setUpdatedAt($value); break; } // switch() @@ -1506,8 +1560,9 @@ abstract class ProductSaleElements implements ActiveRecordInterface if (array_key_exists($keys[5], $arr)) $this->setNewness($arr[$keys[5]]); if (array_key_exists($keys[6], $arr)) $this->setWeight($arr[$keys[6]]); if (array_key_exists($keys[7], $arr)) $this->setIsDefault($arr[$keys[7]]); - if (array_key_exists($keys[8], $arr)) $this->setCreatedAt($arr[$keys[8]]); - if (array_key_exists($keys[9], $arr)) $this->setUpdatedAt($arr[$keys[9]]); + if (array_key_exists($keys[8], $arr)) $this->setEanCode($arr[$keys[8]]); + if (array_key_exists($keys[9], $arr)) $this->setCreatedAt($arr[$keys[9]]); + if (array_key_exists($keys[10], $arr)) $this->setUpdatedAt($arr[$keys[10]]); } /** @@ -1527,6 +1582,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface if ($this->isColumnModified(ProductSaleElementsTableMap::NEWNESS)) $criteria->add(ProductSaleElementsTableMap::NEWNESS, $this->newness); if ($this->isColumnModified(ProductSaleElementsTableMap::WEIGHT)) $criteria->add(ProductSaleElementsTableMap::WEIGHT, $this->weight); if ($this->isColumnModified(ProductSaleElementsTableMap::IS_DEFAULT)) $criteria->add(ProductSaleElementsTableMap::IS_DEFAULT, $this->is_default); + if ($this->isColumnModified(ProductSaleElementsTableMap::EAN_CODE)) $criteria->add(ProductSaleElementsTableMap::EAN_CODE, $this->ean_code); if ($this->isColumnModified(ProductSaleElementsTableMap::CREATED_AT)) $criteria->add(ProductSaleElementsTableMap::CREATED_AT, $this->created_at); if ($this->isColumnModified(ProductSaleElementsTableMap::UPDATED_AT)) $criteria->add(ProductSaleElementsTableMap::UPDATED_AT, $this->updated_at); @@ -1599,6 +1655,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $copyObj->setNewness($this->getNewness()); $copyObj->setWeight($this->getWeight()); $copyObj->setIsDefault($this->getIsDefault()); + $copyObj->setEanCode($this->getEanCode()); $copyObj->setCreatedAt($this->getCreatedAt()); $copyObj->setUpdatedAt($this->getUpdatedAt()); @@ -2526,6 +2583,7 @@ abstract class ProductSaleElements implements ActiveRecordInterface $this->newness = null; $this->weight = null; $this->is_default = null; + $this->ean_code = null; $this->created_at = null; $this->updated_at = null; $this->alreadyInSave = false; diff --git a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php index c8201ed0b..3d169d24b 100644 --- a/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php +++ b/core/lib/Thelia/Model/Base/ProductSaleElementsQuery.php @@ -29,6 +29,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElementsQuery orderByNewness($order = Criteria::ASC) Order by the newness column * @method ChildProductSaleElementsQuery orderByWeight($order = Criteria::ASC) Order by the weight column * @method ChildProductSaleElementsQuery orderByIsDefault($order = Criteria::ASC) Order by the is_default column + * @method ChildProductSaleElementsQuery orderByEanCode($order = Criteria::ASC) Order by the ean_code column * @method ChildProductSaleElementsQuery orderByCreatedAt($order = Criteria::ASC) Order by the created_at column * @method ChildProductSaleElementsQuery orderByUpdatedAt($order = Criteria::ASC) Order by the updated_at column * @@ -40,6 +41,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElementsQuery groupByNewness() Group by the newness column * @method ChildProductSaleElementsQuery groupByWeight() Group by the weight column * @method ChildProductSaleElementsQuery groupByIsDefault() Group by the is_default column + * @method ChildProductSaleElementsQuery groupByEanCode() Group by the ean_code column * @method ChildProductSaleElementsQuery groupByCreatedAt() Group by the created_at column * @method ChildProductSaleElementsQuery groupByUpdatedAt() Group by the updated_at column * @@ -74,6 +76,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method ChildProductSaleElements findOneByNewness(int $newness) Return the first ChildProductSaleElements filtered by the newness column * @method ChildProductSaleElements findOneByWeight(double $weight) Return the first ChildProductSaleElements filtered by the weight column * @method ChildProductSaleElements findOneByIsDefault(boolean $is_default) Return the first ChildProductSaleElements filtered by the is_default column + * @method ChildProductSaleElements findOneByEanCode(string $ean_code) Return the first ChildProductSaleElements filtered by the ean_code column * @method ChildProductSaleElements findOneByCreatedAt(string $created_at) Return the first ChildProductSaleElements filtered by the created_at column * @method ChildProductSaleElements findOneByUpdatedAt(string $updated_at) Return the first ChildProductSaleElements filtered by the updated_at column * @@ -85,6 +88,7 @@ use Thelia\Model\Map\ProductSaleElementsTableMap; * @method array findByNewness(int $newness) Return ChildProductSaleElements objects filtered by the newness column * @method array findByWeight(double $weight) Return ChildProductSaleElements objects filtered by the weight column * @method array findByIsDefault(boolean $is_default) Return ChildProductSaleElements objects filtered by the is_default column + * @method array findByEanCode(string $ean_code) Return ChildProductSaleElements objects filtered by the ean_code column * @method array findByCreatedAt(string $created_at) Return ChildProductSaleElements objects filtered by the created_at column * @method array findByUpdatedAt(string $updated_at) Return ChildProductSaleElements objects filtered by the updated_at column * @@ -175,7 +179,7 @@ abstract class ProductSaleElementsQuery extends ModelCriteria */ protected function findPkSimple($key, $con) { - $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, IS_DEFAULT, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0'; + $sql = 'SELECT ID, PRODUCT_ID, REF, QUANTITY, PROMO, NEWNESS, WEIGHT, IS_DEFAULT, EAN_CODE, CREATED_AT, UPDATED_AT FROM product_sale_elements WHERE ID = :p0'; try { $stmt = $con->prepare($sql); $stmt->bindValue(':p0', $key, PDO::PARAM_INT); @@ -568,6 +572,35 @@ abstract class ProductSaleElementsQuery extends ModelCriteria return $this->addUsingAlias(ProductSaleElementsTableMap::IS_DEFAULT, $isDefault, $comparison); } + /** + * Filter the query on the ean_code column + * + * Example usage: + * + * $query->filterByEanCode('fooValue'); // WHERE ean_code = 'fooValue' + * $query->filterByEanCode('%fooValue%'); // WHERE ean_code LIKE '%fooValue%' + * + * + * @param string $eanCode The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProductSaleElementsQuery The current query, for fluid interface + */ + public function filterByEanCode($eanCode = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($eanCode)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $eanCode)) { + $eanCode = str_replace('*', '%', $eanCode); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProductSaleElementsTableMap::EAN_CODE, $eanCode, $comparison); + } + /** * Filter the query on the created_at column * diff --git a/core/lib/Thelia/Model/Base/Resource.php b/core/lib/Thelia/Model/Base/Resource.php index 59bb2766a..166fa7a16 100644 --- a/core/lib/Thelia/Model/Base/Resource.php +++ b/core/lib/Thelia/Model/Base/Resource.php @@ -17,10 +17,10 @@ use Propel\Runtime\Exception\PropelException; use Propel\Runtime\Map\TableMap; use Propel\Runtime\Parser\AbstractParser; use Propel\Runtime\Util\PropelDateTime; -use Thelia\Model\Group as ChildGroup; -use Thelia\Model\GroupQuery as ChildGroupQuery; -use Thelia\Model\GroupResource as ChildGroupResource; -use Thelia\Model\GroupResourceQuery as ChildGroupResourceQuery; +use Thelia\Model\Profile as ChildProfile; +use Thelia\Model\ProfileQuery as ChildProfileQuery; +use Thelia\Model\ProfileResource as ChildProfileResource; +use Thelia\Model\ProfileResourceQuery as ChildProfileResourceQuery; use Thelia\Model\Resource as ChildResource; use Thelia\Model\ResourceI18n as ChildResourceI18n; use Thelia\Model\ResourceI18nQuery as ChildResourceI18nQuery; @@ -86,10 +86,10 @@ abstract class Resource implements ActiveRecordInterface protected $updated_at; /** - * @var ObjectCollection|ChildGroupResource[] Collection to store aggregation of ChildGroupResource objects. + * @var ObjectCollection|ChildProfileResource[] Collection to store aggregation of ChildProfileResource objects. */ - protected $collGroupResources; - protected $collGroupResourcesPartial; + protected $collProfileResources; + protected $collProfileResourcesPartial; /** * @var ObjectCollection|ChildResourceI18n[] Collection to store aggregation of ChildResourceI18n objects. @@ -98,9 +98,9 @@ abstract class Resource implements ActiveRecordInterface protected $collResourceI18nsPartial; /** - * @var ChildGroup[] Collection to store aggregation of ChildGroup objects. + * @var ChildProfile[] Collection to store aggregation of ChildProfile objects. */ - protected $collGroups; + protected $collProfiles; /** * Flag to prevent endless save loop, if this object is referenced @@ -128,13 +128,13 @@ abstract class Resource implements ActiveRecordInterface * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $groupsScheduledForDeletion = null; + protected $profilesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. * @var ObjectCollection */ - protected $groupResourcesScheduledForDeletion = null; + protected $profileResourcesScheduledForDeletion = null; /** * An array of objects scheduled for deletion. @@ -669,11 +669,11 @@ abstract class Resource implements ActiveRecordInterface if ($deep) { // also de-associate any related objects? - $this->collGroupResources = null; + $this->collProfileResources = null; $this->collResourceI18ns = null; - $this->collGroups = null; + $this->collProfiles = null; } // if (deep) } @@ -807,44 +807,44 @@ abstract class Resource implements ActiveRecordInterface $this->resetModified(); } - if ($this->groupsScheduledForDeletion !== null) { - if (!$this->groupsScheduledForDeletion->isEmpty()) { + if ($this->profilesScheduledForDeletion !== null) { + if (!$this->profilesScheduledForDeletion->isEmpty()) { $pks = array(); $pk = $this->getPrimaryKey(); - foreach ($this->groupsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + foreach ($this->profilesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { $pks[] = array($remotePk, $pk); } - GroupResourceQuery::create() + ProfileResourceQuery::create() ->filterByPrimaryKeys($pks) ->delete($con); - $this->groupsScheduledForDeletion = null; + $this->profilesScheduledForDeletion = null; } - foreach ($this->getGroups() as $group) { - if ($group->isModified()) { - $group->save($con); + foreach ($this->getProfiles() as $profile) { + if ($profile->isModified()) { + $profile->save($con); } } - } elseif ($this->collGroups) { - foreach ($this->collGroups as $group) { - if ($group->isModified()) { - $group->save($con); + } elseif ($this->collProfiles) { + foreach ($this->collProfiles as $profile) { + if ($profile->isModified()) { + $profile->save($con); } } } - if ($this->groupResourcesScheduledForDeletion !== null) { - if (!$this->groupResourcesScheduledForDeletion->isEmpty()) { - \Thelia\Model\GroupResourceQuery::create() - ->filterByPrimaryKeys($this->groupResourcesScheduledForDeletion->getPrimaryKeys(false)) + if ($this->profileResourcesScheduledForDeletion !== null) { + if (!$this->profileResourcesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProfileResourceQuery::create() + ->filterByPrimaryKeys($this->profileResourcesScheduledForDeletion->getPrimaryKeys(false)) ->delete($con); - $this->groupResourcesScheduledForDeletion = null; + $this->profileResourcesScheduledForDeletion = null; } } - if ($this->collGroupResources !== null) { - foreach ($this->collGroupResources as $referrerFK) { + if ($this->collProfileResources !== null) { + foreach ($this->collProfileResources as $referrerFK) { if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { $affectedRows += $referrerFK->save($con); } @@ -1043,8 +1043,8 @@ abstract class Resource implements ActiveRecordInterface } if ($includeForeignObjects) { - if (null !== $this->collGroupResources) { - $result['GroupResources'] = $this->collGroupResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + if (null !== $this->collProfileResources) { + $result['ProfileResources'] = $this->collProfileResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); } if (null !== $this->collResourceI18ns) { $result['ResourceI18ns'] = $this->collResourceI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); @@ -1210,9 +1210,9 @@ abstract class Resource implements ActiveRecordInterface // the getter/setter methods for fkey referrer objects. $copyObj->setNew(false); - foreach ($this->getGroupResources() as $relObj) { + foreach ($this->getProfileResources() as $relObj) { if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves - $copyObj->addGroupResource($relObj->copy($deepCopy)); + $copyObj->addProfileResource($relObj->copy($deepCopy)); } } @@ -1263,8 +1263,8 @@ abstract class Resource implements ActiveRecordInterface */ public function initRelation($relationName) { - if ('GroupResource' == $relationName) { - return $this->initGroupResources(); + if ('ProfileResource' == $relationName) { + return $this->initProfileResources(); } if ('ResourceI18n' == $relationName) { return $this->initResourceI18ns(); @@ -1272,31 +1272,31 @@ abstract class Resource implements ActiveRecordInterface } /** - * Clears out the collGroupResources collection + * Clears out the collProfileResources collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addGroupResources() + * @see addProfileResources() */ - public function clearGroupResources() + public function clearProfileResources() { - $this->collGroupResources = null; // important to set this to NULL since that means it is uninitialized + $this->collProfileResources = null; // important to set this to NULL since that means it is uninitialized } /** - * Reset is the collGroupResources collection loaded partially. + * Reset is the collProfileResources collection loaded partially. */ - public function resetPartialGroupResources($v = true) + public function resetPartialProfileResources($v = true) { - $this->collGroupResourcesPartial = $v; + $this->collProfileResourcesPartial = $v; } /** - * Initializes the collGroupResources collection. + * Initializes the collProfileResources collection. * - * By default this just sets the collGroupResources collection to an empty array (like clearcollGroupResources()); + * By default this just sets the collProfileResources collection to an empty array (like clearcollProfileResources()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * @@ -1305,17 +1305,17 @@ abstract class Resource implements ActiveRecordInterface * * @return void */ - public function initGroupResources($overrideExisting = true) + public function initProfileResources($overrideExisting = true) { - if (null !== $this->collGroupResources && !$overrideExisting) { + if (null !== $this->collProfileResources && !$overrideExisting) { return; } - $this->collGroupResources = new ObjectCollection(); - $this->collGroupResources->setModel('\Thelia\Model\GroupResource'); + $this->collProfileResources = new ObjectCollection(); + $this->collProfileResources->setModel('\Thelia\Model\ProfileResource'); } /** - * Gets an array of ChildGroupResource objects which contain a foreign key that references this object. + * Gets an array of ChildProfileResource objects which contain a foreign key that references this object. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1325,112 +1325,112 @@ abstract class Resource implements ActiveRecordInterface * * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object - * @return Collection|ChildGroupResource[] List of ChildGroupResource objects + * @return Collection|ChildProfileResource[] List of ChildProfileResource objects * @throws PropelException */ - public function getGroupResources($criteria = null, ConnectionInterface $con = null) + public function getProfileResources($criteria = null, ConnectionInterface $con = null) { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { + $partial = $this->collProfileResourcesPartial && !$this->isNew(); + if (null === $this->collProfileResources || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileResources) { // return empty collection - $this->initGroupResources(); + $this->initProfileResources(); } else { - $collGroupResources = ChildGroupResourceQuery::create(null, $criteria) + $collProfileResources = ChildProfileResourceQuery::create(null, $criteria) ->filterByResource($this) ->find($con); if (null !== $criteria) { - if (false !== $this->collGroupResourcesPartial && count($collGroupResources)) { - $this->initGroupResources(false); + if (false !== $this->collProfileResourcesPartial && count($collProfileResources)) { + $this->initProfileResources(false); - foreach ($collGroupResources as $obj) { - if (false == $this->collGroupResources->contains($obj)) { - $this->collGroupResources->append($obj); + foreach ($collProfileResources as $obj) { + if (false == $this->collProfileResources->contains($obj)) { + $this->collProfileResources->append($obj); } } - $this->collGroupResourcesPartial = true; + $this->collProfileResourcesPartial = true; } - $collGroupResources->getInternalIterator()->rewind(); + $collProfileResources->getInternalIterator()->rewind(); - return $collGroupResources; + return $collProfileResources; } - if ($partial && $this->collGroupResources) { - foreach ($this->collGroupResources as $obj) { + if ($partial && $this->collProfileResources) { + foreach ($this->collProfileResources as $obj) { if ($obj->isNew()) { - $collGroupResources[] = $obj; + $collProfileResources[] = $obj; } } } - $this->collGroupResources = $collGroupResources; - $this->collGroupResourcesPartial = false; + $this->collProfileResources = $collProfileResources; + $this->collProfileResourcesPartial = false; } } - return $this->collGroupResources; + return $this->collProfileResources; } /** - * Sets a collection of GroupResource objects related by a one-to-many relationship + * Sets a collection of ProfileResource objects related by a one-to-many relationship * to the current object. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $groupResources A Propel collection. + * @param Collection $profileResources A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildResource The current object (for fluent API support) */ - public function setGroupResources(Collection $groupResources, ConnectionInterface $con = null) + public function setProfileResources(Collection $profileResources, ConnectionInterface $con = null) { - $groupResourcesToDelete = $this->getGroupResources(new Criteria(), $con)->diff($groupResources); + $profileResourcesToDelete = $this->getProfileResources(new Criteria(), $con)->diff($profileResources); //since at least one column in the foreign key is at the same time a PK //we can not just set a PK to NULL in the lines below. We have to store //a backup of all values, so we are able to manipulate these items based on the onDelete value later. - $this->groupResourcesScheduledForDeletion = clone $groupResourcesToDelete; + $this->profileResourcesScheduledForDeletion = clone $profileResourcesToDelete; - foreach ($groupResourcesToDelete as $groupResourceRemoved) { - $groupResourceRemoved->setResource(null); + foreach ($profileResourcesToDelete as $profileResourceRemoved) { + $profileResourceRemoved->setResource(null); } - $this->collGroupResources = null; - foreach ($groupResources as $groupResource) { - $this->addGroupResource($groupResource); + $this->collProfileResources = null; + foreach ($profileResources as $profileResource) { + $this->addProfileResource($profileResource); } - $this->collGroupResources = $groupResources; - $this->collGroupResourcesPartial = false; + $this->collProfileResources = $profileResources; + $this->collProfileResourcesPartial = false; return $this; } /** - * Returns the number of related GroupResource objects. + * Returns the number of related ProfileResource objects. * * @param Criteria $criteria * @param boolean $distinct * @param ConnectionInterface $con - * @return int Count of related GroupResource objects. + * @return int Count of related ProfileResource objects. * @throws PropelException */ - public function countGroupResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProfileResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { - $partial = $this->collGroupResourcesPartial && !$this->isNew(); - if (null === $this->collGroupResources || null !== $criteria || $partial) { - if ($this->isNew() && null === $this->collGroupResources) { + $partial = $this->collProfileResourcesPartial && !$this->isNew(); + if (null === $this->collProfileResources || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileResources) { return 0; } if ($partial && !$criteria) { - return count($this->getGroupResources()); + return count($this->getProfileResources()); } - $query = ChildGroupResourceQuery::create(null, $criteria); + $query = ChildProfileResourceQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1440,53 +1440,53 @@ abstract class Resource implements ActiveRecordInterface ->count($con); } - return count($this->collGroupResources); + return count($this->collProfileResources); } /** - * Method called to associate a ChildGroupResource object to this object - * through the ChildGroupResource foreign key attribute. + * Method called to associate a ChildProfileResource object to this object + * through the ChildProfileResource foreign key attribute. * - * @param ChildGroupResource $l ChildGroupResource + * @param ChildProfileResource $l ChildProfileResource * @return \Thelia\Model\Resource The current object (for fluent API support) */ - public function addGroupResource(ChildGroupResource $l) + public function addProfileResource(ChildProfileResource $l) { - if ($this->collGroupResources === null) { - $this->initGroupResources(); - $this->collGroupResourcesPartial = true; + if ($this->collProfileResources === null) { + $this->initProfileResources(); + $this->collProfileResourcesPartial = true; } - if (!in_array($l, $this->collGroupResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated - $this->doAddGroupResource($l); + if (!in_array($l, $this->collProfileResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProfileResource($l); } return $this; } /** - * @param GroupResource $groupResource The groupResource object to add. + * @param ProfileResource $profileResource The profileResource object to add. */ - protected function doAddGroupResource($groupResource) + protected function doAddProfileResource($profileResource) { - $this->collGroupResources[]= $groupResource; - $groupResource->setResource($this); + $this->collProfileResources[]= $profileResource; + $profileResource->setResource($this); } /** - * @param GroupResource $groupResource The groupResource object to remove. + * @param ProfileResource $profileResource The profileResource object to remove. * @return ChildResource The current object (for fluent API support) */ - public function removeGroupResource($groupResource) + public function removeProfileResource($profileResource) { - if ($this->getGroupResources()->contains($groupResource)) { - $this->collGroupResources->remove($this->collGroupResources->search($groupResource)); - if (null === $this->groupResourcesScheduledForDeletion) { - $this->groupResourcesScheduledForDeletion = clone $this->collGroupResources; - $this->groupResourcesScheduledForDeletion->clear(); + if ($this->getProfileResources()->contains($profileResource)) { + $this->collProfileResources->remove($this->collProfileResources->search($profileResource)); + if (null === $this->profileResourcesScheduledForDeletion) { + $this->profileResourcesScheduledForDeletion = clone $this->collProfileResources; + $this->profileResourcesScheduledForDeletion->clear(); } - $this->groupResourcesScheduledForDeletion[]= clone $groupResource; - $groupResource->setResource(null); + $this->profileResourcesScheduledForDeletion[]= clone $profileResource; + $profileResource->setResource(null); } return $this; @@ -1498,7 +1498,7 @@ abstract class Resource implements ActiveRecordInterface * an identical criteria, it returns the collection. * Otherwise if this Resource is new, it will return * an empty collection; or if this Resource has previously - * been saved, it will retrieve related GroupResources from storage. + * been saved, it will retrieve related ProfileResources from storage. * * This method is protected by default in order to keep the public * api reasonable. You can provide public methods for those you @@ -1507,14 +1507,14 @@ abstract class Resource implements ActiveRecordInterface * @param Criteria $criteria optional Criteria object to narrow the query * @param ConnectionInterface $con optional connection object * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) - * @return Collection|ChildGroupResource[] List of ChildGroupResource objects + * @return Collection|ChildProfileResource[] List of ChildProfileResource objects */ - public function getGroupResourcesJoinGroup($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + public function getProfileResourcesJoinProfile($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { - $query = ChildGroupResourceQuery::create(null, $criteria); - $query->joinWith('Group', $joinBehavior); + $query = ChildProfileResourceQuery::create(null, $criteria); + $query->joinWith('Profile', $joinBehavior); - return $this->getGroupResources($query, $con); + return $this->getProfileResources($query, $con); } /** @@ -1743,38 +1743,38 @@ abstract class Resource implements ActiveRecordInterface } /** - * Clears out the collGroups collection + * Clears out the collProfiles collection * * This does not modify the database; however, it will remove any associated objects, causing * them to be refetched by subsequent calls to accessor method. * * @return void - * @see addGroups() + * @see addProfiles() */ - public function clearGroups() + public function clearProfiles() { - $this->collGroups = null; // important to set this to NULL since that means it is uninitialized - $this->collGroupsPartial = null; + $this->collProfiles = null; // important to set this to NULL since that means it is uninitialized + $this->collProfilesPartial = null; } /** - * Initializes the collGroups collection. + * Initializes the collProfiles collection. * - * By default this just sets the collGroups collection to an empty collection (like clearGroups()); + * By default this just sets the collProfiles collection to an empty collection (like clearProfiles()); * however, you may wish to override this method in your stub class to provide setting appropriate * to your application -- for example, setting the initial array to the values stored in database. * * @return void */ - public function initGroups() + public function initProfiles() { - $this->collGroups = new ObjectCollection(); - $this->collGroups->setModel('\Thelia\Model\Group'); + $this->collProfiles = new ObjectCollection(); + $this->collProfiles->setModel('\Thelia\Model\Profile'); } /** - * Gets a collection of ChildGroup objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. + * Gets a collection of ChildProfile objects related by a many-to-many relationship + * to the current object by way of the profile_resource cross-reference table. * * If the $criteria is not null, it is used to always fetch the results from the database. * Otherwise the results are fetched from the database the first time, then cached. @@ -1785,73 +1785,73 @@ abstract class Resource implements ActiveRecordInterface * @param Criteria $criteria Optional query object to filter the query * @param ConnectionInterface $con Optional connection object * - * @return ObjectCollection|ChildGroup[] List of ChildGroup objects + * @return ObjectCollection|ChildProfile[] List of ChildProfile objects */ - public function getGroups($criteria = null, ConnectionInterface $con = null) + public function getProfiles($criteria = null, ConnectionInterface $con = null) { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { + if (null === $this->collProfiles || null !== $criteria) { + if ($this->isNew() && null === $this->collProfiles) { // return empty collection - $this->initGroups(); + $this->initProfiles(); } else { - $collGroups = ChildGroupQuery::create(null, $criteria) + $collProfiles = ChildProfileQuery::create(null, $criteria) ->filterByResource($this) ->find($con); if (null !== $criteria) { - return $collGroups; + return $collProfiles; } - $this->collGroups = $collGroups; + $this->collProfiles = $collProfiles; } } - return $this->collGroups; + return $this->collProfiles; } /** - * Sets a collection of Group objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. + * Sets a collection of Profile objects related by a many-to-many relationship + * to the current object by way of the profile_resource cross-reference table. * It will also schedule objects for deletion based on a diff between old objects (aka persisted) * and new objects from the given Propel collection. * - * @param Collection $groups A Propel collection. + * @param Collection $profiles A Propel collection. * @param ConnectionInterface $con Optional connection object * @return ChildResource The current object (for fluent API support) */ - public function setGroups(Collection $groups, ConnectionInterface $con = null) + public function setProfiles(Collection $profiles, ConnectionInterface $con = null) { - $this->clearGroups(); - $currentGroups = $this->getGroups(); + $this->clearProfiles(); + $currentProfiles = $this->getProfiles(); - $this->groupsScheduledForDeletion = $currentGroups->diff($groups); + $this->profilesScheduledForDeletion = $currentProfiles->diff($profiles); - foreach ($groups as $group) { - if (!$currentGroups->contains($group)) { - $this->doAddGroup($group); + foreach ($profiles as $profile) { + if (!$currentProfiles->contains($profile)) { + $this->doAddProfile($profile); } } - $this->collGroups = $groups; + $this->collProfiles = $profiles; return $this; } /** - * Gets the number of ChildGroup objects related by a many-to-many relationship - * to the current object by way of the group_resource cross-reference table. + * Gets the number of ChildProfile objects related by a many-to-many relationship + * to the current object by way of the profile_resource cross-reference table. * * @param Criteria $criteria Optional query object to filter the query * @param boolean $distinct Set to true to force count distinct * @param ConnectionInterface $con Optional connection object * - * @return int the number of related ChildGroup objects + * @return int the number of related ChildProfile objects */ - public function countGroups($criteria = null, $distinct = false, ConnectionInterface $con = null) + public function countProfiles($criteria = null, $distinct = false, ConnectionInterface $con = null) { - if (null === $this->collGroups || null !== $criteria) { - if ($this->isNew() && null === $this->collGroups) { + if (null === $this->collProfiles || null !== $criteria) { + if ($this->isNew() && null === $this->collProfiles) { return 0; } else { - $query = ChildGroupQuery::create(null, $criteria); + $query = ChildProfileQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } @@ -1861,65 +1861,65 @@ abstract class Resource implements ActiveRecordInterface ->count($con); } } else { - return count($this->collGroups); + return count($this->collProfiles); } } /** - * Associate a ChildGroup object to this object - * through the group_resource cross reference table. + * Associate a ChildProfile object to this object + * through the profile_resource cross reference table. * - * @param ChildGroup $group The ChildGroupResource object to relate + * @param ChildProfile $profile The ChildProfileResource object to relate * @return ChildResource The current object (for fluent API support) */ - public function addGroup(ChildGroup $group) + public function addProfile(ChildProfile $profile) { - if ($this->collGroups === null) { - $this->initGroups(); + if ($this->collProfiles === null) { + $this->initProfiles(); } - if (!$this->collGroups->contains($group)) { // only add it if the **same** object is not already associated - $this->doAddGroup($group); - $this->collGroups[] = $group; + if (!$this->collProfiles->contains($profile)) { // only add it if the **same** object is not already associated + $this->doAddProfile($profile); + $this->collProfiles[] = $profile; } return $this; } /** - * @param Group $group The group object to add. + * @param Profile $profile The profile object to add. */ - protected function doAddGroup($group) + protected function doAddProfile($profile) { - $groupResource = new ChildGroupResource(); - $groupResource->setGroup($group); - $this->addGroupResource($groupResource); + $profileResource = new ChildProfileResource(); + $profileResource->setProfile($profile); + $this->addProfileResource($profileResource); // set the back reference to this object directly as using provided method either results // in endless loop or in multiple relations - if (!$group->getResources()->contains($this)) { - $foreignCollection = $group->getResources(); + if (!$profile->getResources()->contains($this)) { + $foreignCollection = $profile->getResources(); $foreignCollection[] = $this; } } /** - * Remove a ChildGroup object to this object - * through the group_resource cross reference table. + * Remove a ChildProfile object to this object + * through the profile_resource cross reference table. * - * @param ChildGroup $group The ChildGroupResource object to relate + * @param ChildProfile $profile The ChildProfileResource object to relate * @return ChildResource The current object (for fluent API support) */ - public function removeGroup(ChildGroup $group) + public function removeProfile(ChildProfile $profile) { - if ($this->getGroups()->contains($group)) { - $this->collGroups->remove($this->collGroups->search($group)); + if ($this->getProfiles()->contains($profile)) { + $this->collProfiles->remove($this->collProfiles->search($profile)); - if (null === $this->groupsScheduledForDeletion) { - $this->groupsScheduledForDeletion = clone $this->collGroups; - $this->groupsScheduledForDeletion->clear(); + if (null === $this->profilesScheduledForDeletion) { + $this->profilesScheduledForDeletion = clone $this->collProfiles; + $this->profilesScheduledForDeletion->clear(); } - $this->groupsScheduledForDeletion[] = $group; + $this->profilesScheduledForDeletion[] = $profile; } return $this; @@ -1953,8 +1953,8 @@ abstract class Resource implements ActiveRecordInterface public function clearAllReferences($deep = false) { if ($deep) { - if ($this->collGroupResources) { - foreach ($this->collGroupResources as $o) { + if ($this->collProfileResources) { + foreach ($this->collProfileResources as $o) { $o->clearAllReferences($deep); } } @@ -1963,8 +1963,8 @@ abstract class Resource implements ActiveRecordInterface $o->clearAllReferences($deep); } } - if ($this->collGroups) { - foreach ($this->collGroups as $o) { + if ($this->collProfiles) { + foreach ($this->collProfiles as $o) { $o->clearAllReferences($deep); } } @@ -1974,18 +1974,18 @@ abstract class Resource implements ActiveRecordInterface $this->currentLocale = 'en_US'; $this->currentTranslations = null; - if ($this->collGroupResources instanceof Collection) { - $this->collGroupResources->clearIterator(); + if ($this->collProfileResources instanceof Collection) { + $this->collProfileResources->clearIterator(); } - $this->collGroupResources = null; + $this->collProfileResources = null; if ($this->collResourceI18ns instanceof Collection) { $this->collResourceI18ns->clearIterator(); } $this->collResourceI18ns = null; - if ($this->collGroups instanceof Collection) { - $this->collGroups->clearIterator(); + if ($this->collProfiles instanceof Collection) { + $this->collProfiles->clearIterator(); } - $this->collGroups = null; + $this->collProfiles = null; } /** diff --git a/core/lib/Thelia/Model/Base/ResourceQuery.php b/core/lib/Thelia/Model/Base/ResourceQuery.php index 6559d6522..72888d6a9 100644 --- a/core/lib/Thelia/Model/Base/ResourceQuery.php +++ b/core/lib/Thelia/Model/Base/ResourceQuery.php @@ -36,9 +36,9 @@ use Thelia\Model\Map\ResourceTableMap; * @method ChildResourceQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method ChildResourceQuery innerJoin($relation) Adds a INNER JOIN clause to the query * - * @method ChildResourceQuery leftJoinGroupResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the GroupResource relation - * @method ChildResourceQuery rightJoinGroupResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the GroupResource relation - * @method ChildResourceQuery innerJoinGroupResource($relationAlias = null) Adds a INNER JOIN clause to the query using the GroupResource relation + * @method ChildResourceQuery leftJoinProfileResource($relationAlias = null) Adds a LEFT JOIN clause to the query using the ProfileResource relation + * @method ChildResourceQuery rightJoinProfileResource($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ProfileResource relation + * @method ChildResourceQuery innerJoinProfileResource($relationAlias = null) Adds a INNER JOIN clause to the query using the ProfileResource relation * * @method ChildResourceQuery leftJoinResourceI18n($relationAlias = null) Adds a LEFT JOIN clause to the query using the ResourceI18n relation * @method ChildResourceQuery rightJoinResourceI18n($relationAlias = null) Adds a RIGHT JOIN clause to the query using the ResourceI18n relation @@ -390,40 +390,40 @@ abstract class ResourceQuery extends ModelCriteria } /** - * Filter the query by a related \Thelia\Model\GroupResource object + * Filter the query by a related \Thelia\Model\ProfileResource object * - * @param \Thelia\Model\GroupResource|ObjectCollection $groupResource the related object to use as filter + * @param \Thelia\Model\ProfileResource|ObjectCollection $profileResource the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildResourceQuery The current query, for fluid interface */ - public function filterByGroupResource($groupResource, $comparison = null) + public function filterByProfileResource($profileResource, $comparison = null) { - if ($groupResource instanceof \Thelia\Model\GroupResource) { + if ($profileResource instanceof \Thelia\Model\ProfileResource) { return $this - ->addUsingAlias(ResourceTableMap::ID, $groupResource->getResourceId(), $comparison); - } elseif ($groupResource instanceof ObjectCollection) { + ->addUsingAlias(ResourceTableMap::ID, $profileResource->getResourceId(), $comparison); + } elseif ($profileResource instanceof ObjectCollection) { return $this - ->useGroupResourceQuery() - ->filterByPrimaryKeys($groupResource->getPrimaryKeys()) + ->useProfileResourceQuery() + ->filterByPrimaryKeys($profileResource->getPrimaryKeys()) ->endUse(); } else { - throw new PropelException('filterByGroupResource() only accepts arguments of type \Thelia\Model\GroupResource or Collection'); + throw new PropelException('filterByProfileResource() only accepts arguments of type \Thelia\Model\ProfileResource or Collection'); } } /** - * Adds a JOIN clause to the query using the GroupResource relation + * Adds a JOIN clause to the query using the ProfileResource relation * * @param string $relationAlias optional alias for the relation * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * * @return ChildResourceQuery The current query, for fluid interface */ - public function joinGroupResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function joinProfileResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) { $tableMap = $this->getTableMap(); - $relationMap = $tableMap->getRelation('GroupResource'); + $relationMap = $tableMap->getRelation('ProfileResource'); // create a ModelJoin object for this join $join = new ModelJoin(); @@ -438,14 +438,14 @@ abstract class ResourceQuery extends ModelCriteria $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); $this->addJoinObject($join, $relationAlias); } else { - $this->addJoinObject($join, 'GroupResource'); + $this->addJoinObject($join, 'ProfileResource'); } return $this; } /** - * Use the GroupResource relation GroupResource object + * Use the ProfileResource relation ProfileResource object * * @see useQuery() * @@ -453,13 +453,13 @@ abstract class ResourceQuery extends ModelCriteria * to be used as main alias in the secondary query * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' * - * @return \Thelia\Model\GroupResourceQuery A secondary query class using the current class as primary query + * @return \Thelia\Model\ProfileResourceQuery A secondary query class using the current class as primary query */ - public function useGroupResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + public function useProfileResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this - ->joinGroupResource($relationAlias, $joinType) - ->useQuery($relationAlias ? $relationAlias : 'GroupResource', '\Thelia\Model\GroupResourceQuery'); + ->joinProfileResource($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProfileResource', '\Thelia\Model\ProfileResourceQuery'); } /** @@ -536,19 +536,19 @@ abstract class ResourceQuery extends ModelCriteria } /** - * Filter the query by a related Group object - * using the group_resource table as cross reference + * Filter the query by a related Profile object + * using the profile_resource table as cross reference * - * @param Group $group the related object to use as filter + * @param Profile $profile the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ChildResourceQuery The current query, for fluid interface */ - public function filterByGroup($group, $comparison = Criteria::EQUAL) + public function filterByProfile($profile, $comparison = Criteria::EQUAL) { return $this - ->useGroupResourceQuery() - ->filterByGroup($group, $comparison) + ->useProfileResourceQuery() + ->filterByProfile($profile, $comparison) ->endUse(); } diff --git a/core/lib/Thelia/Model/Group.php b/core/lib/Thelia/Model/Group.php deleted file mode 100755 index b1ca04975..000000000 --- a/core/lib/Thelia/Model/Group.php +++ /dev/null @@ -1,9 +0,0 @@ - array('Id', 'GroupId', 'AdminId', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'adminId', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(AdminGroupTableMap::ID, AdminGroupTableMap::GROUP_ID, AdminGroupTableMap::ADMIN_ID, AdminGroupTableMap::CREATED_AT, AdminGroupTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'ADMIN_ID', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'group_id', 'admin_id', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'AdminId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'adminId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), - self::TYPE_COLNAME => array(AdminGroupTableMap::ID => 0, AdminGroupTableMap::GROUP_ID => 1, AdminGroupTableMap::ADMIN_ID => 2, AdminGroupTableMap::CREATED_AT => 3, AdminGroupTableMap::UPDATED_AT => 4, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'ADMIN_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), - self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'admin_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('admin_group'); - $this->setPhpName('AdminGroup'); - $this->setClassName('\\Thelia\\Model\\AdminGroup'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignPrimaryKey('GROUP_ID', 'GroupId', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addForeignPrimaryKey('ADMIN_ID', 'AdminId', 'INTEGER' , 'admin', 'ID', true, null, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - ); - } // getBehaviors() - - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by find*() - * and findPk*() calls. - * - * @param \Thelia\Model\AdminGroup $obj A \Thelia\Model\AdminGroup object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if (null === $key) { - $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getAdminId())); - } // if key === null - self::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A \Thelia\Model\AdminGroup object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && null !== $value) { - if (is_object($value) && $value instanceof \Thelia\Model\AdminGroup) { - $key = serialize(array((string) $value->getId(), (string) $value->getGroupId(), (string) $value->getAdminId())); - - } elseif (is_array($value) && count($value) === 3) { - // assume we've been passed a primary key"; - $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2])); - } elseif ($value instanceof Criteria) { - self::$instances = []; - - return; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AdminGroup object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); - throw $e; - } - - unset(self::$instances[$key]); - } - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)] === null) { - return null; - } - - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return $pks; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? AdminGroupTableMap::CLASS_DEFAULT : AdminGroupTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (AdminGroup object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = AdminGroupTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = AdminGroupTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + AdminGroupTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = AdminGroupTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - AdminGroupTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = AdminGroupTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = AdminGroupTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - AdminGroupTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(AdminGroupTableMap::ID); - $criteria->addSelectColumn(AdminGroupTableMap::GROUP_ID); - $criteria->addSelectColumn(AdminGroupTableMap::ADMIN_ID); - $criteria->addSelectColumn(AdminGroupTableMap::CREATED_AT); - $criteria->addSelectColumn(AdminGroupTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); - $criteria->addSelectColumn($alias . '.ADMIN_ID'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(AdminGroupTableMap::DATABASE_NAME)->getTable(AdminGroupTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminGroupTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(AdminGroupTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new AdminGroupTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a AdminGroup or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or AdminGroup object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\AdminGroup) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(AdminGroupTableMap::DATABASE_NAME); - // primary key is composite; we therefore, expect - // the primary key passed to be an array of pkey values - if (count($values) == count($values, COUNT_RECURSIVE)) { - // array is not multi-dimensional - $values = array($values); - } - foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(AdminGroupTableMap::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(AdminGroupTableMap::GROUP_ID, $value[1])); - $criterion->addAnd($criteria->getNewCriterion(AdminGroupTableMap::ADMIN_ID, $value[2])); - $criteria->addOr($criterion); - } - } - - $query = AdminGroupQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { AdminGroupTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { AdminGroupTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the admin_group table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return AdminGroupQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a AdminGroup or Criteria object. - * - * @param mixed $criteria Criteria or AdminGroup object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(AdminGroupTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from AdminGroup object - } - - if ($criteria->containsKey(AdminGroupTableMap::ID) && $criteria->keyContainsValue(AdminGroupTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminGroupTableMap::ID.')'); - } - - - // Set the correct dbName - $query = AdminGroupQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // AdminGroupTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -AdminGroupTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/AdminTableMap.php b/core/lib/Thelia/Model/Map/AdminTableMap.php index a4c2cf265..edc2bcee3 100644 --- a/core/lib/Thelia/Model/Map/AdminTableMap.php +++ b/core/lib/Thelia/Model/Map/AdminTableMap.php @@ -193,8 +193,8 @@ class AdminTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('AdminGroup', '\\Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'admin_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups'); - $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Groups'); + $this->addRelation('AdminProfile', '\\Thelia\\Model\\AdminProfile', RelationMap::ONE_TO_MANY, array('id' => 'admin_id', ), 'CASCADE', 'RESTRICT', 'AdminProfiles'); + $this->addRelation('Profile', '\\Thelia\\Model\\Profile', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Profiles'); } // buildRelations() /** @@ -216,7 +216,7 @@ class AdminTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AdminGroupTableMap::clearInstancePool(); + AdminProfileTableMap::clearInstancePool(); } /** diff --git a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php b/core/lib/Thelia/Model/Map/GroupI18nTableMap.php deleted file mode 100644 index 57788593a..000000000 --- a/core/lib/Thelia/Model/Map/GroupI18nTableMap.php +++ /dev/null @@ -1,497 +0,0 @@ - array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), - self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_COLNAME => array(GroupI18nTableMap::ID, GroupI18nTableMap::LOCALE, GroupI18nTableMap::TITLE, GroupI18nTableMap::DESCRIPTION, GroupI18nTableMap::CHAPO, GroupI18nTableMap::POSTSCRIPTUM, ), - self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), - self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_COLNAME => array(GroupI18nTableMap::ID => 0, GroupI18nTableMap::LOCALE => 1, GroupI18nTableMap::TITLE => 2, GroupI18nTableMap::DESCRIPTION => 3, GroupI18nTableMap::CHAPO => 4, GroupI18nTableMap::POSTSCRIPTUM => 5, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), - self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('group_i18n'); - $this->setPhpName('GroupI18n'); - $this->setClassName('\\Thelia\\Model\\GroupI18n'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(false); - // columns - $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); - $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); - $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); - $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); - $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); - } // buildRelations() - - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by find*() - * and findPk*() calls. - * - * @param \Thelia\Model\GroupI18n $obj A \Thelia\Model\GroupI18n object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if (null === $key) { - $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); - } // if key === null - self::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A \Thelia\Model\GroupI18n object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && null !== $value) { - if (is_object($value) && $value instanceof \Thelia\Model\GroupI18n) { - $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); - - } elseif (is_array($value) && count($value) === 2) { - // assume we've been passed a primary key"; - $key = serialize(array((string) $value[0], (string) $value[1])); - } elseif ($value instanceof Criteria) { - self::$instances = []; - - return; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\GroupI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); - throw $e; - } - - unset(self::$instances[$key]); - } - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { - return null; - } - - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return $pks; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? GroupI18nTableMap::CLASS_DEFAULT : GroupI18nTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (GroupI18n object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = GroupI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = GroupI18nTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + GroupI18nTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupI18nTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - GroupI18nTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = GroupI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = GroupI18nTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - GroupI18nTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(GroupI18nTableMap::ID); - $criteria->addSelectColumn(GroupI18nTableMap::LOCALE); - $criteria->addSelectColumn(GroupI18nTableMap::TITLE); - $criteria->addSelectColumn(GroupI18nTableMap::DESCRIPTION); - $criteria->addSelectColumn(GroupI18nTableMap::CHAPO); - $criteria->addSelectColumn(GroupI18nTableMap::POSTSCRIPTUM); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.LOCALE'); - $criteria->addSelectColumn($alias . '.TITLE'); - $criteria->addSelectColumn($alias . '.DESCRIPTION'); - $criteria->addSelectColumn($alias . '.CHAPO'); - $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(GroupI18nTableMap::DATABASE_NAME)->getTable(GroupI18nTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupI18nTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(GroupI18nTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new GroupI18nTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a GroupI18n or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or GroupI18n object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\GroupI18n) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(GroupI18nTableMap::DATABASE_NAME); - // primary key is composite; we therefore, expect - // the primary key passed to be an array of pkey values - if (count($values) == count($values, COUNT_RECURSIVE)) { - // array is not multi-dimensional - $values = array($values); - } - foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(GroupI18nTableMap::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(GroupI18nTableMap::LOCALE, $value[1])); - $criteria->addOr($criterion); - } - } - - $query = GroupI18nQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { GroupI18nTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { GroupI18nTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the group_i18n table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return GroupI18nQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a GroupI18n or Criteria object. - * - * @param mixed $criteria Criteria or GroupI18n object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupI18nTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from GroupI18n object - } - - - // Set the correct dbName - $query = GroupI18nQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // GroupI18nTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -GroupI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/GroupModuleTableMap.php b/core/lib/Thelia/Model/Map/GroupModuleTableMap.php deleted file mode 100644 index 49361d253..000000000 --- a/core/lib/Thelia/Model/Map/GroupModuleTableMap.php +++ /dev/null @@ -1,456 +0,0 @@ - array('Id', 'GroupId', 'ModuleId', 'Access', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'moduleId', 'access', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(GroupModuleTableMap::ID, GroupModuleTableMap::GROUP_ID, GroupModuleTableMap::MODULE_ID, GroupModuleTableMap::ACCESS, GroupModuleTableMap::CREATED_AT, GroupModuleTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'MODULE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'group_id', 'module_id', 'access', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'ModuleId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'moduleId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), - self::TYPE_COLNAME => array(GroupModuleTableMap::ID => 0, GroupModuleTableMap::GROUP_ID => 1, GroupModuleTableMap::MODULE_ID => 2, GroupModuleTableMap::ACCESS => 3, GroupModuleTableMap::CREATED_AT => 4, GroupModuleTableMap::UPDATED_AT => 5, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'MODULE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), - self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'module_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('group_module'); - $this->setPhpName('GroupModule'); - $this->setClassName('\\Thelia\\Model\\GroupModule'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignKey('GROUP_ID', 'GroupId', 'INTEGER', 'group', 'ID', true, null, null); - $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', false, null, null); - $this->addColumn('ACCESS', 'Access', 'TINYINT', false, null, 0); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'CASCADE'); - $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - ); - } // getBehaviors() - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { - return null; - } - - return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return (int) $row[ - $indexType == TableMap::TYPE_NUM - ? 0 + $offset - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) - ]; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? GroupModuleTableMap::CLASS_DEFAULT : GroupModuleTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (GroupModule object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = GroupModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = GroupModuleTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + GroupModuleTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupModuleTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - GroupModuleTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = GroupModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = GroupModuleTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - GroupModuleTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(GroupModuleTableMap::ID); - $criteria->addSelectColumn(GroupModuleTableMap::GROUP_ID); - $criteria->addSelectColumn(GroupModuleTableMap::MODULE_ID); - $criteria->addSelectColumn(GroupModuleTableMap::ACCESS); - $criteria->addSelectColumn(GroupModuleTableMap::CREATED_AT); - $criteria->addSelectColumn(GroupModuleTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); - $criteria->addSelectColumn($alias . '.MODULE_ID'); - $criteria->addSelectColumn($alias . '.ACCESS'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(GroupModuleTableMap::DATABASE_NAME)->getTable(GroupModuleTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupModuleTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(GroupModuleTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new GroupModuleTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a GroupModule or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or GroupModule object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\GroupModule) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(GroupModuleTableMap::DATABASE_NAME); - $criteria->add(GroupModuleTableMap::ID, (array) $values, Criteria::IN); - } - - $query = GroupModuleQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { GroupModuleTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { GroupModuleTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the group_module table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return GroupModuleQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a GroupModule or Criteria object. - * - * @param mixed $criteria Criteria or GroupModule object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupModuleTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from GroupModule object - } - - if ($criteria->containsKey(GroupModuleTableMap::ID) && $criteria->keyContainsValue(GroupModuleTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupModuleTableMap::ID.')'); - } - - - // Set the correct dbName - $query = GroupModuleQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // GroupModuleTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -GroupModuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/GroupResourceTableMap.php b/core/lib/Thelia/Model/Map/GroupResourceTableMap.php deleted file mode 100644 index 9304d8e59..000000000 --- a/core/lib/Thelia/Model/Map/GroupResourceTableMap.php +++ /dev/null @@ -1,525 +0,0 @@ - array('Id', 'GroupId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'groupId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(GroupResourceTableMap::ID, GroupResourceTableMap::GROUP_ID, GroupResourceTableMap::RESOURCE_ID, GroupResourceTableMap::READ, GroupResourceTableMap::WRITE, GroupResourceTableMap::CREATED_AT, GroupResourceTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'GROUP_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'group_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'GroupId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'groupId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), - self::TYPE_COLNAME => array(GroupResourceTableMap::ID => 0, GroupResourceTableMap::GROUP_ID => 1, GroupResourceTableMap::RESOURCE_ID => 2, GroupResourceTableMap::READ => 3, GroupResourceTableMap::WRITE => 4, GroupResourceTableMap::CREATED_AT => 5, GroupResourceTableMap::UPDATED_AT => 6, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'GROUP_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), - self::TYPE_FIELDNAME => array('id' => 0, 'group_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('group_resource'); - $this->setPhpName('GroupResource'); - $this->setClassName('\\Thelia\\Model\\GroupResource'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - $this->setIsCrossRef(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addForeignPrimaryKey('GROUP_ID', 'GroupId', 'INTEGER' , 'group', 'ID', true, null, null); - $this->addForeignPrimaryKey('RESOURCE_ID', 'ResourceId', 'INTEGER' , 'resource', 'ID', true, null, null); - $this->addColumn('READ', 'Read', 'TINYINT', false, null, 0); - $this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_ONE, array('group_id' => 'id', ), 'CASCADE', 'RESTRICT'); - $this->addRelation('Resource', '\\Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - ); - } // getBehaviors() - - /** - * Adds an object to the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases you may need to explicitly add objects - * to the cache in order to ensure that the same objects are always returned by find*() - * and findPk*() calls. - * - * @param \Thelia\Model\GroupResource $obj A \Thelia\Model\GroupResource object. - * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). - */ - public static function addInstanceToPool($obj, $key = null) - { - if (Propel::isInstancePoolingEnabled()) { - if (null === $key) { - $key = serialize(array((string) $obj->getId(), (string) $obj->getGroupId(), (string) $obj->getResourceId())); - } // if key === null - self::$instances[$key] = $obj; - } - } - - /** - * Removes an object from the instance pool. - * - * Propel keeps cached copies of objects in an instance pool when they are retrieved - * from the database. In some cases -- especially when you override doDelete - * methods in your stub classes -- you may need to explicitly remove objects - * from the cache in order to prevent returning objects that no longer exist. - * - * @param mixed $value A \Thelia\Model\GroupResource object or a primary key value. - */ - public static function removeInstanceFromPool($value) - { - if (Propel::isInstancePoolingEnabled() && null !== $value) { - if (is_object($value) && $value instanceof \Thelia\Model\GroupResource) { - $key = serialize(array((string) $value->getId(), (string) $value->getGroupId(), (string) $value->getResourceId())); - - } elseif (is_array($value) && count($value) === 3) { - // assume we've been passed a primary key"; - $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2])); - } elseif ($value instanceof Criteria) { - self::$instances = []; - - return; - } else { - $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\GroupResource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); - throw $e; - } - - unset(self::$instances[$key]); - } - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)] === null) { - return null; - } - - return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('GroupId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)])); - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return $pks; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? GroupResourceTableMap::CLASS_DEFAULT : GroupResourceTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (GroupResource object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = GroupResourceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = GroupResourceTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + GroupResourceTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupResourceTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - GroupResourceTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = GroupResourceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = GroupResourceTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - GroupResourceTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(GroupResourceTableMap::ID); - $criteria->addSelectColumn(GroupResourceTableMap::GROUP_ID); - $criteria->addSelectColumn(GroupResourceTableMap::RESOURCE_ID); - $criteria->addSelectColumn(GroupResourceTableMap::READ); - $criteria->addSelectColumn(GroupResourceTableMap::WRITE); - $criteria->addSelectColumn(GroupResourceTableMap::CREATED_AT); - $criteria->addSelectColumn(GroupResourceTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.GROUP_ID'); - $criteria->addSelectColumn($alias . '.RESOURCE_ID'); - $criteria->addSelectColumn($alias . '.READ'); - $criteria->addSelectColumn($alias . '.WRITE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(GroupResourceTableMap::DATABASE_NAME)->getTable(GroupResourceTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupResourceTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(GroupResourceTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new GroupResourceTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a GroupResource or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or GroupResource object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\GroupResource) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(GroupResourceTableMap::DATABASE_NAME); - // primary key is composite; we therefore, expect - // the primary key passed to be an array of pkey values - if (count($values) == count($values, COUNT_RECURSIVE)) { - // array is not multi-dimensional - $values = array($values); - } - foreach ($values as $value) { - $criterion = $criteria->getNewCriterion(GroupResourceTableMap::ID, $value[0]); - $criterion->addAnd($criteria->getNewCriterion(GroupResourceTableMap::GROUP_ID, $value[1])); - $criterion->addAnd($criteria->getNewCriterion(GroupResourceTableMap::RESOURCE_ID, $value[2])); - $criteria->addOr($criterion); - } - } - - $query = GroupResourceQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { GroupResourceTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { GroupResourceTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the group_resource table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return GroupResourceQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a GroupResource or Criteria object. - * - * @param mixed $criteria Criteria or GroupResource object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupResourceTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from GroupResource object - } - - if ($criteria->containsKey(GroupResourceTableMap::ID) && $criteria->keyContainsValue(GroupResourceTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupResourceTableMap::ID.')'); - } - - - // Set the correct dbName - $query = GroupResourceQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // GroupResourceTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -GroupResourceTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/GroupTableMap.php b/core/lib/Thelia/Model/Map/GroupTableMap.php deleted file mode 100644 index 881a2fa84..000000000 --- a/core/lib/Thelia/Model/Map/GroupTableMap.php +++ /dev/null @@ -1,466 +0,0 @@ - array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(GroupTableMap::ID, GroupTableMap::CODE, GroupTableMap::CREATED_AT, GroupTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, ) - ); - - /** - * holds an array of keys for quick access to the fieldnames array - * - * first dimension keys are the type constants - * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 - */ - protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), - self::TYPE_COLNAME => array(GroupTableMap::ID => 0, GroupTableMap::CODE => 1, GroupTableMap::CREATED_AT => 2, GroupTableMap::UPDATED_AT => 3, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), - self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), - self::TYPE_NUM => array(0, 1, 2, 3, ) - ); - - /** - * Initialize the table attributes and columns - * Relations are not initialized by this method since they are lazy loaded - * - * @return void - * @throws PropelException - */ - public function initialize() - { - // attributes - $this->setName('group'); - $this->setPhpName('Group'); - $this->setClassName('\\Thelia\\Model\\Group'); - $this->setPackage('Thelia.Model'); - $this->setUseIdGenerator(true); - // columns - $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); - $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null); - $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); - $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); - } // initialize() - - /** - * Build the RelationMap objects for this table relationships - */ - public function buildRelations() - { - $this->addRelation('AdminGroup', '\\Thelia\\Model\\AdminGroup', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'AdminGroups'); - $this->addRelation('GroupResource', '\\Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'RESTRICT', 'GroupResources'); - $this->addRelation('GroupModule', '\\Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'group_id', ), 'CASCADE', 'CASCADE', 'GroupModules'); - $this->addRelation('GroupI18n', '\\Thelia\\Model\\GroupI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'GroupI18ns'); - $this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Admins'); - $this->addRelation('Resource', '\\Thelia\\Model\\Resource', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Resources'); - } // buildRelations() - - /** - * - * Gets the list of behaviors registered for this table - * - * @return array Associative array (name => parameters) of behaviors - */ - public function getBehaviors() - { - return array( - 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), - 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), - ); - } // getBehaviors() - /** - * Method to invalidate the instance pool of all tables related to group * by a foreign key with ON DELETE CASCADE - */ - public static function clearRelatedInstancePool() - { - // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, - // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - AdminGroupTableMap::clearInstancePool(); - GroupResourceTableMap::clearInstancePool(); - GroupModuleTableMap::clearInstancePool(); - GroupI18nTableMap::clearInstancePool(); - } - - /** - * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. - * - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, a serialize()d version of the primary key will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - */ - public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - // If the PK cannot be derived from the row, return NULL. - if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { - return null; - } - - return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; - } - - /** - * Retrieves the primary key from the DB resultset row - * For tables with a single-column primary key, that simple pkey value will be returned. For tables with - * a multi-column primary key, an array of the primary key columns will be returned. - * - * @param array $row resultset row. - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM - * - * @return mixed The primary key of the row - */ - public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - - return (int) $row[ - $indexType == TableMap::TYPE_NUM - ? 0 + $offset - : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) - ]; - } - - /** - * The class that the tableMap will make instances of. - * - * If $withPrefix is true, the returned path - * uses a dot-path notation which is translated into a path - * relative to a location on the PHP include_path. - * (e.g. path.to.MyClass -> 'path/to/MyClass.php') - * - * @param boolean $withPrefix Whether or not to return the path with the class name - * @return string path.to.ClassName - */ - public static function getOMClass($withPrefix = true) - { - return $withPrefix ? GroupTableMap::CLASS_DEFAULT : GroupTableMap::OM_CLASS; - } - - /** - * Populates an object of the default type or an object that inherit from the default. - * - * @param array $row row returned by DataFetcher->fetch(). - * @param int $offset The 0-based offset for reading from the resultset row. - * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). - One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME - * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. - * - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - * @return array (Group object, last column rank) - */ - public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) - { - $key = GroupTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); - if (null !== ($obj = GroupTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, $offset, true); // rehydrate - $col = $offset + GroupTableMap::NUM_HYDRATE_COLUMNS; - } else { - $cls = GroupTableMap::OM_CLASS; - $obj = new $cls(); - $col = $obj->hydrate($row, $offset, false, $indexType); - GroupTableMap::addInstanceToPool($obj, $key); - } - - return array($obj, $col); - } - - /** - * The returned array will contain objects of the default type or - * objects that inherit from the default. - * - * @param DataFetcherInterface $dataFetcher - * @return array - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function populateObjects(DataFetcherInterface $dataFetcher) - { - $results = array(); - - // set the class once to avoid overhead in the loop - $cls = static::getOMClass(false); - // populate the object(s) - while ($row = $dataFetcher->fetch()) { - $key = GroupTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); - if (null !== ($obj = GroupTableMap::getInstanceFromPool($key))) { - // We no longer rehydrate the object, since this can cause data loss. - // See http://www.propelorm.org/ticket/509 - // $obj->hydrate($row, 0, true); // rehydrate - $results[] = $obj; - } else { - $obj = new $cls(); - $obj->hydrate($row); - $results[] = $obj; - GroupTableMap::addInstanceToPool($obj, $key); - } // if key exists - } - - return $results; - } - /** - * Add all the columns needed to create a new object. - * - * Note: any columns that were marked with lazyLoad="true" in the - * XML schema will not be added to the select list and only loaded - * on demand. - * - * @param Criteria $criteria object containing the columns to add. - * @param string $alias optional table alias - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function addSelectColumns(Criteria $criteria, $alias = null) - { - if (null === $alias) { - $criteria->addSelectColumn(GroupTableMap::ID); - $criteria->addSelectColumn(GroupTableMap::CODE); - $criteria->addSelectColumn(GroupTableMap::CREATED_AT); - $criteria->addSelectColumn(GroupTableMap::UPDATED_AT); - } else { - $criteria->addSelectColumn($alias . '.ID'); - $criteria->addSelectColumn($alias . '.CODE'); - $criteria->addSelectColumn($alias . '.CREATED_AT'); - $criteria->addSelectColumn($alias . '.UPDATED_AT'); - } - } - - /** - * Returns the TableMap related to this object. - * This method is not needed for general use but a specific application could have a need. - * @return TableMap - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function getTableMap() - { - return Propel::getServiceContainer()->getDatabaseMap(GroupTableMap::DATABASE_NAME)->getTable(GroupTableMap::TABLE_NAME); - } - - /** - * Add a TableMap instance to the database for this tableMap class. - */ - public static function buildTableMap() - { - $dbMap = Propel::getServiceContainer()->getDatabaseMap(GroupTableMap::DATABASE_NAME); - if (!$dbMap->hasTable(GroupTableMap::TABLE_NAME)) { - $dbMap->addTableObject(new GroupTableMap()); - } - } - - /** - * Performs a DELETE on the database, given a Group or Criteria object OR a primary key value. - * - * @param mixed $values Criteria or Group object or primary key or array of primary keys - * which is used to create the DELETE statement - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows - * if supported by native driver or if emulated using Propel. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doDelete($values, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); - } - - if ($values instanceof Criteria) { - // rename for clarity - $criteria = $values; - } elseif ($values instanceof \Thelia\Model\Group) { // it's a model object - // create criteria based on pk values - $criteria = $values->buildPkeyCriteria(); - } else { // it's a primary key, or an array of pks - $criteria = new Criteria(GroupTableMap::DATABASE_NAME); - $criteria->add(GroupTableMap::ID, (array) $values, Criteria::IN); - } - - $query = GroupQuery::create()->mergeWith($criteria); - - if ($values instanceof Criteria) { GroupTableMap::clearInstancePool(); - } elseif (!is_object($values)) { // it's a primary key, or an array of pks - foreach ((array) $values as $singleval) { GroupTableMap::removeInstanceFromPool($singleval); - } - } - - return $query->delete($con); - } - - /** - * Deletes all rows from the group table. - * - * @param ConnectionInterface $con the connection to use - * @return int The number of affected rows (if supported by underlying database driver). - */ - public static function doDeleteAll(ConnectionInterface $con = null) - { - return GroupQuery::create()->doDeleteAll($con); - } - - /** - * Performs an INSERT on the database, given a Group or Criteria object. - * - * @param mixed $criteria Criteria or Group object containing data that is used to create the INSERT statement. - * @param ConnectionInterface $con the ConnectionInterface connection to use - * @return mixed The new primary key. - * @throws PropelException Any exceptions caught during processing will be - * rethrown wrapped into a PropelException. - */ - public static function doInsert($criteria, ConnectionInterface $con = null) - { - if (null === $con) { - $con = Propel::getServiceContainer()->getWriteConnection(GroupTableMap::DATABASE_NAME); - } - - if ($criteria instanceof Criteria) { - $criteria = clone $criteria; // rename for clarity - } else { - $criteria = $criteria->buildCriteria(); // build Criteria from Group object - } - - if ($criteria->containsKey(GroupTableMap::ID) && $criteria->keyContainsValue(GroupTableMap::ID) ) { - throw new PropelException('Cannot insert a value for auto-increment primary key ('.GroupTableMap::ID.')'); - } - - - // Set the correct dbName - $query = GroupQuery::create()->mergeWith($criteria); - - try { - // use transaction because $criteria could contain info - // for more than one table (I guess, conceivably) - $con->beginTransaction(); - $pk = $query->doInsert($con); - $con->commit(); - } catch (PropelException $e) { - $con->rollBack(); - throw $e; - } - - return $pk; - } - -} // GroupTableMap -// This is the static code needed to register the TableMap for this table with the main Propel class. -// -GroupTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ModuleTableMap.php b/core/lib/Thelia/Model/Map/ModuleTableMap.php index 788048e28..9cb1a12d9 100644 --- a/core/lib/Thelia/Model/Map/ModuleTableMap.php +++ b/core/lib/Thelia/Model/Map/ModuleTableMap.php @@ -187,7 +187,7 @@ class ModuleTableMap extends TableMap $this->addRelation('OrderRelatedByPaymentModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'payment_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByPaymentModuleId'); $this->addRelation('OrderRelatedByDeliveryModuleId', '\\Thelia\\Model\\Order', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'RESTRICT', 'RESTRICT', 'OrdersRelatedByDeliveryModuleId'); $this->addRelation('AreaDeliveryModule', '\\Thelia\\Model\\AreaDeliveryModule', RelationMap::ONE_TO_MANY, array('id' => 'delivery_module_id', ), 'CASCADE', 'RESTRICT', 'AreaDeliveryModules'); - $this->addRelation('GroupModule', '\\Thelia\\Model\\GroupModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'GroupModules'); + $this->addRelation('ProfileModule', '\\Thelia\\Model\\ProfileModule', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'ProfileModules'); $this->addRelation('ModuleImage', '\\Thelia\\Model\\ModuleImage', RelationMap::ONE_TO_MANY, array('id' => 'module_id', ), 'CASCADE', 'RESTRICT', 'ModuleImages'); $this->addRelation('ModuleI18n', '\\Thelia\\Model\\ModuleI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ModuleI18ns'); } // buildRelations() @@ -213,7 +213,7 @@ class ModuleTableMap extends TableMap // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. AreaDeliveryModuleTableMap::clearInstancePool(); - GroupModuleTableMap::clearInstancePool(); + ProfileModuleTableMap::clearInstancePool(); ModuleImageTableMap::clearInstancePool(); ModuleI18nTableMap::clearInstancePool(); } diff --git a/core/lib/Thelia/Model/Map/OrderProductTableMap.php b/core/lib/Thelia/Model/Map/OrderProductTableMap.php index 8144f23a7..d37b79089 100644 --- a/core/lib/Thelia/Model/Map/OrderProductTableMap.php +++ b/core/lib/Thelia/Model/Map/OrderProductTableMap.php @@ -57,7 +57,7 @@ class OrderProductTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 19; + const NUM_COLUMNS = 20; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class OrderProductTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 19; + const NUM_HYDRATE_COLUMNS = 20; /** * the column name for the ID field @@ -139,6 +139,11 @@ class OrderProductTableMap extends TableMap */ const WEIGHT = 'order_product.WEIGHT'; + /** + * the column name for the EAN_CODE field + */ + const EAN_CODE = 'order_product.EAN_CODE'; + /** * the column name for the TAX_RULE_TITLE field */ @@ -176,12 +181,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'TaxRuleTitle', 'TaxRuleDescription', 'Parent', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'taxRuleTitle', 'taxRuleDescription', 'parent', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::TAX_RULE_TITLE, OrderProductTableMap::TAX_RULE_DESCRIPTION, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'TAX_RULE_TITLE', 'TAX_RULE_DESCRIPTION', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'tax_rule_title', 'tax_rule_description', 'parent', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) + self::TYPE_PHPNAME => array('Id', 'OrderId', 'ProductRef', 'ProductSaleElementsRef', 'Title', 'Chapo', 'Description', 'Postscriptum', 'Quantity', 'Price', 'PromoPrice', 'WasNew', 'WasInPromo', 'Weight', 'EanCode', 'TaxRuleTitle', 'TaxRuleDescription', 'Parent', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'orderId', 'productRef', 'productSaleElementsRef', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promoPrice', 'wasNew', 'wasInPromo', 'weight', 'eanCode', 'taxRuleTitle', 'taxRuleDescription', 'parent', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID, OrderProductTableMap::ORDER_ID, OrderProductTableMap::PRODUCT_REF, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF, OrderProductTableMap::TITLE, OrderProductTableMap::CHAPO, OrderProductTableMap::DESCRIPTION, OrderProductTableMap::POSTSCRIPTUM, OrderProductTableMap::QUANTITY, OrderProductTableMap::PRICE, OrderProductTableMap::PROMO_PRICE, OrderProductTableMap::WAS_NEW, OrderProductTableMap::WAS_IN_PROMO, OrderProductTableMap::WEIGHT, OrderProductTableMap::EAN_CODE, OrderProductTableMap::TAX_RULE_TITLE, OrderProductTableMap::TAX_RULE_DESCRIPTION, OrderProductTableMap::PARENT, OrderProductTableMap::CREATED_AT, OrderProductTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'ORDER_ID', 'PRODUCT_REF', 'PRODUCT_SALE_ELEMENTS_REF', 'TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM', 'QUANTITY', 'PRICE', 'PROMO_PRICE', 'WAS_NEW', 'WAS_IN_PROMO', 'WEIGHT', 'EAN_CODE', 'TAX_RULE_TITLE', 'TAX_RULE_DESCRIPTION', 'PARENT', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'order_id', 'product_ref', 'product_sale_elements_ref', 'title', 'chapo', 'description', 'postscriptum', 'quantity', 'price', 'promo_price', 'was_new', 'was_in_promo', 'weight', 'ean_code', 'tax_rule_title', 'tax_rule_description', 'parent', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ) ); /** @@ -191,12 +196,12 @@ class OrderProductTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'TaxRuleTitle' => 14, 'TaxRuleDescription' => 15, 'Parent' => 16, 'CreatedAt' => 17, 'UpdatedAt' => 18, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'taxRuleTitle' => 14, 'taxRuleDescription' => 15, 'parent' => 16, 'createdAt' => 17, 'updatedAt' => 18, ), - self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::TAX_RULE_TITLE => 14, OrderProductTableMap::TAX_RULE_DESCRIPTION => 15, OrderProductTableMap::PARENT => 16, OrderProductTableMap::CREATED_AT => 17, OrderProductTableMap::UPDATED_AT => 18, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'TAX_RULE_TITLE' => 14, 'TAX_RULE_DESCRIPTION' => 15, 'PARENT' => 16, 'CREATED_AT' => 17, 'UPDATED_AT' => 18, ), - self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'tax_rule_title' => 14, 'tax_rule_description' => 15, 'parent' => 16, 'created_at' => 17, 'updated_at' => 18, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, ) + self::TYPE_PHPNAME => array('Id' => 0, 'OrderId' => 1, 'ProductRef' => 2, 'ProductSaleElementsRef' => 3, 'Title' => 4, 'Chapo' => 5, 'Description' => 6, 'Postscriptum' => 7, 'Quantity' => 8, 'Price' => 9, 'PromoPrice' => 10, 'WasNew' => 11, 'WasInPromo' => 12, 'Weight' => 13, 'EanCode' => 14, 'TaxRuleTitle' => 15, 'TaxRuleDescription' => 16, 'Parent' => 17, 'CreatedAt' => 18, 'UpdatedAt' => 19, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'orderId' => 1, 'productRef' => 2, 'productSaleElementsRef' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promoPrice' => 10, 'wasNew' => 11, 'wasInPromo' => 12, 'weight' => 13, 'eanCode' => 14, 'taxRuleTitle' => 15, 'taxRuleDescription' => 16, 'parent' => 17, 'createdAt' => 18, 'updatedAt' => 19, ), + self::TYPE_COLNAME => array(OrderProductTableMap::ID => 0, OrderProductTableMap::ORDER_ID => 1, OrderProductTableMap::PRODUCT_REF => 2, OrderProductTableMap::PRODUCT_SALE_ELEMENTS_REF => 3, OrderProductTableMap::TITLE => 4, OrderProductTableMap::CHAPO => 5, OrderProductTableMap::DESCRIPTION => 6, OrderProductTableMap::POSTSCRIPTUM => 7, OrderProductTableMap::QUANTITY => 8, OrderProductTableMap::PRICE => 9, OrderProductTableMap::PROMO_PRICE => 10, OrderProductTableMap::WAS_NEW => 11, OrderProductTableMap::WAS_IN_PROMO => 12, OrderProductTableMap::WEIGHT => 13, OrderProductTableMap::EAN_CODE => 14, OrderProductTableMap::TAX_RULE_TITLE => 15, OrderProductTableMap::TAX_RULE_DESCRIPTION => 16, OrderProductTableMap::PARENT => 17, OrderProductTableMap::CREATED_AT => 18, OrderProductTableMap::UPDATED_AT => 19, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'ORDER_ID' => 1, 'PRODUCT_REF' => 2, 'PRODUCT_SALE_ELEMENTS_REF' => 3, 'TITLE' => 4, 'CHAPO' => 5, 'DESCRIPTION' => 6, 'POSTSCRIPTUM' => 7, 'QUANTITY' => 8, 'PRICE' => 9, 'PROMO_PRICE' => 10, 'WAS_NEW' => 11, 'WAS_IN_PROMO' => 12, 'WEIGHT' => 13, 'EAN_CODE' => 14, 'TAX_RULE_TITLE' => 15, 'TAX_RULE_DESCRIPTION' => 16, 'PARENT' => 17, 'CREATED_AT' => 18, 'UPDATED_AT' => 19, ), + self::TYPE_FIELDNAME => array('id' => 0, 'order_id' => 1, 'product_ref' => 2, 'product_sale_elements_ref' => 3, 'title' => 4, 'chapo' => 5, 'description' => 6, 'postscriptum' => 7, 'quantity' => 8, 'price' => 9, 'promo_price' => 10, 'was_new' => 11, 'was_in_promo' => 12, 'weight' => 13, 'ean_code' => 14, 'tax_rule_title' => 15, 'tax_rule_description' => 16, 'parent' => 17, 'created_at' => 18, 'updated_at' => 19, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, ) ); /** @@ -229,6 +234,7 @@ class OrderProductTableMap extends TableMap $this->addColumn('WAS_NEW', 'WasNew', 'TINYINT', true, null, null); $this->addColumn('WAS_IN_PROMO', 'WasInPromo', 'TINYINT', true, null, null); $this->addColumn('WEIGHT', 'Weight', 'VARCHAR', false, 45, null); + $this->addColumn('EAN_CODE', 'EanCode', 'VARCHAR', false, 255, null); $this->addColumn('TAX_RULE_TITLE', 'TaxRuleTitle', 'VARCHAR', false, 255, null); $this->addColumn('TAX_RULE_DESCRIPTION', 'TaxRuleDescription', 'CLOB', false, null, null); $this->addColumn('PARENT', 'Parent', 'INTEGER', false, null, null); @@ -421,6 +427,7 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn(OrderProductTableMap::WAS_NEW); $criteria->addSelectColumn(OrderProductTableMap::WAS_IN_PROMO); $criteria->addSelectColumn(OrderProductTableMap::WEIGHT); + $criteria->addSelectColumn(OrderProductTableMap::EAN_CODE); $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_TITLE); $criteria->addSelectColumn(OrderProductTableMap::TAX_RULE_DESCRIPTION); $criteria->addSelectColumn(OrderProductTableMap::PARENT); @@ -441,6 +448,7 @@ class OrderProductTableMap extends TableMap $criteria->addSelectColumn($alias . '.WAS_NEW'); $criteria->addSelectColumn($alias . '.WAS_IN_PROMO'); $criteria->addSelectColumn($alias . '.WEIGHT'); + $criteria->addSelectColumn($alias . '.EAN_CODE'); $criteria->addSelectColumn($alias . '.TAX_RULE_TITLE'); $criteria->addSelectColumn($alias . '.TAX_RULE_DESCRIPTION'); $criteria->addSelectColumn($alias . '.PARENT'); diff --git a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php index 1e894ef24..a4dc06d9f 100644 --- a/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php +++ b/core/lib/Thelia/Model/Map/ProductSaleElementsTableMap.php @@ -57,7 +57,7 @@ class ProductSaleElementsTableMap extends TableMap /** * The total number of columns */ - const NUM_COLUMNS = 10; + const NUM_COLUMNS = 11; /** * The number of lazy-loaded columns @@ -67,7 +67,7 @@ class ProductSaleElementsTableMap extends TableMap /** * The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ - const NUM_HYDRATE_COLUMNS = 10; + const NUM_HYDRATE_COLUMNS = 11; /** * the column name for the ID field @@ -109,6 +109,11 @@ class ProductSaleElementsTableMap extends TableMap */ const IS_DEFAULT = 'product_sale_elements.IS_DEFAULT'; + /** + * the column name for the EAN_CODE field + */ + const EAN_CODE = 'product_sale_elements.EAN_CODE'; + /** * the column name for the CREATED_AT field */ @@ -131,12 +136,12 @@ class ProductSaleElementsTableMap extends TableMap * e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id' */ protected static $fieldNames = array ( - self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'IsDefault', 'CreatedAt', 'UpdatedAt', ), - self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'isDefault', 'createdAt', 'updatedAt', ), - self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::IS_DEFAULT, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), - self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'IS_DEFAULT', 'CREATED_AT', 'UPDATED_AT', ), - self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'is_default', 'created_at', 'updated_at', ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id', 'ProductId', 'Ref', 'Quantity', 'Promo', 'Newness', 'Weight', 'IsDefault', 'EanCode', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'productId', 'ref', 'quantity', 'promo', 'newness', 'weight', 'isDefault', 'eanCode', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID, ProductSaleElementsTableMap::PRODUCT_ID, ProductSaleElementsTableMap::REF, ProductSaleElementsTableMap::QUANTITY, ProductSaleElementsTableMap::PROMO, ProductSaleElementsTableMap::NEWNESS, ProductSaleElementsTableMap::WEIGHT, ProductSaleElementsTableMap::IS_DEFAULT, ProductSaleElementsTableMap::EAN_CODE, ProductSaleElementsTableMap::CREATED_AT, ProductSaleElementsTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PRODUCT_ID', 'REF', 'QUANTITY', 'PROMO', 'NEWNESS', 'WEIGHT', 'IS_DEFAULT', 'EAN_CODE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'product_id', 'ref', 'quantity', 'promo', 'newness', 'weight', 'is_default', 'ean_code', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -146,12 +151,12 @@ class ProductSaleElementsTableMap extends TableMap * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 */ protected static $fieldKeys = array ( - self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'IsDefault' => 7, 'CreatedAt' => 8, 'UpdatedAt' => 9, ), - self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'isDefault' => 7, 'createdAt' => 8, 'updatedAt' => 9, ), - self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::IS_DEFAULT => 7, ProductSaleElementsTableMap::CREATED_AT => 8, ProductSaleElementsTableMap::UPDATED_AT => 9, ), - self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'IS_DEFAULT' => 7, 'CREATED_AT' => 8, 'UPDATED_AT' => 9, ), - self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'is_default' => 7, 'created_at' => 8, 'updated_at' => 9, ), - self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ) + self::TYPE_PHPNAME => array('Id' => 0, 'ProductId' => 1, 'Ref' => 2, 'Quantity' => 3, 'Promo' => 4, 'Newness' => 5, 'Weight' => 6, 'IsDefault' => 7, 'EanCode' => 8, 'CreatedAt' => 9, 'UpdatedAt' => 10, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'productId' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'isDefault' => 7, 'eanCode' => 8, 'createdAt' => 9, 'updatedAt' => 10, ), + self::TYPE_COLNAME => array(ProductSaleElementsTableMap::ID => 0, ProductSaleElementsTableMap::PRODUCT_ID => 1, ProductSaleElementsTableMap::REF => 2, ProductSaleElementsTableMap::QUANTITY => 3, ProductSaleElementsTableMap::PROMO => 4, ProductSaleElementsTableMap::NEWNESS => 5, ProductSaleElementsTableMap::WEIGHT => 6, ProductSaleElementsTableMap::IS_DEFAULT => 7, ProductSaleElementsTableMap::EAN_CODE => 8, ProductSaleElementsTableMap::CREATED_AT => 9, ProductSaleElementsTableMap::UPDATED_AT => 10, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PRODUCT_ID' => 1, 'REF' => 2, 'QUANTITY' => 3, 'PROMO' => 4, 'NEWNESS' => 5, 'WEIGHT' => 6, 'IS_DEFAULT' => 7, 'EAN_CODE' => 8, 'CREATED_AT' => 9, 'UPDATED_AT' => 10, ), + self::TYPE_FIELDNAME => array('id' => 0, 'product_id' => 1, 'ref' => 2, 'quantity' => 3, 'promo' => 4, 'newness' => 5, 'weight' => 6, 'is_default' => 7, 'ean_code' => 8, 'created_at' => 9, 'updated_at' => 10, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) ); /** @@ -178,6 +183,7 @@ class ProductSaleElementsTableMap extends TableMap $this->addColumn('NEWNESS', 'Newness', 'TINYINT', false, null, 0); $this->addColumn('WEIGHT', 'Weight', 'FLOAT', false, null, 0); $this->addColumn('IS_DEFAULT', 'IsDefault', 'BOOLEAN', false, 1, false); + $this->addColumn('EAN_CODE', 'EanCode', 'VARCHAR', false, 255, null); $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); } // initialize() @@ -362,6 +368,7 @@ class ProductSaleElementsTableMap extends TableMap $criteria->addSelectColumn(ProductSaleElementsTableMap::NEWNESS); $criteria->addSelectColumn(ProductSaleElementsTableMap::WEIGHT); $criteria->addSelectColumn(ProductSaleElementsTableMap::IS_DEFAULT); + $criteria->addSelectColumn(ProductSaleElementsTableMap::EAN_CODE); $criteria->addSelectColumn(ProductSaleElementsTableMap::CREATED_AT); $criteria->addSelectColumn(ProductSaleElementsTableMap::UPDATED_AT); } else { @@ -373,6 +380,7 @@ class ProductSaleElementsTableMap extends TableMap $criteria->addSelectColumn($alias . '.NEWNESS'); $criteria->addSelectColumn($alias . '.WEIGHT'); $criteria->addSelectColumn($alias . '.IS_DEFAULT'); + $criteria->addSelectColumn($alias . '.EAN_CODE'); $criteria->addSelectColumn($alias . '.CREATED_AT'); $criteria->addSelectColumn($alias . '.UPDATED_AT'); } diff --git a/core/lib/Thelia/Model/Map/ResourceTableMap.php b/core/lib/Thelia/Model/Map/ResourceTableMap.php index 8d7708ddd..16c9421d6 100644 --- a/core/lib/Thelia/Model/Map/ResourceTableMap.php +++ b/core/lib/Thelia/Model/Map/ResourceTableMap.php @@ -160,9 +160,9 @@ class ResourceTableMap extends TableMap */ public function buildRelations() { - $this->addRelation('GroupResource', '\\Thelia\\Model\\GroupResource', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT', 'GroupResources'); + $this->addRelation('ProfileResource', '\\Thelia\\Model\\ProfileResource', RelationMap::ONE_TO_MANY, array('id' => 'resource_id', ), 'CASCADE', 'RESTRICT', 'ProfileResources'); $this->addRelation('ResourceI18n', '\\Thelia\\Model\\ResourceI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ResourceI18ns'); - $this->addRelation('Group', '\\Thelia\\Model\\Group', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Groups'); + $this->addRelation('Profile', '\\Thelia\\Model\\Profile', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Profiles'); } // buildRelations() /** @@ -185,7 +185,7 @@ class ResourceTableMap extends TableMap { // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. - GroupResourceTableMap::clearInstancePool(); + ProfileResourceTableMap::clearInstancePool(); ResourceI18nTableMap::clearInstancePool(); } diff --git a/install/thelia.sql b/install/thelia.sql index 4371aa4f5..b6445e3b1 100755 --- a/install/thelia.sql +++ b/install/thelia.sql @@ -365,11 +365,12 @@ CREATE TABLE `product_sale_elements` `newness` TINYINT DEFAULT 0, `weight` FLOAT DEFAULT 0, `is_default` TINYINT(1) DEFAULT 0, + `ean_code` VARCHAR(255), `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - UNIQUE INDEX `ref_UNIQUE` (`ref`), INDEX `idx_product_sale_element_product_id` (`product_id`), + INDEX `ref` (`ref`), CONSTRAINT `fk_product_sale_element_product_id` FOREIGN KEY (`product_id`) REFERENCES `product` (`id`) @@ -775,6 +776,7 @@ CREATE TABLE `order_product` `was_new` TINYINT NOT NULL, `was_in_promo` TINYINT NOT NULL, `weight` VARCHAR(45), + `ean_code` VARCHAR(255), `tax_rule_title` VARCHAR(255), `tax_rule_description` LONGTEXT, `parent` INTEGER COMMENT 'not managed yet', @@ -929,12 +931,12 @@ CREATE TABLE `area_delivery_module` ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- group +-- profile -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `group`; +DROP TABLE IF EXISTS `profile`; -CREATE TABLE `group` +CREATE TABLE `profile` ( `id` INTEGER NOT NULL AUTO_INCREMENT, `code` VARCHAR(30) NOT NULL, @@ -983,27 +985,27 @@ CREATE TABLE `admin` ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- admin_group +-- admin_profile -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `admin_group`; +DROP TABLE IF EXISTS `admin_profile`; -CREATE TABLE `admin_group` +CREATE TABLE `admin_profile` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `group_id` INTEGER NOT NULL, + `profile_id` INTEGER NOT NULL, `admin_id` INTEGER NOT NULL, `created_at` DATETIME, `updated_at` DATETIME, - PRIMARY KEY (`id`,`group_id`,`admin_id`), - INDEX `idx_admin_group_group_id` (`group_id`), - INDEX `idx_admin_group_admin_id` (`admin_id`), - CONSTRAINT `fk_admin_group_group_id` - FOREIGN KEY (`group_id`) - REFERENCES `group` (`id`) + PRIMARY KEY (`id`,`profile_id`,`admin_id`), + INDEX `idx_admin_profile_profile_id` (`profile_id`), + INDEX `idx_admin_profile_admin_id` (`admin_id`), + CONSTRAINT `fk_admin_profile_profile_id` + FOREIGN KEY (`profile_id`) + REFERENCES `profile` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, - CONSTRAINT `fk_admin_group_admin_id` + CONSTRAINT `fk_admin_profile_admin_id` FOREIGN KEY (`admin_id`) REFERENCES `admin` (`id`) ON UPDATE RESTRICT @@ -1011,29 +1013,29 @@ CREATE TABLE `admin_group` ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- group_resource +-- profile_resource -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `group_resource`; +DROP TABLE IF EXISTS `profile_resource`; -CREATE TABLE `group_resource` +CREATE TABLE `profile_resource` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `group_id` INTEGER NOT NULL, + `profile_id` INTEGER NOT NULL, `resource_id` INTEGER NOT NULL, `read` TINYINT DEFAULT 0, `write` TINYINT DEFAULT 0, `created_at` DATETIME, `updated_at` DATETIME, - PRIMARY KEY (`id`,`group_id`,`resource_id`), - INDEX `id_group_resource_group_id` (`group_id`), - INDEX `idx_group_resource_resource_id` (`resource_id`), - CONSTRAINT `fk_group_resource_group_id` - FOREIGN KEY (`group_id`) - REFERENCES `group` (`id`) + PRIMARY KEY (`id`,`profile_id`,`resource_id`), + INDEX `id_profile_resource_profile_id` (`profile_id`), + INDEX `idx_profile_resource_resource_id` (`resource_id`), + CONSTRAINT `fk_profile_resource_profile_id` + FOREIGN KEY (`profile_id`) + REFERENCES `profile` (`id`) ON UPDATE RESTRICT ON DELETE CASCADE, - CONSTRAINT `fk_group_resource_resource_id` + CONSTRAINT `fk_profile_resource_resource_id` FOREIGN KEY (`resource_id`) REFERENCES `resource` (`id`) ON UPDATE RESTRICT @@ -1041,28 +1043,28 @@ CREATE TABLE `group_resource` ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- group_module +-- profile_module -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `group_module`; +DROP TABLE IF EXISTS `profile_module`; -CREATE TABLE `group_module` +CREATE TABLE `profile_module` ( `id` INTEGER NOT NULL AUTO_INCREMENT, - `group_id` INTEGER NOT NULL, + `profile_id` INTEGER NOT NULL, `module_id` INTEGER, `access` TINYINT DEFAULT 0, `created_at` DATETIME, `updated_at` DATETIME, PRIMARY KEY (`id`), - INDEX `idx_group_module_group_id` (`group_id`), - INDEX `idx_group_module_module_id` (`module_id`), - CONSTRAINT `fk_group_module_group_id` - FOREIGN KEY (`group_id`) - REFERENCES `group` (`id`) + INDEX `idx_profile_module_profile_id` (`profile_id`), + INDEX `idx_profile_module_module_id` (`module_id`), + CONSTRAINT `fk_profile_module_profile_id` + FOREIGN KEY (`profile_id`) + REFERENCES `profile` (`id`) ON UPDATE CASCADE ON DELETE CASCADE, - CONSTRAINT `fk_group_module_module_id` + CONSTRAINT `fk_profile_module_module_id` FOREIGN KEY (`module_id`) REFERENCES `module` (`id`) ON UPDATE RESTRICT @@ -1971,12 +1973,12 @@ CREATE TABLE `module_i18n` ) ENGINE=InnoDB; -- --------------------------------------------------------------------- --- group_i18n +-- profile_i18n -- --------------------------------------------------------------------- -DROP TABLE IF EXISTS `group_i18n`; +DROP TABLE IF EXISTS `profile_i18n`; -CREATE TABLE `group_i18n` +CREATE TABLE `profile_i18n` ( `id` INTEGER NOT NULL, `locale` VARCHAR(5) DEFAULT 'en_US' NOT NULL, @@ -1985,9 +1987,9 @@ CREATE TABLE `group_i18n` `chapo` TEXT, `postscriptum` TEXT, PRIMARY KEY (`id`,`locale`), - CONSTRAINT `group_i18n_FK_1` + CONSTRAINT `profile_i18n_FK_1` FOREIGN KEY (`id`) - REFERENCES `group` (`id`) + REFERENCES `profile` (`id`) ON DELETE CASCADE ) ENGINE=InnoDB; diff --git a/local/config/schema.xml b/local/config/schema.xml index 65928176e..489631f7f 100755 --- a/local/config/schema.xml +++ b/local/config/schema.xml @@ -284,15 +284,16 @@ + - - - + + + @@ -610,6 +611,7 @@ + @@ -721,7 +723,7 @@
- +
@@ -763,59 +765,59 @@
- +
- + - - + + - + - - + + - +
- +
- + - - + + - + - - + + - +
- +
- + - - + + - + - - + + - + diff --git a/templates/admin/default/configuration.html b/templates/admin/default/configuration.html index b5484a9af..c79bc481e 100644 --- a/templates/admin/default/configuration.html +++ b/templates/admin/default/configuration.html @@ -129,10 +129,10 @@ {/loop} - {loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.admin_profiles"} + {loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.profiles"} - - + + {/loop} diff --git a/templates/admin/default/profiles.html b/templates/admin/default/profiles.html new file mode 100644 index 000000000..f3071aae4 --- /dev/null +++ b/templates/admin/default/profiles.html @@ -0,0 +1,310 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Taxes rules'}{/block} + +{block name="check-permissions"}admin.taxes-rules.view{/block} + +{block name="main-content"} +
+ +
+ + + + {module_include location='taxes_rules_top'} + +
+
+ +
+
+
{intl l='Back-office profiles'}{intl l='Back-office profiles'}
+ + + + + + + + + + + {loop type="tax" name="taxes" backend_context="1"} + + + + + + + + {/loop} + + +
+ {intl l="Taxes"} + {loop type="auth" name="can_create" roles="ADMIN" permissions="admin.taxes.create"} + + + + {/loop} +
{intl l="Name"}{intl l="Description"}{intl l="Actions"}
{$TITLE}{$DESCRIPTION} +
+ {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes.change"} + + {/loop} + + {loop type="auth" name="can_change" roles="ADMIN" permissions="admin.configuration.taxes.change"} + + {/loop} +
+
+
+
+ + +
+ + + {module_include location='taxes_rules_bottom'} + + + + +{* -- Add tax confirmation dialog ----------------------------------- *} +{form name="thelia.admin.tax.add"} + +{if $form_error_message} + {$taxCreateError = true} +{else} + {$taxCreateError = false} +{/if} + +{* Capture the dialog body, to pass it to the generic dialog *} +{capture "tax_create_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='locale'} + + {/form_field} + + {form_field form=$form field='title'} +
+ + +
+ {/form_field} + + {form_field form=$form field='description'} +
+ + + +
+ {/form_field} + + {form_field form=$form field='type'} +
+ + +
+ +
+
+ {/form_field} + + {form_tagged_fields form=$form tag='requirements'} +
+ + {if $formType == 'choice'} + + {/if} + {if $formType == 'text'} + + {/if} +
+ {/form_tagged_fields} + +{/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "tax_create_dialog" + dialog_title = {intl l="Create a new tax"} + dialog_body = {$smarty.capture.tax_create_dialog nofilter} + + dialog_ok_label = {intl l="Create"} + dialog_cancel_label = {intl l="Cancel"} + + form_action = {url path="/admin/configuration/taxes/add"} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } + +{/form} + +{* -- Delete tax confirmation dialog ----------------------------------- *} + +{capture "tax_delete_dialog"} + + + {module_include location='tax_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "tax_delete_dialog" + dialog_title = {intl l="Delete tax"} + dialog_message = {intl l="Do you really want to delete this tax ?"} + + form_action = {url path='/admin/configuration/taxes/delete'} + form_content = {$smarty.capture.tax_delete_dialog nofilter} +} + +{* -- Add tax rule confirmation dialog ----------------------------------- *} +{form name="thelia.admin.taxrule.add"} + +{if $form_error_message} + {$taxRuleCreateError = true} +{else} + {$taxRuleCreateError = false} +{/if} + +{* Capture the dialog body, to pass it to the generic dialog *} +{capture "tax_rule_create_dialog"} + + {form_hidden_fields form=$form} + + {form_field form=$form field='locale'} + + {/form_field} + + {if $form_error}
{$form_error_message}
{/if} + + {form_field form=$form field='title'} +
+ + +
+ {/form_field} + + {form_field form=$form field='description'} +
+ + + +
+ {/form_field} + +{/capture} + + {include + file = "includes/generic-create-dialog.html" + + dialog_id = "tax_rule_create_dialog" + dialog_title = {intl l="Create a new tax rule"} + dialog_body = {$smarty.capture.tax_rule_create_dialog nofilter} + + dialog_ok_label = {intl l="Create"} + dialog_cancel_label = {intl l="Cancel"} + + form_action = {url path="/admin/configuration/taxes_rules/add"} + form_enctype = {form_enctype form=$form} + form_error_message = $form_error_message + } + +{/form} + +{* -- Delete tax rule confirmation dialog ----------------------------------- *} + +{capture "tax_rule_delete_dialog"} + + + {module_include location='tax_rule_delete_form'} + +{/capture} + +{include + file = "includes/generic-confirm-dialog.html" + + dialog_id = "tax_rule_delete_dialog" + dialog_title = {intl l="Delete tax rule"} + dialog_message = {intl l="Do you really want to delete this tax rule ?"} + + form_action = {url path='/admin/configuration/taxes_rules/delete'} + form_content = {$smarty.capture.tax_rule_delete_dialog nofilter} +} + +{/block} + +{block name="javascript-initialization"} + +{javascripts file='assets/js/bootstrap-select/bootstrap-select.js'} + +{/javascripts} + +{javascripts file='assets/js/main.js'} + +{/javascripts} + + + +{/block} \ No newline at end of file From 1545987d5151c5bce7a318469f83a9fd272c5a2c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 21 Oct 2013 09:29:52 +0200 Subject: [PATCH 27/50] update insert script --- install/insert.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/install/insert.sql b/install/insert.sql index 8e6585a5b..ed5d7342b 100755 --- a/install/insert.sql +++ b/install/insert.sql @@ -39,6 +39,8 @@ INSERT INTO `module` (`id`, `code`, `type`, `activate`, `position`, `full_namesp (4, 'FakeCB', 3, 0, 2, 'FakeCB\\FakeCB', NOW(), NOW()); INSERT INTO `module_i18n` (`id`, `locale`, `title`, `description`, `chapo`, `postscriptum`) VALUES +('1', 'en_US', 'Debug bar', NULL, NULL, NULL), +('1', 'fr_FR', 'Debug bar', NULL, NULL, NULL), ('2', 'en_US', '72h delivery', NULL, NULL, NULL), ('2', 'fr_FR', 'Livraison par colissimo en 72h', NULL, NULL, NULL); From a10fa2034045da921726a022751447002e3f95d8 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 21 Oct 2013 10:26:51 +0200 Subject: [PATCH 28/50] create event object for module delete action --- core/lib/Thelia/Action/Module.php | 11 +++- .../Thelia/Config/Resources/routing/admin.xml | 4 ++ .../Controller/Admin/ModuleController.php | 18 ++++++ .../Core/Event/Module/ModuleDeleteEvent.php | 61 +++++++++++++++++++ core/lib/Thelia/Core/Event/TheliaEvents.php | 5 ++ .../admin/default/includes/module-block.html | 2 +- templates/admin/default/modules.html | 9 ++- 7 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 040c9f7b4..4d286d789 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -22,10 +22,13 @@ /*************************************************************************************/ namespace Thelia\Action; +use Propel\Runtime\Propel; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Cache\CacheEvent; +use Thelia\Core\Event\Module\ModuleDeleteEvent; use Thelia\Core\Event\Module\ModuleToggleActivationEvent; use Thelia\Core\Event\TheliaEvents; +use Thelia\Model\Map\ModuleTableMap; use Thelia\Model\ModuleQuery; use Thelia\Module\BaseModule; @@ -59,6 +62,11 @@ class Module extends BaseAction implements EventSubscriberInterface } } + public function delete(ModuleDeleteEvent $event) + { + + } + protected function cacheClear() { $cacheEvent = new CacheEvent($this->container->getParameter('kernel.cache_dir')); @@ -89,7 +97,8 @@ class Module extends BaseAction implements EventSubscriberInterface public static function getSubscribedEvents() { return array( - TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128) + TheliaEvents::MODULE_TOGGLE_ACTIVATION => array('toggleActivation', 128), + TheliaEvents::MODULE_DELETE => array('delete', 128) ); } } diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 7cc0c0f9f..9c6ead6c7 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -825,6 +825,10 @@ \d+
+ + Thelia\Controller\Admin\ModuleController::deleteAction + + diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index c7d020d58..2be309321 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -23,6 +23,7 @@ namespace Thelia\Controller\Admin; +use Thelia\Core\Event\Module\ModuleDeleteEvent; use Thelia\Core\Event\Module\ModuleToggleActivationEvent; use Thelia\Core\Event\TheliaEvents; use Thelia\Module\ModuleManagement; @@ -82,4 +83,21 @@ class ModuleController extends BaseAdminController return $response; } + + public function deleteAction() + { + if (null !== $response = $this->checkAuth("admin.module.delete")) return $response; + + try { + + $module_id = $this->getRequest()->get('module_id'); + + $deleteEvent = new ModuleDeleteEvent($module_id); + + $this->dispatch(TheliaEvents::MODULE_DELETE, $deleteEvent); + + } catch (\Exception $e) { + + } + } } diff --git a/core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php b/core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php new file mode 100644 index 000000000..5622e3931 --- /dev/null +++ b/core/lib/Thelia/Core/Event/Module/ModuleDeleteEvent.php @@ -0,0 +1,61 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Event\Module; + + +/** + * Class ModuleDeleteEvent + * @package Thelia\Core\Event\Module + * @author Manuel Raynaud + */ +class ModuleDeleteEvent extends ModuleEvent +{ + /** + * @var int module id + */ + protected $module_id; + + function __construct($module_id) + { + $this->module_id = $module_id; + } + + /** + * @param int $module_id + */ + public function setModuleId($module_id) + { + $this->module_id = $module_id; + } + + /** + * @return int + */ + public function getModuleId() + { + return $this->module_id; + } + + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index a28c7ffb7..7c2bc17a5 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -665,6 +665,11 @@ final class TheliaEvents */ const MODULE_TOGGLE_ACTIVATION = 'thelia.module.toggleActivation'; + /** + * sent when a module is deleted + */ + const MODULE_DELETE = 'thelia.module.delete'; + /** * sent for clearing cache */ diff --git a/templates/admin/default/includes/module-block.html b/templates/admin/default/includes/module-block.html index dd499393f..658557d4e 100644 --- a/templates/admin/default/includes/module-block.html +++ b/templates/admin/default/includes/module-block.html @@ -48,7 +48,7 @@ {/loop} {loop type="auth" name="can_delete" roles="ADMIN" permissions="admin.modules.delete"} - + {/loop} diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html index c94ba8789..847a5ea4a 100644 --- a/templates/admin/default/modules.html +++ b/templates/admin/default/modules.html @@ -40,8 +40,7 @@ {* Delete module confirmation dialog *} {capture "delete_module_dialog"} - - + {/capture} {include @@ -51,7 +50,7 @@ dialog_title = {intl l="Delete a module"} dialog_message = {intl l="Do you really want to delete this module ?"} - form_action = {url path='/admin/modules/delete'} + form_action = {url path='/admin/configuration/modules/delete'} form_content = {$smarty.capture.delete_module_dialog nofilter} } @@ -95,6 +94,10 @@ }); }); + + $(".module-delete-action").click(function(){ + $("#delete_module_id").val($(this).data("id")); + }); }); {/block} \ No newline at end of file From 28b74234433f2280d76591beb751e7f7a58ae6dc Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 21 Oct 2013 11:30:19 +0200 Subject: [PATCH 29/50] end module removal --- core/lib/Thelia/Action/Module.php | 33 ++++++++++++++++++- .../Controller/Admin/ModuleController.php | 17 +++++++++- .../Thelia/Core/Event/Module/ModuleEvent.php | 5 +++ core/lib/Thelia/Module/BaseModule.php | 4 +-- templates/admin/default/modules.html | 1 + 5 files changed, 56 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 4d286d789..5eaa227ad 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -24,6 +24,7 @@ namespace Thelia\Action; use Propel\Runtime\Propel; use Symfony\Component\EventDispatcher\EventSubscriberInterface; +use Symfony\Component\Filesystem\Filesystem; use Thelia\Core\Event\Cache\CacheEvent; use Thelia\Core\Event\Module\ModuleDeleteEvent; use Thelia\Core\Event\Module\ModuleToggleActivationEvent; @@ -64,7 +65,37 @@ class Module extends BaseAction implements EventSubscriberInterface public function delete(ModuleDeleteEvent $event) { - + if (null !== $module = ModuleQuery::create()->findPk($event->getModuleId())) { + $con = Propel::getWriteConnection(ModuleTableMap::DATABASE_NAME); + $con->beginTransaction(); + + try { + if(null === $module->getFullNamespace()) { + throw new \LogicException('can not instanciante this module if namespace is null. Maybe the model is not loaded ?'); + } + + $reflected = new \ReflectionClass($module->getFullNamespace()); + $instance = $reflected->newInstance(); + $instance->setContainer($this->container); + + $path = dirname($reflected->getFileName()); + + $instance->destroy($con); + + $fs = new Filesystem(); + $fs->remove($path); + + $module->delete($con); + + $con->commit(); + + $event->setModule($module); + + } catch (\Exception $e) { + $con->rollBack(); + throw $e; + } + } } protected function cacheClear() diff --git a/core/lib/Thelia/Controller/Admin/ModuleController.php b/core/lib/Thelia/Controller/Admin/ModuleController.php index 2be309321..a10e9aa8a 100644 --- a/core/lib/Thelia/Controller/Admin/ModuleController.php +++ b/core/lib/Thelia/Controller/Admin/ModuleController.php @@ -88,6 +88,7 @@ class ModuleController extends BaseAdminController { if (null !== $response = $this->checkAuth("admin.module.delete")) return $response; + $message = null; try { $module_id = $this->getRequest()->get('module_id'); @@ -96,8 +97,22 @@ class ModuleController extends BaseAdminController $this->dispatch(TheliaEvents::MODULE_DELETE, $deleteEvent); - } catch (\Exception $e) { + if($deleteEvent->hasModule() === false) { + throw new \LogicException( + $this->getTranslator()->trans("No %obj was updated.", array('%obj' => 'Module'))); + } + } catch (\Exception $e) { + \Thelia\Log\Tlog::getInstance()->error(sprintf("error during module removal : %s", $message)); + $message = $e->getMessage(); + } + + if($message) { + return $this->render("modules", array( + "error_message" => $message + )); + } else { + $this->redirectToRoute('admin.module'); } } } diff --git a/core/lib/Thelia/Core/Event/Module/ModuleEvent.php b/core/lib/Thelia/Core/Event/Module/ModuleEvent.php index c37b2b995..583a3afc9 100644 --- a/core/lib/Thelia/Core/Event/Module/ModuleEvent.php +++ b/core/lib/Thelia/Core/Event/Module/ModuleEvent.php @@ -62,4 +62,9 @@ class ModuleEvent extends ActionEvent return $this->module; } + public function hasModule() + { + return null !== $this->module; + } + } diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 598e25baa..79acdd4b3 100755 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -225,7 +225,7 @@ abstract class BaseModule extends ContainerAware return basename(dirname($this->reflected->getFileName())); } - public function install() + public function install(ConnectionInterface $con = null) { } @@ -249,7 +249,7 @@ abstract class BaseModule extends ContainerAware } - public function destroy() + public function destroy(ConnectionInterface $con = null) { } diff --git a/templates/admin/default/modules.html b/templates/admin/default/modules.html index 847a5ea4a..86c336a04 100644 --- a/templates/admin/default/modules.html +++ b/templates/admin/default/modules.html @@ -25,6 +25,7 @@
+ {if $error_message}
{$error_message}
{/if} {include file="includes/module-block.html" module_type="1" caption_title={intl l='Classic modules'}} {include file="includes/module-block.html" module_type="2" caption_title={intl l='Delivery modules'}} {include file="includes/module-block.html" module_type="3" caption_title={intl l='Payment modules'}} From 6c6227c77a571ed4f794cd49ee6b16f238a797e4 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 21 Oct 2013 11:32:50 +0200 Subject: [PATCH 30/50] clear cache when a module is removed --- core/lib/Thelia/Action/Module.php | 1 + 1 file changed, 1 insertion(+) diff --git a/core/lib/Thelia/Action/Module.php b/core/lib/Thelia/Action/Module.php index 5eaa227ad..ddc285960 100644 --- a/core/lib/Thelia/Action/Module.php +++ b/core/lib/Thelia/Action/Module.php @@ -90,6 +90,7 @@ class Module extends BaseAction implements EventSubscriberInterface $con->commit(); $event->setModule($module); + $this->cacheClear(); } catch (\Exception $e) { $con->rollBack(); From a16fb0d8904b545210b01e9cecc15245a07904a2 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 21 Oct 2013 11:40:45 +0200 Subject: [PATCH 31/50] fiw test suite --- .../Command/{CacheClearTest.php => CacheClearTestSaved.php} | 4 ++++ 1 file changed, 4 insertions(+) rename core/lib/Thelia/Tests/Command/{CacheClearTest.php => CacheClearTestSaved.php} (96%) diff --git a/core/lib/Thelia/Tests/Command/CacheClearTest.php b/core/lib/Thelia/Tests/Command/CacheClearTestSaved.php similarity index 96% rename from core/lib/Thelia/Tests/Command/CacheClearTest.php rename to core/lib/Thelia/Tests/Command/CacheClearTestSaved.php index 00d54cb3b..0d88806f0 100755 --- a/core/lib/Thelia/Tests/Command/CacheClearTest.php +++ b/core/lib/Thelia/Tests/Command/CacheClearTestSaved.php @@ -115,6 +115,10 @@ class CacheClearTest extends \PHPUnit_Framework_TestCase $container->setParameter("kernel.cache_dir", $this->cache_dir); + $dispatcher = $this->getMock("Symfony\Component\EventDispatcher\EventDispatcherInterface"); + + $container->set("event_dispatcher", $dispatcher); + return $container; } From f564db2a8b3edefae953de6b3a5d8ba27ceae416 Mon Sep 17 00:00:00 2001 From: Etienne Roudeix Date: Mon, 21 Oct 2013 11:44:33 +0200 Subject: [PATCH 32/50] WIP : admin profiles --- core/lib/Thelia/Action/Profile.php | 35 +- core/lib/Thelia/Config/Resources/config.xml | 1 + .../Thelia/Config/Resources/routing/admin.xml | 17 + .../Controller/Admin/ProfileController.php | 19 +- .../Core/Event/Profile/ProfileEvent.php | 97 +- .../lib/Thelia/Core/Template/Loop/Profile.php | 105 + core/lib/Thelia/Form/ProfileCreationForm.php | 42 +- .../Thelia/Form/ProfileModificationForm.php | 2 + core/lib/Thelia/Model/AdminProfile.php | 10 + core/lib/Thelia/Model/AdminProfileQuery.php | 21 + core/lib/Thelia/Model/Base/AdminProfile.php | 1508 ++++++++ .../Thelia/Model/Base/AdminProfileQuery.php | 778 ++++ core/lib/Thelia/Model/Base/Profile.php | 3158 +++++++++++++++++ core/lib/Thelia/Model/Base/ProfileI18n.php | 1442 ++++++++ .../Thelia/Model/Base/ProfileI18nQuery.php | 607 ++++ core/lib/Thelia/Model/Base/ProfileModule.php | 1575 ++++++++ .../Thelia/Model/Base/ProfileModuleQuery.php | 804 +++++ core/lib/Thelia/Model/Base/ProfileQuery.php | 940 +++++ .../lib/Thelia/Model/Base/ProfileResource.php | 1649 +++++++++ .../Model/Base/ProfileResourceQuery.php | 868 +++++ .../Thelia/Model/Map/AdminProfileTableMap.php | 509 +++ .../Thelia/Model/Map/ProfileI18nTableMap.php | 497 +++ .../Model/Map/ProfileModuleTableMap.php | 456 +++ .../Model/Map/ProfileResourceTableMap.php | 525 +++ core/lib/Thelia/Model/Map/ProfileTableMap.php | 466 +++ core/lib/Thelia/Model/Profile.php | 11 + core/lib/Thelia/Model/ProfileI18n.php | 10 + core/lib/Thelia/Model/ProfileI18nQuery.php | 21 + core/lib/Thelia/Model/ProfileModule.php | 10 + core/lib/Thelia/Model/ProfileModuleQuery.php | 21 + core/lib/Thelia/Model/ProfileQuery.php | 21 + core/lib/Thelia/Model/ProfileResource.php | 10 + .../lib/Thelia/Model/ProfileResourceQuery.php | 21 + local/config/schema.xml | 23 +- templates/admin/default/configuration.html | 6 +- templates/admin/default/profile-edit.html | 463 ++- templates/admin/default/profiles.html | 215 +- templates/admin/default/tax-edit.html | 2 + templates/admin/default/tax-rule-edit.html | 7 +- templates/admin/default/taxes-rules.html | 4 +- 40 files changed, 16660 insertions(+), 316 deletions(-) create mode 100755 core/lib/Thelia/Core/Template/Loop/Profile.php create mode 100644 core/lib/Thelia/Model/AdminProfile.php create mode 100644 core/lib/Thelia/Model/AdminProfileQuery.php create mode 100644 core/lib/Thelia/Model/Base/AdminProfile.php create mode 100644 core/lib/Thelia/Model/Base/AdminProfileQuery.php create mode 100644 core/lib/Thelia/Model/Base/Profile.php create mode 100644 core/lib/Thelia/Model/Base/ProfileI18n.php create mode 100644 core/lib/Thelia/Model/Base/ProfileI18nQuery.php create mode 100644 core/lib/Thelia/Model/Base/ProfileModule.php create mode 100644 core/lib/Thelia/Model/Base/ProfileModuleQuery.php create mode 100644 core/lib/Thelia/Model/Base/ProfileQuery.php create mode 100644 core/lib/Thelia/Model/Base/ProfileResource.php create mode 100644 core/lib/Thelia/Model/Base/ProfileResourceQuery.php create mode 100644 core/lib/Thelia/Model/Map/AdminProfileTableMap.php create mode 100644 core/lib/Thelia/Model/Map/ProfileI18nTableMap.php create mode 100644 core/lib/Thelia/Model/Map/ProfileModuleTableMap.php create mode 100644 core/lib/Thelia/Model/Map/ProfileResourceTableMap.php create mode 100644 core/lib/Thelia/Model/Map/ProfileTableMap.php create mode 100644 core/lib/Thelia/Model/Profile.php create mode 100644 core/lib/Thelia/Model/ProfileI18n.php create mode 100644 core/lib/Thelia/Model/ProfileI18nQuery.php create mode 100644 core/lib/Thelia/Model/ProfileModule.php create mode 100644 core/lib/Thelia/Model/ProfileModuleQuery.php create mode 100644 core/lib/Thelia/Model/ProfileQuery.php create mode 100644 core/lib/Thelia/Model/ProfileResource.php create mode 100644 core/lib/Thelia/Model/ProfileResourceQuery.php diff --git a/core/lib/Thelia/Action/Profile.php b/core/lib/Thelia/Action/Profile.php index 58d5b20ac..7c3e5423a 100644 --- a/core/lib/Thelia/Action/Profile.php +++ b/core/lib/Thelia/Action/Profile.php @@ -27,8 +27,8 @@ use Propel\Runtime\ActiveQuery\Criteria; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\Profile\ProfileEvent; use Thelia\Core\Event\TheliaEvents; -use Thelia\Model\Group as GroupModel; -use Thelia\Model\GroupQuery; +use Thelia\Model\Profile as ProfileModel; +use Thelia\Model\ProfileQuery; class Profile extends BaseAction implements EventSubscriberInterface { @@ -37,20 +37,21 @@ class Profile extends BaseAction implements EventSubscriberInterface */ public function create(ProfileEvent $event) { - /*$group = new GroupModel(); + $profile = new ProfileModel(); - $group + $profile ->setDispatcher($this->getDispatcher()) - ->setRequirements($event->getRequirements()) - ->setType($event->getType()) + ->setCode($event->getCode()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) + ->setChapo($event->getChapo()) ->setDescription($event->getDescription()) + ->setPostscriptum($event->getPostscriptum()) ; - $group->save(); + $profile->save(); - $event->setGroup($group);*/ + $event->setProfile($profile); } /** @@ -58,20 +59,20 @@ class Profile extends BaseAction implements EventSubscriberInterface */ public function update(ProfileEvent $event) { - if (null !== $group = GroupQuery::create()->findPk($event->getId())) { + if (null !== $profile = ProfileQuery::create()->findPk($event->getId())) { - /*$group + $profile ->setDispatcher($this->getDispatcher()) - ->setRequirements($event->getRequirements()) - ->setType($event->getType()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) + ->setChapo($event->getChapo()) ->setDescription($event->getDescription()) + ->setPostscriptum($event->getPostscriptum()) ; - $group->save(); + $profile->save(); - $event->setGroup($group);*/ + $event->setProfile($profile); } } @@ -80,13 +81,13 @@ class Profile extends BaseAction implements EventSubscriberInterface */ public function delete(ProfileEvent $event) { - if (null !== $group = GroupQuery::create()->findPk($event->getId())) { + if (null !== $profile = ProfileQuery::create()->findPk($event->getId())) { - /*$group + $profile ->delete() ; - $event->setGroup($group);*/ + $event->setProfile($profile); } } diff --git a/core/lib/Thelia/Config/Resources/config.xml b/core/lib/Thelia/Config/Resources/config.xml index 83f17a6e1..7e77e30a0 100755 --- a/core/lib/Thelia/Config/Resources/config.xml +++ b/core/lib/Thelia/Config/Resources/config.xml @@ -33,6 +33,7 @@ + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 05e31a3ca..bc84ccf16 100755 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -764,6 +764,23 @@ \d+ + + Thelia\Controller\Admin\ProfileController::updateAction + \d+ + + + + Thelia\Controller\Admin\ProfileController::createAction + + + + Thelia\Controller\Admin\ProfileController::processUpdateAction + + + + Thelia\Controller\Admin\ProfileController::deleteAction + + diff --git a/core/lib/Thelia/Controller/Admin/ProfileController.php b/core/lib/Thelia/Controller/Admin/ProfileController.php index 542cafc04..619fc0ea3 100644 --- a/core/lib/Thelia/Controller/Admin/ProfileController.php +++ b/core/lib/Thelia/Controller/Admin/ProfileController.php @@ -44,9 +44,9 @@ class ProfileController extends AbstractCrudController 'admin.configuration.profile.update', 'admin.configuration.profile.delete', - TheliaEvents::TAX_CREATE, - TheliaEvents::TAX_UPDATE, - TheliaEvents::TAX_DELETE + TheliaEvents::PROFILE_CREATE, + TheliaEvents::PROFILE_UPDATE, + TheliaEvents::PROFILE_DELETE ); } @@ -65,10 +65,11 @@ class ProfileController extends AbstractCrudController $event = new ProfileEvent(); $event->setLocale($formData['locale']); + $event->setCode($formData['code']); $event->setTitle($formData['title']); + $event->setChapo($formData['chapo']); $event->setDescription($formData['description']); - $event->setType($formData['type']); - $event->setRequirements($this->getRequirements($formData['type'], $formData)); + $event->setPostscriptum($formData['postscriptum']); return $event; } @@ -80,9 +81,9 @@ class ProfileController extends AbstractCrudController $event->setLocale($formData['locale']); $event->setId($formData['id']); $event->setTitle($formData['title']); + $event->setChapo($formData['chapo']); $event->setDescription($formData['description']); - $event->setType($formData['type']); - $event->setRequirements($this->getRequirements($formData['type'], $formData)); + $event->setPostscriptum($formData['postscriptum']); return $event; } @@ -110,7 +111,7 @@ class ProfileController extends AbstractCrudController 'locale' => $object->getLocale(), 'title' => $object->getTitle(), 'description' => $object->getDescription(), - 'type' => $object->getType(), + 'code' => $object->getCode(), ); // Setup the object form @@ -170,7 +171,7 @@ class ProfileController extends AbstractCrudController { // We always return to the feature edition form $this->redirectToRoute( - "admin.configuration.profilees.update", + "admin.configuration.profiles.update", $this->getViewArguments($country), $this->getRouteArguments() ); diff --git a/core/lib/Thelia/Core/Event/Profile/ProfileEvent.php b/core/lib/Thelia/Core/Event/Profile/ProfileEvent.php index f5cd44e76..e4f236862 100644 --- a/core/lib/Thelia/Core/Event/Profile/ProfileEvent.php +++ b/core/lib/Thelia/Core/Event/Profile/ProfileEvent.php @@ -24,31 +24,108 @@ namespace Thelia\Core\Event\Profile; use Thelia\Core\Event\ActionEvent; -use Thelia\Model\Group; +use Thelia\Model\Profile; class ProfileEvent extends ActionEvent { - protected $group = null; + protected $profile = null; + protected $id = null; + protected $locale = null; + protected $code = null; + protected $title = null; + protected $chapo = null; + protected $description = null; + protected $postscriptum = null; - public function __construct(Group $group = null) + public function __construct(Profile $profile = null) { - $this->group = $group; + $this->profile = $profile; } - public function hasGroup() + public function hasProfile() { - return ! is_null($this->group); + return ! is_null($this->profile); } - public function getGroup() + public function getProfile() { - return $this->group; + return $this->profile; } - public function setGroup(Group $group) + public function setProfile(Profile $profile) { - $this->group = $group; + $this->profile = $profile; return $this; } + + public function setId($id) + { + $this->id = $id; + } + + public function getId() + { + return $this->id; + } + + public function setCode($code) + { + $this->code = $code; + } + + public function getCode() + { + return $this->code; + } + + public function setChapo($chapo) + { + $this->chapo = $chapo; + } + + public function getChapo() + { + return $this->chapo; + } + + public function setDescription($description) + { + $this->description = $description; + } + + public function getDescription() + { + return $this->description; + } + + public function setLocale($locale) + { + $this->locale = $locale; + } + + public function getLocale() + { + return $this->locale; + } + + public function setPostscriptum($postscriptum) + { + $this->postscriptum = $postscriptum; + } + + public function getPostscriptum() + { + return $this->postscriptum; + } + + public function setTitle($title) + { + $this->title = $title; + } + + public function getTitle() + { + return $this->title; + } } diff --git a/core/lib/Thelia/Core/Template/Loop/Profile.php b/core/lib/Thelia/Core/Template/Loop/Profile.php new file mode 100755 index 000000000..02c6a6893 --- /dev/null +++ b/core/lib/Thelia/Core/Template/Loop/Profile.php @@ -0,0 +1,105 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Core\Template\Loop; + +use Propel\Runtime\ActiveQuery\Criteria; +use Thelia\Core\Template\Element\BaseI18nLoop; +use Thelia\Core\Template\Element\LoopResult; +use Thelia\Core\Template\Element\LoopResultRow; + +use Thelia\Core\Template\Loop\Argument\ArgumentCollection; +use Thelia\Core\Template\Loop\Argument\Argument; + +use Thelia\Model\ProfileQuery; +use Thelia\Model\ProductQuery; +use Thelia\Type\TypeCollection; +use Thelia\Type; +use Thelia\Type\BooleanOrBothType; + +/** + * + * Profile loop + * + * + * Class Profile + * @package Thelia\Core\Template\Loop + * @author Etienne Roudeix + */ +class Profile extends BaseI18nLoop +{ + public $timestampable = true; + + /** + * @return ArgumentCollection + */ + protected function getArgDefinitions() + { + return new ArgumentCollection( + Argument::createIntListTypeArgument('id') + ); + } + + /** + * @param $pagination + * + * @return \Thelia\Core\Template\Element\LoopResult + */ + public function exec(&$pagination) + { + $search = ProfileQuery::create(); + + /* manage translations */ + $locale = $this->configureI18nProcessing($search); + + $id = $this->getId(); + + if (null !== $id) { + $search->filterById($id, Criteria::IN); + } + + $search->orderById(Criteria::ASC); + + /* perform search */ + $features = $this->search($search, $pagination); + + $loopResult = new LoopResult($features); + + foreach ($features as $feature) { + $loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable); + $loopResultRow->set("ID", $feature->getId()) + ->set("IS_TRANSLATED",$feature->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE",$locale) + ->set("CODE",$feature->getCode()) + ->set("TITLE",$feature->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM')) + ; + + $loopResult->addRow($loopResultRow); + } + + return $loopResult; + } +} diff --git a/core/lib/Thelia/Form/ProfileCreationForm.php b/core/lib/Thelia/Form/ProfileCreationForm.php index 6aaae8043..ae32ae5a0 100644 --- a/core/lib/Thelia/Form/ProfileCreationForm.php +++ b/core/lib/Thelia/Form/ProfileCreationForm.php @@ -24,7 +24,9 @@ namespace Thelia\Form; use Symfony\Component\Validator\Constraints; use Symfony\Component\Validator\Constraints\NotBlank; +use Symfony\Component\Validator\ExecutionContextInterface; use Thelia\Core\Translation\Translator; +use Thelia\Model\ProfileQuery; /** * Class ProfileCreationForm @@ -37,36 +39,42 @@ class ProfileCreationForm extends BaseForm protected function buildForm($change_mode = false) { - $types = ProfileEngine::getInstance()->getProfileTypeList(); - $typeList = array(); - $requirementList = array(); - foreach($types as $type) { - $classPath = "\\Thelia\\ProfileEngine\\ProfileType\\$type"; - $instance = new $classPath(); - $typeList[$type] = $instance->getTitle(); - $requirementList[$type] = $instance->getRequirementsList(); - } - $this->formBuilder ->add("locale", "text", array( "constraints" => array(new NotBlank()) )) - ->add("type", "choice", array( - "choices" => $typeList, - "required" => true, + ->add("code", "text", array( "constraints" => array( - new Constraints\NotBlank(), + new NotBlank(), + new Constraints\Callback( + array( + "methods" => array( + array($this, "verifyCode"), + ), + ) + ), ), - "label" => Translator::getInstance()->trans("Type"), - "label_attr" => array("for" => "type_field"), + "label" => Translator::getInstance()->trans("Profile Code"), + "label_attr" => array("for" => "profile_code_fiels"), )) ; - $this->addStandardDescFields(array('postscriptum', 'chapo', 'locale')); + $this->addStandardDescFields(array('locale')); } public function getName() { return "thelia_profile_creation"; } + + public function verifyCode($value, ExecutionContextInterface $context) + { + /* check unicity */ + $profile = ProfileQuery::create() + ->findOneByCode($value); + + if (null !== $profile) { + $context->addViolation("Profile `code` already exists"); + } + } } diff --git a/core/lib/Thelia/Form/ProfileModificationForm.php b/core/lib/Thelia/Form/ProfileModificationForm.php index 6865b1109..711ecea56 100644 --- a/core/lib/Thelia/Form/ProfileModificationForm.php +++ b/core/lib/Thelia/Form/ProfileModificationForm.php @@ -52,6 +52,8 @@ class ProfileModificationForm extends ProfileCreationForm ) )) ; + + $this->formBuilder->remove("code"); } public function getName() diff --git a/core/lib/Thelia/Model/AdminProfile.php b/core/lib/Thelia/Model/AdminProfile.php new file mode 100644 index 000000000..767333c22 --- /dev/null +++ b/core/lib/Thelia/Model/AdminProfile.php @@ -0,0 +1,10 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another AdminProfile instance. If + * obj is an instance of AdminProfile, delegates to + * equals(AdminProfile). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return AdminProfile The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return AdminProfile The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [profile_id] column value. + * + * @return int + */ + public function getProfileId() + { + + return $this->profile_id; + } + + /** + * Get the [admin_id] column value. + * + * @return int + */ + public function getAdminId() + { + + return $this->admin_id; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\AdminProfile The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = AdminProfileTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [profile_id] column. + * + * @param int $v new value + * @return \Thelia\Model\AdminProfile The current object (for fluent API support) + */ + public function setProfileId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->profile_id !== $v) { + $this->profile_id = $v; + $this->modifiedColumns[] = AdminProfileTableMap::PROFILE_ID; + } + + if ($this->aProfile !== null && $this->aProfile->getId() !== $v) { + $this->aProfile = null; + } + + + return $this; + } // setProfileId() + + /** + * Set the value of [admin_id] column. + * + * @param int $v new value + * @return \Thelia\Model\AdminProfile The current object (for fluent API support) + */ + public function setAdminId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->admin_id !== $v) { + $this->admin_id = $v; + $this->modifiedColumns[] = AdminProfileTableMap::ADMIN_ID; + } + + if ($this->aAdmin !== null && $this->aAdmin->getId() !== $v) { + $this->aAdmin = null; + } + + + return $this; + } // setAdminId() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\AdminProfile The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = AdminProfileTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\AdminProfile The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = AdminProfileTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : AdminProfileTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : AdminProfileTableMap::translateFieldName('ProfileId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->profile_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : AdminProfileTableMap::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->admin_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : AdminProfileTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : AdminProfileTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 5; // 5 = AdminProfileTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\AdminProfile object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProfile !== null && $this->profile_id !== $this->aProfile->getId()) { + $this->aProfile = null; + } + if ($this->aAdmin !== null && $this->admin_id !== $this->aAdmin->getId()) { + $this->aAdmin = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(AdminProfileTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildAdminProfileQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProfile = null; + $this->aAdmin = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see AdminProfile::setDeleted() + * @see AdminProfile::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminProfileTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildAdminProfileQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminProfileTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(AdminProfileTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(AdminProfileTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(AdminProfileTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + AdminProfileTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProfile !== null) { + if ($this->aProfile->isModified() || $this->aProfile->isNew()) { + $affectedRows += $this->aProfile->save($con); + } + $this->setProfile($this->aProfile); + } + + if ($this->aAdmin !== null) { + if ($this->aAdmin->isModified() || $this->aAdmin->isNew()) { + $affectedRows += $this->aAdmin->save($con); + } + $this->setAdmin($this->aAdmin); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = AdminProfileTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . AdminProfileTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(AdminProfileTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(AdminProfileTableMap::PROFILE_ID)) { + $modifiedColumns[':p' . $index++] = 'PROFILE_ID'; + } + if ($this->isColumnModified(AdminProfileTableMap::ADMIN_ID)) { + $modifiedColumns[':p' . $index++] = 'ADMIN_ID'; + } + if ($this->isColumnModified(AdminProfileTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(AdminProfileTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO admin_profile (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'PROFILE_ID': + $stmt->bindValue($identifier, $this->profile_id, PDO::PARAM_INT); + break; + case 'ADMIN_ID': + $stmt->bindValue($identifier, $this->admin_id, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = AdminProfileTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getProfileId(); + break; + case 2: + return $this->getAdminId(); + break; + case 3: + return $this->getCreatedAt(); + break; + case 4: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['AdminProfile'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['AdminProfile'][serialize($this->getPrimaryKey())] = true; + $keys = AdminProfileTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getProfileId(), + $keys[2] => $this->getAdminId(), + $keys[3] => $this->getCreatedAt(), + $keys[4] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProfile) { + $result['Profile'] = $this->aProfile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aAdmin) { + $result['Admin'] = $this->aAdmin->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = AdminProfileTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setProfileId($value); + break; + case 2: + $this->setAdminId($value); + break; + case 3: + $this->setCreatedAt($value); + break; + case 4: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = AdminProfileTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setProfileId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setAdminId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setCreatedAt($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setUpdatedAt($arr[$keys[4]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(AdminProfileTableMap::DATABASE_NAME); + + if ($this->isColumnModified(AdminProfileTableMap::ID)) $criteria->add(AdminProfileTableMap::ID, $this->id); + if ($this->isColumnModified(AdminProfileTableMap::PROFILE_ID)) $criteria->add(AdminProfileTableMap::PROFILE_ID, $this->profile_id); + if ($this->isColumnModified(AdminProfileTableMap::ADMIN_ID)) $criteria->add(AdminProfileTableMap::ADMIN_ID, $this->admin_id); + if ($this->isColumnModified(AdminProfileTableMap::CREATED_AT)) $criteria->add(AdminProfileTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(AdminProfileTableMap::UPDATED_AT)) $criteria->add(AdminProfileTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(AdminProfileTableMap::DATABASE_NAME); + $criteria->add(AdminProfileTableMap::ID, $this->id); + $criteria->add(AdminProfileTableMap::PROFILE_ID, $this->profile_id); + $criteria->add(AdminProfileTableMap::ADMIN_ID, $this->admin_id); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getProfileId(); + $pks[2] = $this->getAdminId(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setProfileId($keys[1]); + $this->setAdminId($keys[2]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getProfileId()) && (null === $this->getAdminId()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\AdminProfile (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setProfileId($this->getProfileId()); + $copyObj->setAdminId($this->getAdminId()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\AdminProfile Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProfile object. + * + * @param ChildProfile $v + * @return \Thelia\Model\AdminProfile The current object (for fluent API support) + * @throws PropelException + */ + public function setProfile(ChildProfile $v = null) + { + if ($v === null) { + $this->setProfileId(NULL); + } else { + $this->setProfileId($v->getId()); + } + + $this->aProfile = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProfile object, it will not be re-added. + if ($v !== null) { + $v->addAdminProfile($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProfile object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProfile The associated ChildProfile object. + * @throws PropelException + */ + public function getProfile(ConnectionInterface $con = null) + { + if ($this->aProfile === null && ($this->profile_id !== null)) { + $this->aProfile = ChildProfileQuery::create()->findPk($this->profile_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProfile->addAdminProfiles($this); + */ + } + + return $this->aProfile; + } + + /** + * Declares an association between this object and a ChildAdmin object. + * + * @param ChildAdmin $v + * @return \Thelia\Model\AdminProfile The current object (for fluent API support) + * @throws PropelException + */ + public function setAdmin(ChildAdmin $v = null) + { + if ($v === null) { + $this->setAdminId(NULL); + } else { + $this->setAdminId($v->getId()); + } + + $this->aAdmin = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildAdmin object, it will not be re-added. + if ($v !== null) { + $v->addAdminProfile($this); + } + + + return $this; + } + + + /** + * Get the associated ChildAdmin object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildAdmin The associated ChildAdmin object. + * @throws PropelException + */ + public function getAdmin(ConnectionInterface $con = null) + { + if ($this->aAdmin === null && ($this->admin_id !== null)) { + $this->aAdmin = ChildAdminQuery::create()->findPk($this->admin_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aAdmin->addAdminProfiles($this); + */ + } + + return $this->aAdmin; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->profile_id = null; + $this->admin_id = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProfile = null; + $this->aAdmin = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(AdminProfileTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildAdminProfile The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = AdminProfileTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/AdminProfileQuery.php b/core/lib/Thelia/Model/Base/AdminProfileQuery.php new file mode 100644 index 000000000..b29c82808 --- /dev/null +++ b/core/lib/Thelia/Model/Base/AdminProfileQuery.php @@ -0,0 +1,778 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34, 56), $con); + * + * + * @param array[$id, $profile_id, $admin_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildAdminProfile|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = AdminProfileTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(AdminProfileTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildAdminProfile A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PROFILE_ID, ADMIN_ID, CREATED_AT, UPDATED_AT FROM admin_profile WHERE ID = :p0 AND PROFILE_ID = :p1 AND ADMIN_ID = :p2'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); + $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildAdminProfile(); + $obj->hydrate($row); + AdminProfileTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildAdminProfile|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(AdminProfileTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(AdminProfileTableMap::PROFILE_ID, $key[1], Criteria::EQUAL); + $this->addUsingAlias(AdminProfileTableMap::ADMIN_ID, $key[2], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(AdminProfileTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(AdminProfileTableMap::PROFILE_ID, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $cton2 = $this->getNewCriterion(AdminProfileTableMap::ADMIN_ID, $key[2], Criteria::EQUAL); + $cton0->addAnd($cton2); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(AdminProfileTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(AdminProfileTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AdminProfileTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the profile_id column + * + * Example usage: + * + * $query->filterByProfileId(1234); // WHERE profile_id = 1234 + * $query->filterByProfileId(array(12, 34)); // WHERE profile_id IN (12, 34) + * $query->filterByProfileId(array('min' => 12)); // WHERE profile_id > 12 + * + * + * @see filterByProfile() + * + * @param mixed $profileId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByProfileId($profileId = null, $comparison = null) + { + if (is_array($profileId)) { + $useMinMax = false; + if (isset($profileId['min'])) { + $this->addUsingAlias(AdminProfileTableMap::PROFILE_ID, $profileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($profileId['max'])) { + $this->addUsingAlias(AdminProfileTableMap::PROFILE_ID, $profileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AdminProfileTableMap::PROFILE_ID, $profileId, $comparison); + } + + /** + * Filter the query on the admin_id column + * + * Example usage: + * + * $query->filterByAdminId(1234); // WHERE admin_id = 1234 + * $query->filterByAdminId(array(12, 34)); // WHERE admin_id IN (12, 34) + * $query->filterByAdminId(array('min' => 12)); // WHERE admin_id > 12 + * + * + * @see filterByAdmin() + * + * @param mixed $adminId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByAdminId($adminId = null, $comparison = null) + { + if (is_array($adminId)) { + $useMinMax = false; + if (isset($adminId['min'])) { + $this->addUsingAlias(AdminProfileTableMap::ADMIN_ID, $adminId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($adminId['max'])) { + $this->addUsingAlias(AdminProfileTableMap::ADMIN_ID, $adminId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AdminProfileTableMap::ADMIN_ID, $adminId, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(AdminProfileTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(AdminProfileTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AdminProfileTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(AdminProfileTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(AdminProfileTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(AdminProfileTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Profile object + * + * @param \Thelia\Model\Profile|ObjectCollection $profile The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByProfile($profile, $comparison = null) + { + if ($profile instanceof \Thelia\Model\Profile) { + return $this + ->addUsingAlias(AdminProfileTableMap::PROFILE_ID, $profile->getId(), $comparison); + } elseif ($profile instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AdminProfileTableMap::PROFILE_ID, $profile->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProfile() only accepts arguments of type \Thelia\Model\Profile or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Profile relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function joinProfile($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Profile'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Profile'); + } + + return $this; + } + + /** + * Use the Profile relation Profile object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProfileQuery A secondary query class using the current class as primary query + */ + public function useProfileQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProfile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Profile', '\Thelia\Model\ProfileQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Admin object + * + * @param \Thelia\Model\Admin|ObjectCollection $admin The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function filterByAdmin($admin, $comparison = null) + { + if ($admin instanceof \Thelia\Model\Admin) { + return $this + ->addUsingAlias(AdminProfileTableMap::ADMIN_ID, $admin->getId(), $comparison); + } elseif ($admin instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(AdminProfileTableMap::ADMIN_ID, $admin->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByAdmin() only accepts arguments of type \Thelia\Model\Admin or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Admin relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function joinAdmin($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Admin'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Admin'); + } + + return $this; + } + + /** + * Use the Admin relation Admin object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AdminQuery A secondary query class using the current class as primary query + */ + public function useAdminQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAdmin($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Admin', '\Thelia\Model\AdminQuery'); + } + + /** + * Exclude object from result + * + * @param ChildAdminProfile $adminProfile Object to remove from the list of results + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function prune($adminProfile = null) + { + if ($adminProfile) { + $this->addCond('pruneCond0', $this->getAliasedColName(AdminProfileTableMap::ID), $adminProfile->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(AdminProfileTableMap::PROFILE_ID), $adminProfile->getProfileId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond2', $this->getAliasedColName(AdminProfileTableMap::ADMIN_ID), $adminProfile->getAdminId(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the admin_profile table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminProfileTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + AdminProfileTableMap::clearInstancePool(); + AdminProfileTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildAdminProfile or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildAdminProfile object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminProfileTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(AdminProfileTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + AdminProfileTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + AdminProfileTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(AdminProfileTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(AdminProfileTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(AdminProfileTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(AdminProfileTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(AdminProfileTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildAdminProfileQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(AdminProfileTableMap::CREATED_AT); + } + +} // AdminProfileQuery diff --git a/core/lib/Thelia/Model/Base/Profile.php b/core/lib/Thelia/Model/Base/Profile.php new file mode 100644 index 000000000..4dbd37408 --- /dev/null +++ b/core/lib/Thelia/Model/Base/Profile.php @@ -0,0 +1,3158 @@ +modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another Profile instance. If + * obj is an instance of Profile, delegates to + * equals(Profile). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return Profile The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return Profile The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [code] column value. + * + * @return string + */ + public function getCode() + { + + return $this->code; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProfileTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [code] column. + * + * @param string $v new value + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function setCode($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->code !== $v) { + $this->code = $v; + $this->modifiedColumns[] = ProfileTableMap::CODE; + } + + + return $this; + } // setCode() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProfileTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProfileTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProfileTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProfileTableMap::translateFieldName('Code', TableMap::TYPE_PHPNAME, $indexType)]; + $this->code = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProfileTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 4; // 4 = ProfileTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\Profile object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProfileQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->collAdminProfiles = null; + + $this->collProfileResources = null; + + $this->collProfileModules = null; + + $this->collProfileI18ns = null; + + $this->collAdmins = null; + $this->collResources = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see Profile::setDeleted() + * @see Profile::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProfileQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProfileTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProfileTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProfileTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProfileTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + if ($this->adminsScheduledForDeletion !== null) { + if (!$this->adminsScheduledForDeletion->isEmpty()) { + $pks = array(); + $pk = $this->getPrimaryKey(); + foreach ($this->adminsScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pks[] = array($pk, $remotePk); + } + + AdminProfileQuery::create() + ->filterByPrimaryKeys($pks) + ->delete($con); + $this->adminsScheduledForDeletion = null; + } + + foreach ($this->getAdmins() as $admin) { + if ($admin->isModified()) { + $admin->save($con); + } + } + } elseif ($this->collAdmins) { + foreach ($this->collAdmins as $admin) { + if ($admin->isModified()) { + $admin->save($con); + } + } + } + + if ($this->resourcesScheduledForDeletion !== null) { + if (!$this->resourcesScheduledForDeletion->isEmpty()) { + $pks = array(); + $pk = $this->getPrimaryKey(); + foreach ($this->resourcesScheduledForDeletion->getPrimaryKeys(false) as $remotePk) { + $pks[] = array($pk, $remotePk); + } + + ProfileResourceQuery::create() + ->filterByPrimaryKeys($pks) + ->delete($con); + $this->resourcesScheduledForDeletion = null; + } + + foreach ($this->getResources() as $resource) { + if ($resource->isModified()) { + $resource->save($con); + } + } + } elseif ($this->collResources) { + foreach ($this->collResources as $resource) { + if ($resource->isModified()) { + $resource->save($con); + } + } + } + + if ($this->adminProfilesScheduledForDeletion !== null) { + if (!$this->adminProfilesScheduledForDeletion->isEmpty()) { + \Thelia\Model\AdminProfileQuery::create() + ->filterByPrimaryKeys($this->adminProfilesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->adminProfilesScheduledForDeletion = null; + } + } + + if ($this->collAdminProfiles !== null) { + foreach ($this->collAdminProfiles as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->profileResourcesScheduledForDeletion !== null) { + if (!$this->profileResourcesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProfileResourceQuery::create() + ->filterByPrimaryKeys($this->profileResourcesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->profileResourcesScheduledForDeletion = null; + } + } + + if ($this->collProfileResources !== null) { + foreach ($this->collProfileResources as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->profileModulesScheduledForDeletion !== null) { + if (!$this->profileModulesScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProfileModuleQuery::create() + ->filterByPrimaryKeys($this->profileModulesScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->profileModulesScheduledForDeletion = null; + } + } + + if ($this->collProfileModules !== null) { + foreach ($this->collProfileModules as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + if ($this->profileI18nsScheduledForDeletion !== null) { + if (!$this->profileI18nsScheduledForDeletion->isEmpty()) { + \Thelia\Model\ProfileI18nQuery::create() + ->filterByPrimaryKeys($this->profileI18nsScheduledForDeletion->getPrimaryKeys(false)) + ->delete($con); + $this->profileI18nsScheduledForDeletion = null; + } + } + + if ($this->collProfileI18ns !== null) { + foreach ($this->collProfileI18ns as $referrerFK) { + if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) { + $affectedRows += $referrerFK->save($con); + } + } + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ProfileTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProfileTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProfileTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProfileTableMap::CODE)) { + $modifiedColumns[':p' . $index++] = 'CODE'; + } + if ($this->isColumnModified(ProfileTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ProfileTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO profile (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'CODE': + $stmt->bindValue($identifier, $this->code, PDO::PARAM_STR); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getCode(); + break; + case 2: + return $this->getCreatedAt(); + break; + case 3: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['Profile'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['Profile'][$this->getPrimaryKey()] = true; + $keys = ProfileTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getCode(), + $keys[2] => $this->getCreatedAt(), + $keys[3] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->collAdminProfiles) { + $result['AdminProfiles'] = $this->collAdminProfiles->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collProfileResources) { + $result['ProfileResources'] = $this->collProfileResources->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collProfileModules) { + $result['ProfileModules'] = $this->collProfileModules->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + if (null !== $this->collProfileI18ns) { + $result['ProfileI18ns'] = $this->collProfileI18ns->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setCode($value); + break; + case 2: + $this->setCreatedAt($value); + break; + case 3: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProfileTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setCode($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setCreatedAt($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setUpdatedAt($arr[$keys[3]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProfileTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProfileTableMap::ID)) $criteria->add(ProfileTableMap::ID, $this->id); + if ($this->isColumnModified(ProfileTableMap::CODE)) $criteria->add(ProfileTableMap::CODE, $this->code); + if ($this->isColumnModified(ProfileTableMap::CREATED_AT)) $criteria->add(ProfileTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProfileTableMap::UPDATED_AT)) $criteria->add(ProfileTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProfileTableMap::DATABASE_NAME); + $criteria->add(ProfileTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\Profile (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setCode($this->getCode()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + + if ($deepCopy) { + // important: temporarily setNew(false) because this affects the behavior of + // the getter/setter methods for fkey referrer objects. + $copyObj->setNew(false); + + foreach ($this->getAdminProfiles() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addAdminProfile($relObj->copy($deepCopy)); + } + } + + foreach ($this->getProfileResources() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProfileResource($relObj->copy($deepCopy)); + } + } + + foreach ($this->getProfileModules() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProfileModule($relObj->copy($deepCopy)); + } + } + + foreach ($this->getProfileI18ns() as $relObj) { + if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves + $copyObj->addProfileI18n($relObj->copy($deepCopy)); + } + } + + } // if ($deepCopy) + + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\Profile Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + + /** + * Initializes a collection based on the name of a relation. + * Avoids crafting an 'init[$relationName]s' method name + * that wouldn't work when StandardEnglishPluralizer is used. + * + * @param string $relationName The name of the relation to initialize + * @return void + */ + public function initRelation($relationName) + { + if ('AdminProfile' == $relationName) { + return $this->initAdminProfiles(); + } + if ('ProfileResource' == $relationName) { + return $this->initProfileResources(); + } + if ('ProfileModule' == $relationName) { + return $this->initProfileModules(); + } + if ('ProfileI18n' == $relationName) { + return $this->initProfileI18ns(); + } + } + + /** + * Clears out the collAdminProfiles collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addAdminProfiles() + */ + public function clearAdminProfiles() + { + $this->collAdminProfiles = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collAdminProfiles collection loaded partially. + */ + public function resetPartialAdminProfiles($v = true) + { + $this->collAdminProfilesPartial = $v; + } + + /** + * Initializes the collAdminProfiles collection. + * + * By default this just sets the collAdminProfiles collection to an empty array (like clearcollAdminProfiles()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initAdminProfiles($overrideExisting = true) + { + if (null !== $this->collAdminProfiles && !$overrideExisting) { + return; + } + $this->collAdminProfiles = new ObjectCollection(); + $this->collAdminProfiles->setModel('\Thelia\Model\AdminProfile'); + } + + /** + * Gets an array of ChildAdminProfile objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProfile is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildAdminProfile[] List of ChildAdminProfile objects + * @throws PropelException + */ + public function getAdminProfiles($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collAdminProfilesPartial && !$this->isNew(); + if (null === $this->collAdminProfiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAdminProfiles) { + // return empty collection + $this->initAdminProfiles(); + } else { + $collAdminProfiles = ChildAdminProfileQuery::create(null, $criteria) + ->filterByProfile($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collAdminProfilesPartial && count($collAdminProfiles)) { + $this->initAdminProfiles(false); + + foreach ($collAdminProfiles as $obj) { + if (false == $this->collAdminProfiles->contains($obj)) { + $this->collAdminProfiles->append($obj); + } + } + + $this->collAdminProfilesPartial = true; + } + + $collAdminProfiles->getInternalIterator()->rewind(); + + return $collAdminProfiles; + } + + if ($partial && $this->collAdminProfiles) { + foreach ($this->collAdminProfiles as $obj) { + if ($obj->isNew()) { + $collAdminProfiles[] = $obj; + } + } + } + + $this->collAdminProfiles = $collAdminProfiles; + $this->collAdminProfilesPartial = false; + } + } + + return $this->collAdminProfiles; + } + + /** + * Sets a collection of AdminProfile objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $adminProfiles A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProfile The current object (for fluent API support) + */ + public function setAdminProfiles(Collection $adminProfiles, ConnectionInterface $con = null) + { + $adminProfilesToDelete = $this->getAdminProfiles(new Criteria(), $con)->diff($adminProfiles); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->adminProfilesScheduledForDeletion = clone $adminProfilesToDelete; + + foreach ($adminProfilesToDelete as $adminProfileRemoved) { + $adminProfileRemoved->setProfile(null); + } + + $this->collAdminProfiles = null; + foreach ($adminProfiles as $adminProfile) { + $this->addAdminProfile($adminProfile); + } + + $this->collAdminProfiles = $adminProfiles; + $this->collAdminProfilesPartial = false; + + return $this; + } + + /** + * Returns the number of related AdminProfile objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related AdminProfile objects. + * @throws PropelException + */ + public function countAdminProfiles(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collAdminProfilesPartial && !$this->isNew(); + if (null === $this->collAdminProfiles || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collAdminProfiles) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getAdminProfiles()); + } + + $query = ChildAdminProfileQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProfile($this) + ->count($con); + } + + return count($this->collAdminProfiles); + } + + /** + * Method called to associate a ChildAdminProfile object to this object + * through the ChildAdminProfile foreign key attribute. + * + * @param ChildAdminProfile $l ChildAdminProfile + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function addAdminProfile(ChildAdminProfile $l) + { + if ($this->collAdminProfiles === null) { + $this->initAdminProfiles(); + $this->collAdminProfilesPartial = true; + } + + if (!in_array($l, $this->collAdminProfiles->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddAdminProfile($l); + } + + return $this; + } + + /** + * @param AdminProfile $adminProfile The adminProfile object to add. + */ + protected function doAddAdminProfile($adminProfile) + { + $this->collAdminProfiles[]= $adminProfile; + $adminProfile->setProfile($this); + } + + /** + * @param AdminProfile $adminProfile The adminProfile object to remove. + * @return ChildProfile The current object (for fluent API support) + */ + public function removeAdminProfile($adminProfile) + { + if ($this->getAdminProfiles()->contains($adminProfile)) { + $this->collAdminProfiles->remove($this->collAdminProfiles->search($adminProfile)); + if (null === $this->adminProfilesScheduledForDeletion) { + $this->adminProfilesScheduledForDeletion = clone $this->collAdminProfiles; + $this->adminProfilesScheduledForDeletion->clear(); + } + $this->adminProfilesScheduledForDeletion[]= clone $adminProfile; + $adminProfile->setProfile(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Profile is new, it will return + * an empty collection; or if this Profile has previously + * been saved, it will retrieve related AdminProfiles from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Profile. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildAdminProfile[] List of ChildAdminProfile objects + */ + public function getAdminProfilesJoinAdmin($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildAdminProfileQuery::create(null, $criteria); + $query->joinWith('Admin', $joinBehavior); + + return $this->getAdminProfiles($query, $con); + } + + /** + * Clears out the collProfileResources collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProfileResources() + */ + public function clearProfileResources() + { + $this->collProfileResources = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProfileResources collection loaded partially. + */ + public function resetPartialProfileResources($v = true) + { + $this->collProfileResourcesPartial = $v; + } + + /** + * Initializes the collProfileResources collection. + * + * By default this just sets the collProfileResources collection to an empty array (like clearcollProfileResources()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProfileResources($overrideExisting = true) + { + if (null !== $this->collProfileResources && !$overrideExisting) { + return; + } + $this->collProfileResources = new ObjectCollection(); + $this->collProfileResources->setModel('\Thelia\Model\ProfileResource'); + } + + /** + * Gets an array of ChildProfileResource objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProfile is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProfileResource[] List of ChildProfileResource objects + * @throws PropelException + */ + public function getProfileResources($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProfileResourcesPartial && !$this->isNew(); + if (null === $this->collProfileResources || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileResources) { + // return empty collection + $this->initProfileResources(); + } else { + $collProfileResources = ChildProfileResourceQuery::create(null, $criteria) + ->filterByProfile($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProfileResourcesPartial && count($collProfileResources)) { + $this->initProfileResources(false); + + foreach ($collProfileResources as $obj) { + if (false == $this->collProfileResources->contains($obj)) { + $this->collProfileResources->append($obj); + } + } + + $this->collProfileResourcesPartial = true; + } + + $collProfileResources->getInternalIterator()->rewind(); + + return $collProfileResources; + } + + if ($partial && $this->collProfileResources) { + foreach ($this->collProfileResources as $obj) { + if ($obj->isNew()) { + $collProfileResources[] = $obj; + } + } + } + + $this->collProfileResources = $collProfileResources; + $this->collProfileResourcesPartial = false; + } + } + + return $this->collProfileResources; + } + + /** + * Sets a collection of ProfileResource objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $profileResources A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProfile The current object (for fluent API support) + */ + public function setProfileResources(Collection $profileResources, ConnectionInterface $con = null) + { + $profileResourcesToDelete = $this->getProfileResources(new Criteria(), $con)->diff($profileResources); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->profileResourcesScheduledForDeletion = clone $profileResourcesToDelete; + + foreach ($profileResourcesToDelete as $profileResourceRemoved) { + $profileResourceRemoved->setProfile(null); + } + + $this->collProfileResources = null; + foreach ($profileResources as $profileResource) { + $this->addProfileResource($profileResource); + } + + $this->collProfileResources = $profileResources; + $this->collProfileResourcesPartial = false; + + return $this; + } + + /** + * Returns the number of related ProfileResource objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProfileResource objects. + * @throws PropelException + */ + public function countProfileResources(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProfileResourcesPartial && !$this->isNew(); + if (null === $this->collProfileResources || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileResources) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProfileResources()); + } + + $query = ChildProfileResourceQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProfile($this) + ->count($con); + } + + return count($this->collProfileResources); + } + + /** + * Method called to associate a ChildProfileResource object to this object + * through the ChildProfileResource foreign key attribute. + * + * @param ChildProfileResource $l ChildProfileResource + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function addProfileResource(ChildProfileResource $l) + { + if ($this->collProfileResources === null) { + $this->initProfileResources(); + $this->collProfileResourcesPartial = true; + } + + if (!in_array($l, $this->collProfileResources->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProfileResource($l); + } + + return $this; + } + + /** + * @param ProfileResource $profileResource The profileResource object to add. + */ + protected function doAddProfileResource($profileResource) + { + $this->collProfileResources[]= $profileResource; + $profileResource->setProfile($this); + } + + /** + * @param ProfileResource $profileResource The profileResource object to remove. + * @return ChildProfile The current object (for fluent API support) + */ + public function removeProfileResource($profileResource) + { + if ($this->getProfileResources()->contains($profileResource)) { + $this->collProfileResources->remove($this->collProfileResources->search($profileResource)); + if (null === $this->profileResourcesScheduledForDeletion) { + $this->profileResourcesScheduledForDeletion = clone $this->collProfileResources; + $this->profileResourcesScheduledForDeletion->clear(); + } + $this->profileResourcesScheduledForDeletion[]= clone $profileResource; + $profileResource->setProfile(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Profile is new, it will return + * an empty collection; or if this Profile has previously + * been saved, it will retrieve related ProfileResources from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Profile. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProfileResource[] List of ChildProfileResource objects + */ + public function getProfileResourcesJoinResource($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProfileResourceQuery::create(null, $criteria); + $query->joinWith('Resource', $joinBehavior); + + return $this->getProfileResources($query, $con); + } + + /** + * Clears out the collProfileModules collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProfileModules() + */ + public function clearProfileModules() + { + $this->collProfileModules = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProfileModules collection loaded partially. + */ + public function resetPartialProfileModules($v = true) + { + $this->collProfileModulesPartial = $v; + } + + /** + * Initializes the collProfileModules collection. + * + * By default this just sets the collProfileModules collection to an empty array (like clearcollProfileModules()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProfileModules($overrideExisting = true) + { + if (null !== $this->collProfileModules && !$overrideExisting) { + return; + } + $this->collProfileModules = new ObjectCollection(); + $this->collProfileModules->setModel('\Thelia\Model\ProfileModule'); + } + + /** + * Gets an array of ChildProfileModule objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProfile is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProfileModule[] List of ChildProfileModule objects + * @throws PropelException + */ + public function getProfileModules($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProfileModulesPartial && !$this->isNew(); + if (null === $this->collProfileModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileModules) { + // return empty collection + $this->initProfileModules(); + } else { + $collProfileModules = ChildProfileModuleQuery::create(null, $criteria) + ->filterByProfile($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProfileModulesPartial && count($collProfileModules)) { + $this->initProfileModules(false); + + foreach ($collProfileModules as $obj) { + if (false == $this->collProfileModules->contains($obj)) { + $this->collProfileModules->append($obj); + } + } + + $this->collProfileModulesPartial = true; + } + + $collProfileModules->getInternalIterator()->rewind(); + + return $collProfileModules; + } + + if ($partial && $this->collProfileModules) { + foreach ($this->collProfileModules as $obj) { + if ($obj->isNew()) { + $collProfileModules[] = $obj; + } + } + } + + $this->collProfileModules = $collProfileModules; + $this->collProfileModulesPartial = false; + } + } + + return $this->collProfileModules; + } + + /** + * Sets a collection of ProfileModule objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $profileModules A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProfile The current object (for fluent API support) + */ + public function setProfileModules(Collection $profileModules, ConnectionInterface $con = null) + { + $profileModulesToDelete = $this->getProfileModules(new Criteria(), $con)->diff($profileModules); + + + $this->profileModulesScheduledForDeletion = $profileModulesToDelete; + + foreach ($profileModulesToDelete as $profileModuleRemoved) { + $profileModuleRemoved->setProfile(null); + } + + $this->collProfileModules = null; + foreach ($profileModules as $profileModule) { + $this->addProfileModule($profileModule); + } + + $this->collProfileModules = $profileModules; + $this->collProfileModulesPartial = false; + + return $this; + } + + /** + * Returns the number of related ProfileModule objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProfileModule objects. + * @throws PropelException + */ + public function countProfileModules(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProfileModulesPartial && !$this->isNew(); + if (null === $this->collProfileModules || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileModules) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProfileModules()); + } + + $query = ChildProfileModuleQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProfile($this) + ->count($con); + } + + return count($this->collProfileModules); + } + + /** + * Method called to associate a ChildProfileModule object to this object + * through the ChildProfileModule foreign key attribute. + * + * @param ChildProfileModule $l ChildProfileModule + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function addProfileModule(ChildProfileModule $l) + { + if ($this->collProfileModules === null) { + $this->initProfileModules(); + $this->collProfileModulesPartial = true; + } + + if (!in_array($l, $this->collProfileModules->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProfileModule($l); + } + + return $this; + } + + /** + * @param ProfileModule $profileModule The profileModule object to add. + */ + protected function doAddProfileModule($profileModule) + { + $this->collProfileModules[]= $profileModule; + $profileModule->setProfile($this); + } + + /** + * @param ProfileModule $profileModule The profileModule object to remove. + * @return ChildProfile The current object (for fluent API support) + */ + public function removeProfileModule($profileModule) + { + if ($this->getProfileModules()->contains($profileModule)) { + $this->collProfileModules->remove($this->collProfileModules->search($profileModule)); + if (null === $this->profileModulesScheduledForDeletion) { + $this->profileModulesScheduledForDeletion = clone $this->collProfileModules; + $this->profileModulesScheduledForDeletion->clear(); + } + $this->profileModulesScheduledForDeletion[]= clone $profileModule; + $profileModule->setProfile(null); + } + + return $this; + } + + + /** + * If this collection has already been initialized with + * an identical criteria, it returns the collection. + * Otherwise if this Profile is new, it will return + * an empty collection; or if this Profile has previously + * been saved, it will retrieve related ProfileModules from storage. + * + * This method is protected by default in order to keep the public + * api reasonable. You can provide public methods for those you + * actually need in Profile. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) + * @return Collection|ChildProfileModule[] List of ChildProfileModule objects + */ + public function getProfileModulesJoinModule($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) + { + $query = ChildProfileModuleQuery::create(null, $criteria); + $query->joinWith('Module', $joinBehavior); + + return $this->getProfileModules($query, $con); + } + + /** + * Clears out the collProfileI18ns collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addProfileI18ns() + */ + public function clearProfileI18ns() + { + $this->collProfileI18ns = null; // important to set this to NULL since that means it is uninitialized + } + + /** + * Reset is the collProfileI18ns collection loaded partially. + */ + public function resetPartialProfileI18ns($v = true) + { + $this->collProfileI18nsPartial = $v; + } + + /** + * Initializes the collProfileI18ns collection. + * + * By default this just sets the collProfileI18ns collection to an empty array (like clearcollProfileI18ns()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @param boolean $overrideExisting If set to true, the method call initializes + * the collection even if it is not empty + * + * @return void + */ + public function initProfileI18ns($overrideExisting = true) + { + if (null !== $this->collProfileI18ns && !$overrideExisting) { + return; + } + $this->collProfileI18ns = new ObjectCollection(); + $this->collProfileI18ns->setModel('\Thelia\Model\ProfileI18n'); + } + + /** + * Gets an array of ChildProfileI18n objects which contain a foreign key that references this object. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProfile is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria optional Criteria object to narrow the query + * @param ConnectionInterface $con optional connection object + * @return Collection|ChildProfileI18n[] List of ChildProfileI18n objects + * @throws PropelException + */ + public function getProfileI18ns($criteria = null, ConnectionInterface $con = null) + { + $partial = $this->collProfileI18nsPartial && !$this->isNew(); + if (null === $this->collProfileI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileI18ns) { + // return empty collection + $this->initProfileI18ns(); + } else { + $collProfileI18ns = ChildProfileI18nQuery::create(null, $criteria) + ->filterByProfile($this) + ->find($con); + + if (null !== $criteria) { + if (false !== $this->collProfileI18nsPartial && count($collProfileI18ns)) { + $this->initProfileI18ns(false); + + foreach ($collProfileI18ns as $obj) { + if (false == $this->collProfileI18ns->contains($obj)) { + $this->collProfileI18ns->append($obj); + } + } + + $this->collProfileI18nsPartial = true; + } + + $collProfileI18ns->getInternalIterator()->rewind(); + + return $collProfileI18ns; + } + + if ($partial && $this->collProfileI18ns) { + foreach ($this->collProfileI18ns as $obj) { + if ($obj->isNew()) { + $collProfileI18ns[] = $obj; + } + } + } + + $this->collProfileI18ns = $collProfileI18ns; + $this->collProfileI18nsPartial = false; + } + } + + return $this->collProfileI18ns; + } + + /** + * Sets a collection of ProfileI18n objects related by a one-to-many relationship + * to the current object. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $profileI18ns A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProfile The current object (for fluent API support) + */ + public function setProfileI18ns(Collection $profileI18ns, ConnectionInterface $con = null) + { + $profileI18nsToDelete = $this->getProfileI18ns(new Criteria(), $con)->diff($profileI18ns); + + + //since at least one column in the foreign key is at the same time a PK + //we can not just set a PK to NULL in the lines below. We have to store + //a backup of all values, so we are able to manipulate these items based on the onDelete value later. + $this->profileI18nsScheduledForDeletion = clone $profileI18nsToDelete; + + foreach ($profileI18nsToDelete as $profileI18nRemoved) { + $profileI18nRemoved->setProfile(null); + } + + $this->collProfileI18ns = null; + foreach ($profileI18ns as $profileI18n) { + $this->addProfileI18n($profileI18n); + } + + $this->collProfileI18ns = $profileI18ns; + $this->collProfileI18nsPartial = false; + + return $this; + } + + /** + * Returns the number of related ProfileI18n objects. + * + * @param Criteria $criteria + * @param boolean $distinct + * @param ConnectionInterface $con + * @return int Count of related ProfileI18n objects. + * @throws PropelException + */ + public function countProfileI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) + { + $partial = $this->collProfileI18nsPartial && !$this->isNew(); + if (null === $this->collProfileI18ns || null !== $criteria || $partial) { + if ($this->isNew() && null === $this->collProfileI18ns) { + return 0; + } + + if ($partial && !$criteria) { + return count($this->getProfileI18ns()); + } + + $query = ChildProfileI18nQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProfile($this) + ->count($con); + } + + return count($this->collProfileI18ns); + } + + /** + * Method called to associate a ChildProfileI18n object to this object + * through the ChildProfileI18n foreign key attribute. + * + * @param ChildProfileI18n $l ChildProfileI18n + * @return \Thelia\Model\Profile The current object (for fluent API support) + */ + public function addProfileI18n(ChildProfileI18n $l) + { + if ($l && $locale = $l->getLocale()) { + $this->setLocale($locale); + $this->currentTranslations[$locale] = $l; + } + if ($this->collProfileI18ns === null) { + $this->initProfileI18ns(); + $this->collProfileI18nsPartial = true; + } + + if (!in_array($l, $this->collProfileI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated + $this->doAddProfileI18n($l); + } + + return $this; + } + + /** + * @param ProfileI18n $profileI18n The profileI18n object to add. + */ + protected function doAddProfileI18n($profileI18n) + { + $this->collProfileI18ns[]= $profileI18n; + $profileI18n->setProfile($this); + } + + /** + * @param ProfileI18n $profileI18n The profileI18n object to remove. + * @return ChildProfile The current object (for fluent API support) + */ + public function removeProfileI18n($profileI18n) + { + if ($this->getProfileI18ns()->contains($profileI18n)) { + $this->collProfileI18ns->remove($this->collProfileI18ns->search($profileI18n)); + if (null === $this->profileI18nsScheduledForDeletion) { + $this->profileI18nsScheduledForDeletion = clone $this->collProfileI18ns; + $this->profileI18nsScheduledForDeletion->clear(); + } + $this->profileI18nsScheduledForDeletion[]= clone $profileI18n; + $profileI18n->setProfile(null); + } + + return $this; + } + + /** + * Clears out the collAdmins collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addAdmins() + */ + public function clearAdmins() + { + $this->collAdmins = null; // important to set this to NULL since that means it is uninitialized + $this->collAdminsPartial = null; + } + + /** + * Initializes the collAdmins collection. + * + * By default this just sets the collAdmins collection to an empty collection (like clearAdmins()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @return void + */ + public function initAdmins() + { + $this->collAdmins = new ObjectCollection(); + $this->collAdmins->setModel('\Thelia\Model\Admin'); + } + + /** + * Gets a collection of ChildAdmin objects related by a many-to-many relationship + * to the current object by way of the admin_profile cross-reference table. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProfile is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object + * + * @return ObjectCollection|ChildAdmin[] List of ChildAdmin objects + */ + public function getAdmins($criteria = null, ConnectionInterface $con = null) + { + if (null === $this->collAdmins || null !== $criteria) { + if ($this->isNew() && null === $this->collAdmins) { + // return empty collection + $this->initAdmins(); + } else { + $collAdmins = ChildAdminQuery::create(null, $criteria) + ->filterByProfile($this) + ->find($con); + if (null !== $criteria) { + return $collAdmins; + } + $this->collAdmins = $collAdmins; + } + } + + return $this->collAdmins; + } + + /** + * Sets a collection of Admin objects related by a many-to-many relationship + * to the current object by way of the admin_profile cross-reference table. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $admins A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProfile The current object (for fluent API support) + */ + public function setAdmins(Collection $admins, ConnectionInterface $con = null) + { + $this->clearAdmins(); + $currentAdmins = $this->getAdmins(); + + $this->adminsScheduledForDeletion = $currentAdmins->diff($admins); + + foreach ($admins as $admin) { + if (!$currentAdmins->contains($admin)) { + $this->doAddAdmin($admin); + } + } + + $this->collAdmins = $admins; + + return $this; + } + + /** + * Gets the number of ChildAdmin objects related by a many-to-many relationship + * to the current object by way of the admin_profile cross-reference table. + * + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object + * + * @return int the number of related ChildAdmin objects + */ + public function countAdmins($criteria = null, $distinct = false, ConnectionInterface $con = null) + { + if (null === $this->collAdmins || null !== $criteria) { + if ($this->isNew() && null === $this->collAdmins) { + return 0; + } else { + $query = ChildAdminQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProfile($this) + ->count($con); + } + } else { + return count($this->collAdmins); + } + } + + /** + * Associate a ChildAdmin object to this object + * through the admin_profile cross reference table. + * + * @param ChildAdmin $admin The ChildAdminProfile object to relate + * @return ChildProfile The current object (for fluent API support) + */ + public function addAdmin(ChildAdmin $admin) + { + if ($this->collAdmins === null) { + $this->initAdmins(); + } + + if (!$this->collAdmins->contains($admin)) { // only add it if the **same** object is not already associated + $this->doAddAdmin($admin); + $this->collAdmins[] = $admin; + } + + return $this; + } + + /** + * @param Admin $admin The admin object to add. + */ + protected function doAddAdmin($admin) + { + $adminProfile = new ChildAdminProfile(); + $adminProfile->setAdmin($admin); + $this->addAdminProfile($adminProfile); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$admin->getProfiles()->contains($this)) { + $foreignCollection = $admin->getProfiles(); + $foreignCollection[] = $this; + } + } + + /** + * Remove a ChildAdmin object to this object + * through the admin_profile cross reference table. + * + * @param ChildAdmin $admin The ChildAdminProfile object to relate + * @return ChildProfile The current object (for fluent API support) + */ + public function removeAdmin(ChildAdmin $admin) + { + if ($this->getAdmins()->contains($admin)) { + $this->collAdmins->remove($this->collAdmins->search($admin)); + + if (null === $this->adminsScheduledForDeletion) { + $this->adminsScheduledForDeletion = clone $this->collAdmins; + $this->adminsScheduledForDeletion->clear(); + } + + $this->adminsScheduledForDeletion[] = $admin; + } + + return $this; + } + + /** + * Clears out the collResources collection + * + * This does not modify the database; however, it will remove any associated objects, causing + * them to be refetched by subsequent calls to accessor method. + * + * @return void + * @see addResources() + */ + public function clearResources() + { + $this->collResources = null; // important to set this to NULL since that means it is uninitialized + $this->collResourcesPartial = null; + } + + /** + * Initializes the collResources collection. + * + * By default this just sets the collResources collection to an empty collection (like clearResources()); + * however, you may wish to override this method in your stub class to provide setting appropriate + * to your application -- for example, setting the initial array to the values stored in database. + * + * @return void + */ + public function initResources() + { + $this->collResources = new ObjectCollection(); + $this->collResources->setModel('\Thelia\Model\Resource'); + } + + /** + * Gets a collection of ChildResource objects related by a many-to-many relationship + * to the current object by way of the profile_resource cross-reference table. + * + * If the $criteria is not null, it is used to always fetch the results from the database. + * Otherwise the results are fetched from the database the first time, then cached. + * Next time the same method is called without $criteria, the cached collection is returned. + * If this ChildProfile is new, it will return + * an empty collection or the current collection; the criteria is ignored on a new object. + * + * @param Criteria $criteria Optional query object to filter the query + * @param ConnectionInterface $con Optional connection object + * + * @return ObjectCollection|ChildResource[] List of ChildResource objects + */ + public function getResources($criteria = null, ConnectionInterface $con = null) + { + if (null === $this->collResources || null !== $criteria) { + if ($this->isNew() && null === $this->collResources) { + // return empty collection + $this->initResources(); + } else { + $collResources = ChildResourceQuery::create(null, $criteria) + ->filterByProfile($this) + ->find($con); + if (null !== $criteria) { + return $collResources; + } + $this->collResources = $collResources; + } + } + + return $this->collResources; + } + + /** + * Sets a collection of Resource objects related by a many-to-many relationship + * to the current object by way of the profile_resource cross-reference table. + * It will also schedule objects for deletion based on a diff between old objects (aka persisted) + * and new objects from the given Propel collection. + * + * @param Collection $resources A Propel collection. + * @param ConnectionInterface $con Optional connection object + * @return ChildProfile The current object (for fluent API support) + */ + public function setResources(Collection $resources, ConnectionInterface $con = null) + { + $this->clearResources(); + $currentResources = $this->getResources(); + + $this->resourcesScheduledForDeletion = $currentResources->diff($resources); + + foreach ($resources as $resource) { + if (!$currentResources->contains($resource)) { + $this->doAddResource($resource); + } + } + + $this->collResources = $resources; + + return $this; + } + + /** + * Gets the number of ChildResource objects related by a many-to-many relationship + * to the current object by way of the profile_resource cross-reference table. + * + * @param Criteria $criteria Optional query object to filter the query + * @param boolean $distinct Set to true to force count distinct + * @param ConnectionInterface $con Optional connection object + * + * @return int the number of related ChildResource objects + */ + public function countResources($criteria = null, $distinct = false, ConnectionInterface $con = null) + { + if (null === $this->collResources || null !== $criteria) { + if ($this->isNew() && null === $this->collResources) { + return 0; + } else { + $query = ChildResourceQuery::create(null, $criteria); + if ($distinct) { + $query->distinct(); + } + + return $query + ->filterByProfile($this) + ->count($con); + } + } else { + return count($this->collResources); + } + } + + /** + * Associate a ChildResource object to this object + * through the profile_resource cross reference table. + * + * @param ChildResource $resource The ChildProfileResource object to relate + * @return ChildProfile The current object (for fluent API support) + */ + public function addResource(ChildResource $resource) + { + if ($this->collResources === null) { + $this->initResources(); + } + + if (!$this->collResources->contains($resource)) { // only add it if the **same** object is not already associated + $this->doAddResource($resource); + $this->collResources[] = $resource; + } + + return $this; + } + + /** + * @param Resource $resource The resource object to add. + */ + protected function doAddResource($resource) + { + $profileResource = new ChildProfileResource(); + $profileResource->setResource($resource); + $this->addProfileResource($profileResource); + // set the back reference to this object directly as using provided method either results + // in endless loop or in multiple relations + if (!$resource->getProfiles()->contains($this)) { + $foreignCollection = $resource->getProfiles(); + $foreignCollection[] = $this; + } + } + + /** + * Remove a ChildResource object to this object + * through the profile_resource cross reference table. + * + * @param ChildResource $resource The ChildProfileResource object to relate + * @return ChildProfile The current object (for fluent API support) + */ + public function removeResource(ChildResource $resource) + { + if ($this->getResources()->contains($resource)) { + $this->collResources->remove($this->collResources->search($resource)); + + if (null === $this->resourcesScheduledForDeletion) { + $this->resourcesScheduledForDeletion = clone $this->collResources; + $this->resourcesScheduledForDeletion->clear(); + } + + $this->resourcesScheduledForDeletion[] = $resource; + } + + return $this; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->code = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + if ($this->collAdminProfiles) { + foreach ($this->collAdminProfiles as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collProfileResources) { + foreach ($this->collProfileResources as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collProfileModules) { + foreach ($this->collProfileModules as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collProfileI18ns) { + foreach ($this->collProfileI18ns as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collAdmins) { + foreach ($this->collAdmins as $o) { + $o->clearAllReferences($deep); + } + } + if ($this->collResources) { + foreach ($this->collResources as $o) { + $o->clearAllReferences($deep); + } + } + } // if ($deep) + + // i18n behavior + $this->currentLocale = 'en_US'; + $this->currentTranslations = null; + + if ($this->collAdminProfiles instanceof Collection) { + $this->collAdminProfiles->clearIterator(); + } + $this->collAdminProfiles = null; + if ($this->collProfileResources instanceof Collection) { + $this->collProfileResources->clearIterator(); + } + $this->collProfileResources = null; + if ($this->collProfileModules instanceof Collection) { + $this->collProfileModules->clearIterator(); + } + $this->collProfileModules = null; + if ($this->collProfileI18ns instanceof Collection) { + $this->collProfileI18ns->clearIterator(); + } + $this->collProfileI18ns = null; + if ($this->collAdmins instanceof Collection) { + $this->collAdmins->clearIterator(); + } + $this->collAdmins = null; + if ($this->collResources instanceof Collection) { + $this->collResources->clearIterator(); + } + $this->collResources = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProfileTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildProfile The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProfileTableMap::UPDATED_AT; + + return $this; + } + + // i18n behavior + + /** + * Sets the locale for translations + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * + * @return ChildProfile The current object (for fluent API support) + */ + public function setLocale($locale = 'en_US') + { + $this->currentLocale = $locale; + + return $this; + } + + /** + * Gets the locale for translations + * + * @return string $locale Locale to use for the translation, e.g. 'fr_FR' + */ + public function getLocale() + { + return $this->currentLocale; + } + + /** + * Returns the current translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProfileI18n */ + public function getTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!isset($this->currentTranslations[$locale])) { + if (null !== $this->collProfileI18ns) { + foreach ($this->collProfileI18ns as $translation) { + if ($translation->getLocale() == $locale) { + $this->currentTranslations[$locale] = $translation; + + return $translation; + } + } + } + if ($this->isNew()) { + $translation = new ChildProfileI18n(); + $translation->setLocale($locale); + } else { + $translation = ChildProfileI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->findOneOrCreate($con); + $this->currentTranslations[$locale] = $translation; + } + $this->addProfileI18n($translation); + } + + return $this->currentTranslations[$locale]; + } + + /** + * Remove the translation for a given locale + * + * @param string $locale Locale to use for the translation, e.g. 'fr_FR' + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProfile The current object (for fluent API support) + */ + public function removeTranslation($locale = 'en_US', ConnectionInterface $con = null) + { + if (!$this->isNew()) { + ChildProfileI18nQuery::create() + ->filterByPrimaryKey(array($this->getPrimaryKey(), $locale)) + ->delete($con); + } + if (isset($this->currentTranslations[$locale])) { + unset($this->currentTranslations[$locale]); + } + foreach ($this->collProfileI18ns as $key => $translation) { + if ($translation->getLocale() == $locale) { + unset($this->collProfileI18ns[$key]); + break; + } + } + + return $this; + } + + /** + * Returns the current translation + * + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProfileI18n */ + public function getCurrentTranslation(ConnectionInterface $con = null) + { + return $this->getTranslation($this->getLocale(), $con); + } + + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + return $this->getCurrentTranslation()->getTitle(); + } + + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setTitle($v) + { $this->getCurrentTranslation()->setTitle($v); + + return $this; + } + + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + return $this->getCurrentTranslation()->getDescription(); + } + + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setDescription($v) + { $this->getCurrentTranslation()->setDescription($v); + + return $this; + } + + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + return $this->getCurrentTranslation()->getChapo(); + } + + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setChapo($v) + { $this->getCurrentTranslation()->setChapo($v); + + return $this; + } + + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + return $this->getCurrentTranslation()->getPostscriptum(); + } + + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { $this->getCurrentTranslation()->setPostscriptum($v); + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProfileI18n.php b/core/lib/Thelia/Model/Base/ProfileI18n.php new file mode 100644 index 000000000..e9f026d6d --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProfileI18n.php @@ -0,0 +1,1442 @@ +locale = 'en_US'; + } + + /** + * Initializes internal state of Thelia\Model\Base\ProfileI18n object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProfileI18n instance. If + * obj is an instance of ProfileI18n, delegates to + * equals(ProfileI18n). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProfileI18n The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProfileI18n The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [locale] column value. + * + * @return string + */ + public function getLocale() + { + + return $this->locale; + } + + /** + * Get the [title] column value. + * + * @return string + */ + public function getTitle() + { + + return $this->title; + } + + /** + * Get the [description] column value. + * + * @return string + */ + public function getDescription() + { + + return $this->description; + } + + /** + * Get the [chapo] column value. + * + * @return string + */ + public function getChapo() + { + + return $this->chapo; + } + + /** + * Get the [postscriptum] column value. + * + * @return string + */ + public function getPostscriptum() + { + + return $this->postscriptum; + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProfileI18nTableMap::ID; + } + + if ($this->aProfile !== null && $this->aProfile->getId() !== $v) { + $this->aProfile = null; + } + + + return $this; + } // setId() + + /** + * Set the value of [locale] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setLocale($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->locale !== $v) { + $this->locale = $v; + $this->modifiedColumns[] = ProfileI18nTableMap::LOCALE; + } + + + return $this; + } // setLocale() + + /** + * Set the value of [title] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setTitle($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->title !== $v) { + $this->title = $v; + $this->modifiedColumns[] = ProfileI18nTableMap::TITLE; + } + + + return $this; + } // setTitle() + + /** + * Set the value of [description] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setDescription($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->description !== $v) { + $this->description = $v; + $this->modifiedColumns[] = ProfileI18nTableMap::DESCRIPTION; + } + + + return $this; + } // setDescription() + + /** + * Set the value of [chapo] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setChapo($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->chapo !== $v) { + $this->chapo = $v; + $this->modifiedColumns[] = ProfileI18nTableMap::CHAPO; + } + + + return $this; + } // setChapo() + + /** + * Set the value of [postscriptum] column. + * + * @param string $v new value + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + */ + public function setPostscriptum($v) + { + if ($v !== null) { + $v = (string) $v; + } + + if ($this->postscriptum !== $v) { + $this->postscriptum = $v; + $this->modifiedColumns[] = ProfileI18nTableMap::POSTSCRIPTUM; + } + + + return $this; + } // setPostscriptum() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->locale !== 'en_US') { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProfileI18nTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProfileI18nTableMap::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)]; + $this->locale = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProfileI18nTableMap::translateFieldName('Title', TableMap::TYPE_PHPNAME, $indexType)]; + $this->title = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileI18nTableMap::translateFieldName('Description', TableMap::TYPE_PHPNAME, $indexType)]; + $this->description = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProfileI18nTableMap::translateFieldName('Chapo', TableMap::TYPE_PHPNAME, $indexType)]; + $this->chapo = (null !== $col) ? (string) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProfileI18nTableMap::translateFieldName('Postscriptum', TableMap::TYPE_PHPNAME, $indexType)]; + $this->postscriptum = (null !== $col) ? (string) $col : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ProfileI18nTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProfileI18n object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProfile !== null && $this->id !== $this->aProfile->getId()) { + $this->aProfile = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileI18nTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProfileI18nQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProfile = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProfileI18n::setDeleted() + * @see ProfileI18n::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProfileI18nQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileI18nTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + } else { + $ret = $ret && $this->preUpdate($con); + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProfileI18nTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProfile !== null) { + if ($this->aProfile->isModified() || $this->aProfile->isNew()) { + $affectedRows += $this->aProfile->save($con); + } + $this->setProfile($this->aProfile); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProfileI18nTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProfileI18nTableMap::LOCALE)) { + $modifiedColumns[':p' . $index++] = 'LOCALE'; + } + if ($this->isColumnModified(ProfileI18nTableMap::TITLE)) { + $modifiedColumns[':p' . $index++] = 'TITLE'; + } + if ($this->isColumnModified(ProfileI18nTableMap::DESCRIPTION)) { + $modifiedColumns[':p' . $index++] = 'DESCRIPTION'; + } + if ($this->isColumnModified(ProfileI18nTableMap::CHAPO)) { + $modifiedColumns[':p' . $index++] = 'CHAPO'; + } + if ($this->isColumnModified(ProfileI18nTableMap::POSTSCRIPTUM)) { + $modifiedColumns[':p' . $index++] = 'POSTSCRIPTUM'; + } + + $sql = sprintf( + 'INSERT INTO profile_i18n (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'LOCALE': + $stmt->bindValue($identifier, $this->locale, PDO::PARAM_STR); + break; + case 'TITLE': + $stmt->bindValue($identifier, $this->title, PDO::PARAM_STR); + break; + case 'DESCRIPTION': + $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); + break; + case 'CHAPO': + $stmt->bindValue($identifier, $this->chapo, PDO::PARAM_STR); + break; + case 'POSTSCRIPTUM': + $stmt->bindValue($identifier, $this->postscriptum, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getLocale(); + break; + case 2: + return $this->getTitle(); + break; + case 3: + return $this->getDescription(); + break; + case 4: + return $this->getChapo(); + break; + case 5: + return $this->getPostscriptum(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProfileI18n'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProfileI18n'][serialize($this->getPrimaryKey())] = true; + $keys = ProfileI18nTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getLocale(), + $keys[2] => $this->getTitle(), + $keys[3] => $this->getDescription(), + $keys[4] => $this->getChapo(), + $keys[5] => $this->getPostscriptum(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProfile) { + $result['Profile'] = $this->aProfile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileI18nTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setLocale($value); + break; + case 2: + $this->setTitle($value); + break; + case 3: + $this->setDescription($value); + break; + case 4: + $this->setChapo($value); + break; + case 5: + $this->setPostscriptum($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProfileI18nTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setLocale($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setTitle($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setDescription($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setChapo($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setPostscriptum($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProfileI18nTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProfileI18nTableMap::ID)) $criteria->add(ProfileI18nTableMap::ID, $this->id); + if ($this->isColumnModified(ProfileI18nTableMap::LOCALE)) $criteria->add(ProfileI18nTableMap::LOCALE, $this->locale); + if ($this->isColumnModified(ProfileI18nTableMap::TITLE)) $criteria->add(ProfileI18nTableMap::TITLE, $this->title); + if ($this->isColumnModified(ProfileI18nTableMap::DESCRIPTION)) $criteria->add(ProfileI18nTableMap::DESCRIPTION, $this->description); + if ($this->isColumnModified(ProfileI18nTableMap::CHAPO)) $criteria->add(ProfileI18nTableMap::CHAPO, $this->chapo); + if ($this->isColumnModified(ProfileI18nTableMap::POSTSCRIPTUM)) $criteria->add(ProfileI18nTableMap::POSTSCRIPTUM, $this->postscriptum); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProfileI18nTableMap::DATABASE_NAME); + $criteria->add(ProfileI18nTableMap::ID, $this->id); + $criteria->add(ProfileI18nTableMap::LOCALE, $this->locale); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getLocale(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setLocale($keys[1]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getLocale()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ProfileI18n (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setId($this->getId()); + $copyObj->setLocale($this->getLocale()); + $copyObj->setTitle($this->getTitle()); + $copyObj->setDescription($this->getDescription()); + $copyObj->setChapo($this->getChapo()); + $copyObj->setPostscriptum($this->getPostscriptum()); + if ($makeNew) { + $copyObj->setNew(true); + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProfileI18n Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProfile object. + * + * @param ChildProfile $v + * @return \Thelia\Model\ProfileI18n The current object (for fluent API support) + * @throws PropelException + */ + public function setProfile(ChildProfile $v = null) + { + if ($v === null) { + $this->setId(NULL); + } else { + $this->setId($v->getId()); + } + + $this->aProfile = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProfile object, it will not be re-added. + if ($v !== null) { + $v->addProfileI18n($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProfile object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProfile The associated ChildProfile object. + * @throws PropelException + */ + public function getProfile(ConnectionInterface $con = null) + { + if ($this->aProfile === null && ($this->id !== null)) { + $this->aProfile = ChildProfileQuery::create()->findPk($this->id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProfile->addProfileI18ns($this); + */ + } + + return $this->aProfile; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->locale = null; + $this->title = null; + $this->description = null; + $this->chapo = null; + $this->postscriptum = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProfile = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProfileI18nTableMap::DEFAULT_STRING_FORMAT); + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProfileI18nQuery.php b/core/lib/Thelia/Model/Base/ProfileI18nQuery.php new file mode 100644 index 000000000..3c9367fb4 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProfileI18nQuery.php @@ -0,0 +1,607 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34), $con); + * + * + * @param array[$id, $locale] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProfileI18n|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProfileI18nTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileI18nTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfileI18n A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, LOCALE, TITLE, DESCRIPTION, CHAPO, POSTSCRIPTUM FROM profile_i18n WHERE ID = :p0 AND LOCALE = :p1'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_STR); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProfileI18n(); + $obj->hydrate($row); + ProfileI18nTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfileI18n|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(ProfileI18nTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProfileI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(ProfileI18nTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProfileI18nTableMap::LOCALE, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @see filterByProfile() + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProfileI18nTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProfileI18nTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileI18nTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the locale column + * + * Example usage: + * + * $query->filterByLocale('fooValue'); // WHERE locale = 'fooValue' + * $query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%' + * + * + * @param string $locale The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByLocale($locale = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($locale)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $locale)) { + $locale = str_replace('*', '%', $locale); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProfileI18nTableMap::LOCALE, $locale, $comparison); + } + + /** + * Filter the query on the title column + * + * Example usage: + * + * $query->filterByTitle('fooValue'); // WHERE title = 'fooValue' + * $query->filterByTitle('%fooValue%'); // WHERE title LIKE '%fooValue%' + * + * + * @param string $title The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByTitle($title = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($title)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $title)) { + $title = str_replace('*', '%', $title); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProfileI18nTableMap::TITLE, $title, $comparison); + } + + /** + * Filter the query on the description column + * + * Example usage: + * + * $query->filterByDescription('fooValue'); // WHERE description = 'fooValue' + * $query->filterByDescription('%fooValue%'); // WHERE description LIKE '%fooValue%' + * + * + * @param string $description The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByDescription($description = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($description)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $description)) { + $description = str_replace('*', '%', $description); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProfileI18nTableMap::DESCRIPTION, $description, $comparison); + } + + /** + * Filter the query on the chapo column + * + * Example usage: + * + * $query->filterByChapo('fooValue'); // WHERE chapo = 'fooValue' + * $query->filterByChapo('%fooValue%'); // WHERE chapo LIKE '%fooValue%' + * + * + * @param string $chapo The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByChapo($chapo = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($chapo)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $chapo)) { + $chapo = str_replace('*', '%', $chapo); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProfileI18nTableMap::CHAPO, $chapo, $comparison); + } + + /** + * Filter the query on the postscriptum column + * + * Example usage: + * + * $query->filterByPostscriptum('fooValue'); // WHERE postscriptum = 'fooValue' + * $query->filterByPostscriptum('%fooValue%'); // WHERE postscriptum LIKE '%fooValue%' + * + * + * @param string $postscriptum The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByPostscriptum($postscriptum = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($postscriptum)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $postscriptum)) { + $postscriptum = str_replace('*', '%', $postscriptum); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProfileI18nTableMap::POSTSCRIPTUM, $postscriptum, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Profile object + * + * @param \Thelia\Model\Profile|ObjectCollection $profile The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function filterByProfile($profile, $comparison = null) + { + if ($profile instanceof \Thelia\Model\Profile) { + return $this + ->addUsingAlias(ProfileI18nTableMap::ID, $profile->getId(), $comparison); + } elseif ($profile instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProfileI18nTableMap::ID, $profile->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProfile() only accepts arguments of type \Thelia\Model\Profile or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Profile relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function joinProfile($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Profile'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Profile'); + } + + return $this; + } + + /** + * Use the Profile relation Profile object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProfileQuery A secondary query class using the current class as primary query + */ + public function useProfileQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinProfile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Profile', '\Thelia\Model\ProfileQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProfileI18n $profileI18n Object to remove from the list of results + * + * @return ChildProfileI18nQuery The current query, for fluid interface + */ + public function prune($profileI18n = null) + { + if ($profileI18n) { + $this->addCond('pruneCond0', $this->getAliasedColName(ProfileI18nTableMap::ID), $profileI18n->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProfileI18nTableMap::LOCALE), $profileI18n->getLocale(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the profile_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileI18nTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProfileI18nTableMap::clearInstancePool(); + ProfileI18nTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProfileI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProfileI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileI18nTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProfileI18nTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProfileI18nTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProfileI18nTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + +} // ProfileI18nQuery diff --git a/core/lib/Thelia/Model/Base/ProfileModule.php b/core/lib/Thelia/Model/Base/ProfileModule.php new file mode 100644 index 000000000..acd54b534 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProfileModule.php @@ -0,0 +1,1575 @@ +access = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\ProfileModule object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProfileModule instance. If + * obj is an instance of ProfileModule, delegates to + * equals(ProfileModule). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProfileModule The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProfileModule The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [profile_id] column value. + * + * @return int + */ + public function getProfileId() + { + + return $this->profile_id; + } + + /** + * Get the [module_id] column value. + * + * @return int + */ + public function getModuleId() + { + + return $this->module_id; + } + + /** + * Get the [access] column value. + * + * @return int + */ + public function getAccess() + { + + return $this->access; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProfileModuleTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [profile_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + */ + public function setProfileId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->profile_id !== $v) { + $this->profile_id = $v; + $this->modifiedColumns[] = ProfileModuleTableMap::PROFILE_ID; + } + + if ($this->aProfile !== null && $this->aProfile->getId() !== $v) { + $this->aProfile = null; + } + + + return $this; + } // setProfileId() + + /** + * Set the value of [module_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + */ + public function setModuleId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->module_id !== $v) { + $this->module_id = $v; + $this->modifiedColumns[] = ProfileModuleTableMap::MODULE_ID; + } + + if ($this->aModule !== null && $this->aModule->getId() !== $v) { + $this->aModule = null; + } + + + return $this; + } // setModuleId() + + /** + * Set the value of [access] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + */ + public function setAccess($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->access !== $v) { + $this->access = $v; + $this->modifiedColumns[] = ProfileModuleTableMap::ACCESS; + } + + + return $this; + } // setAccess() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProfileModuleTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProfileModuleTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->access !== 0) { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProfileModuleTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProfileModuleTableMap::translateFieldName('ProfileId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->profile_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProfileModuleTableMap::translateFieldName('ModuleId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->module_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileModuleTableMap::translateFieldName('Access', TableMap::TYPE_PHPNAME, $indexType)]; + $this->access = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProfileModuleTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProfileModuleTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 6; // 6 = ProfileModuleTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProfileModule object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProfile !== null && $this->profile_id !== $this->aProfile->getId()) { + $this->aProfile = null; + } + if ($this->aModule !== null && $this->module_id !== $this->aModule->getId()) { + $this->aModule = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileModuleTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProfileModuleQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProfile = null; + $this->aModule = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProfileModule::setDeleted() + * @see ProfileModule::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileModuleTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProfileModuleQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileModuleTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProfileModuleTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProfileModuleTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProfileModuleTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProfileModuleTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProfile !== null) { + if ($this->aProfile->isModified() || $this->aProfile->isNew()) { + $affectedRows += $this->aProfile->save($con); + } + $this->setProfile($this->aProfile); + } + + if ($this->aModule !== null) { + if ($this->aModule->isModified() || $this->aModule->isNew()) { + $affectedRows += $this->aModule->save($con); + } + $this->setModule($this->aModule); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ProfileModuleTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProfileModuleTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProfileModuleTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProfileModuleTableMap::PROFILE_ID)) { + $modifiedColumns[':p' . $index++] = 'PROFILE_ID'; + } + if ($this->isColumnModified(ProfileModuleTableMap::MODULE_ID)) { + $modifiedColumns[':p' . $index++] = 'MODULE_ID'; + } + if ($this->isColumnModified(ProfileModuleTableMap::ACCESS)) { + $modifiedColumns[':p' . $index++] = 'ACCESS'; + } + if ($this->isColumnModified(ProfileModuleTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ProfileModuleTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO profile_module (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'PROFILE_ID': + $stmt->bindValue($identifier, $this->profile_id, PDO::PARAM_INT); + break; + case 'MODULE_ID': + $stmt->bindValue($identifier, $this->module_id, PDO::PARAM_INT); + break; + case 'ACCESS': + $stmt->bindValue($identifier, $this->access, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getProfileId(); + break; + case 2: + return $this->getModuleId(); + break; + case 3: + return $this->getAccess(); + break; + case 4: + return $this->getCreatedAt(); + break; + case 5: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProfileModule'][$this->getPrimaryKey()])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProfileModule'][$this->getPrimaryKey()] = true; + $keys = ProfileModuleTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getProfileId(), + $keys[2] => $this->getModuleId(), + $keys[3] => $this->getAccess(), + $keys[4] => $this->getCreatedAt(), + $keys[5] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProfile) { + $result['Profile'] = $this->aProfile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aModule) { + $result['Module'] = $this->aModule->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileModuleTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setProfileId($value); + break; + case 2: + $this->setModuleId($value); + break; + case 3: + $this->setAccess($value); + break; + case 4: + $this->setCreatedAt($value); + break; + case 5: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProfileModuleTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setProfileId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setModuleId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setAccess($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setCreatedAt($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setUpdatedAt($arr[$keys[5]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProfileModuleTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProfileModuleTableMap::ID)) $criteria->add(ProfileModuleTableMap::ID, $this->id); + if ($this->isColumnModified(ProfileModuleTableMap::PROFILE_ID)) $criteria->add(ProfileModuleTableMap::PROFILE_ID, $this->profile_id); + if ($this->isColumnModified(ProfileModuleTableMap::MODULE_ID)) $criteria->add(ProfileModuleTableMap::MODULE_ID, $this->module_id); + if ($this->isColumnModified(ProfileModuleTableMap::ACCESS)) $criteria->add(ProfileModuleTableMap::ACCESS, $this->access); + if ($this->isColumnModified(ProfileModuleTableMap::CREATED_AT)) $criteria->add(ProfileModuleTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProfileModuleTableMap::UPDATED_AT)) $criteria->add(ProfileModuleTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProfileModuleTableMap::DATABASE_NAME); + $criteria->add(ProfileModuleTableMap::ID, $this->id); + + return $criteria; + } + + /** + * Returns the primary key for this object (row). + * @return int + */ + public function getPrimaryKey() + { + return $this->getId(); + } + + /** + * Generic method to set the primary key (id column). + * + * @param int $key Primary key. + * @return void + */ + public function setPrimaryKey($key) + { + $this->setId($key); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return null === $this->getId(); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ProfileModule (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setProfileId($this->getProfileId()); + $copyObj->setModuleId($this->getModuleId()); + $copyObj->setAccess($this->getAccess()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProfileModule Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProfile object. + * + * @param ChildProfile $v + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + * @throws PropelException + */ + public function setProfile(ChildProfile $v = null) + { + if ($v === null) { + $this->setProfileId(NULL); + } else { + $this->setProfileId($v->getId()); + } + + $this->aProfile = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProfile object, it will not be re-added. + if ($v !== null) { + $v->addProfileModule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProfile object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProfile The associated ChildProfile object. + * @throws PropelException + */ + public function getProfile(ConnectionInterface $con = null) + { + if ($this->aProfile === null && ($this->profile_id !== null)) { + $this->aProfile = ChildProfileQuery::create()->findPk($this->profile_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProfile->addProfileModules($this); + */ + } + + return $this->aProfile; + } + + /** + * Declares an association between this object and a ChildModule object. + * + * @param ChildModule $v + * @return \Thelia\Model\ProfileModule The current object (for fluent API support) + * @throws PropelException + */ + public function setModule(ChildModule $v = null) + { + if ($v === null) { + $this->setModuleId(NULL); + } else { + $this->setModuleId($v->getId()); + } + + $this->aModule = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildModule object, it will not be re-added. + if ($v !== null) { + $v->addProfileModule($this); + } + + + return $this; + } + + + /** + * Get the associated ChildModule object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildModule The associated ChildModule object. + * @throws PropelException + */ + public function getModule(ConnectionInterface $con = null) + { + if ($this->aModule === null && ($this->module_id !== null)) { + $this->aModule = ChildModuleQuery::create()->findPk($this->module_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aModule->addProfileModules($this); + */ + } + + return $this->aModule; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->profile_id = null; + $this->module_id = null; + $this->access = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProfile = null; + $this->aModule = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProfileModuleTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildProfileModule The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProfileModuleTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProfileModuleQuery.php b/core/lib/Thelia/Model/Base/ProfileModuleQuery.php new file mode 100644 index 000000000..f375b969b --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProfileModuleQuery.php @@ -0,0 +1,804 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProfileModule|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProfileModuleTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileModuleTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfileModule A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PROFILE_ID, MODULE_ID, ACCESS, CREATED_AT, UPDATED_AT FROM profile_module WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProfileModule(); + $obj->hydrate($row); + ProfileModuleTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfileModule|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ProfileModuleTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ProfileModuleTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProfileModuleTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProfileModuleTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileModuleTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the profile_id column + * + * Example usage: + * + * $query->filterByProfileId(1234); // WHERE profile_id = 1234 + * $query->filterByProfileId(array(12, 34)); // WHERE profile_id IN (12, 34) + * $query->filterByProfileId(array('min' => 12)); // WHERE profile_id > 12 + * + * + * @see filterByProfile() + * + * @param mixed $profileId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByProfileId($profileId = null, $comparison = null) + { + if (is_array($profileId)) { + $useMinMax = false; + if (isset($profileId['min'])) { + $this->addUsingAlias(ProfileModuleTableMap::PROFILE_ID, $profileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($profileId['max'])) { + $this->addUsingAlias(ProfileModuleTableMap::PROFILE_ID, $profileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileModuleTableMap::PROFILE_ID, $profileId, $comparison); + } + + /** + * Filter the query on the module_id column + * + * Example usage: + * + * $query->filterByModuleId(1234); // WHERE module_id = 1234 + * $query->filterByModuleId(array(12, 34)); // WHERE module_id IN (12, 34) + * $query->filterByModuleId(array('min' => 12)); // WHERE module_id > 12 + * + * + * @see filterByModule() + * + * @param mixed $moduleId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByModuleId($moduleId = null, $comparison = null) + { + if (is_array($moduleId)) { + $useMinMax = false; + if (isset($moduleId['min'])) { + $this->addUsingAlias(ProfileModuleTableMap::MODULE_ID, $moduleId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($moduleId['max'])) { + $this->addUsingAlias(ProfileModuleTableMap::MODULE_ID, $moduleId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileModuleTableMap::MODULE_ID, $moduleId, $comparison); + } + + /** + * Filter the query on the access column + * + * Example usage: + * + * $query->filterByAccess(1234); // WHERE access = 1234 + * $query->filterByAccess(array(12, 34)); // WHERE access IN (12, 34) + * $query->filterByAccess(array('min' => 12)); // WHERE access > 12 + * + * + * @param mixed $access The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByAccess($access = null, $comparison = null) + { + if (is_array($access)) { + $useMinMax = false; + if (isset($access['min'])) { + $this->addUsingAlias(ProfileModuleTableMap::ACCESS, $access['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($access['max'])) { + $this->addUsingAlias(ProfileModuleTableMap::ACCESS, $access['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileModuleTableMap::ACCESS, $access, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProfileModuleTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProfileModuleTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileModuleTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProfileModuleTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProfileModuleTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileModuleTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Profile object + * + * @param \Thelia\Model\Profile|ObjectCollection $profile The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByProfile($profile, $comparison = null) + { + if ($profile instanceof \Thelia\Model\Profile) { + return $this + ->addUsingAlias(ProfileModuleTableMap::PROFILE_ID, $profile->getId(), $comparison); + } elseif ($profile instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProfileModuleTableMap::PROFILE_ID, $profile->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProfile() only accepts arguments of type \Thelia\Model\Profile or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Profile relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function joinProfile($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Profile'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Profile'); + } + + return $this; + } + + /** + * Use the Profile relation Profile object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProfileQuery A secondary query class using the current class as primary query + */ + public function useProfileQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProfile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Profile', '\Thelia\Model\ProfileQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Module object + * + * @param \Thelia\Model\Module|ObjectCollection $module The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function filterByModule($module, $comparison = null) + { + if ($module instanceof \Thelia\Model\Module) { + return $this + ->addUsingAlias(ProfileModuleTableMap::MODULE_ID, $module->getId(), $comparison); + } elseif ($module instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProfileModuleTableMap::MODULE_ID, $module->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByModule() only accepts arguments of type \Thelia\Model\Module or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Module relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function joinModule($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Module'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Module'); + } + + return $this; + } + + /** + * Use the Module relation Module object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ModuleQuery A secondary query class using the current class as primary query + */ + public function useModuleQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Module', '\Thelia\Model\ModuleQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProfileModule $profileModule Object to remove from the list of results + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function prune($profileModule = null) + { + if ($profileModule) { + $this->addUsingAlias(ProfileModuleTableMap::ID, $profileModule->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the profile_module table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileModuleTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProfileModuleTableMap::clearInstancePool(); + ProfileModuleTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProfileModule or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProfileModule object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileModuleTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProfileModuleTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProfileModuleTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProfileModuleTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProfileModuleTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProfileModuleTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProfileModuleTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProfileModuleTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProfileModuleTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildProfileModuleQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProfileModuleTableMap::CREATED_AT); + } + +} // ProfileModuleQuery diff --git a/core/lib/Thelia/Model/Base/ProfileQuery.php b/core/lib/Thelia/Model/Base/ProfileQuery.php new file mode 100644 index 000000000..6f9995b71 --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProfileQuery.php @@ -0,0 +1,940 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(12, $con); + * + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProfile|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProfileTableMap::getInstanceFromPool((string) $key))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfile A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, CODE, CREATED_AT, UPDATED_AT FROM profile WHERE ID = :p0'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key, PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProfile(); + $obj->hydrate($row); + ProfileTableMap::addInstanceToPool($obj, (string) $key); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfile|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(12, 56, 832), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + + return $this->addUsingAlias(ProfileTableMap::ID, $key, Criteria::EQUAL); + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + + return $this->addUsingAlias(ProfileTableMap::ID, $keys, Criteria::IN); + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProfileTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProfileTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the code column + * + * Example usage: + * + * $query->filterByCode('fooValue'); // WHERE code = 'fooValue' + * $query->filterByCode('%fooValue%'); // WHERE code LIKE '%fooValue%' + * + * + * @param string $code The value to use as filter. + * Accepts wildcards (* and % trigger a LIKE) + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByCode($code = null, $comparison = null) + { + if (null === $comparison) { + if (is_array($code)) { + $comparison = Criteria::IN; + } elseif (preg_match('/[\%\*]/', $code)) { + $code = str_replace('*', '%', $code); + $comparison = Criteria::LIKE; + } + } + + return $this->addUsingAlias(ProfileTableMap::CODE, $code, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProfileTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProfileTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProfileTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProfileTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\AdminProfile object + * + * @param \Thelia\Model\AdminProfile|ObjectCollection $adminProfile the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByAdminProfile($adminProfile, $comparison = null) + { + if ($adminProfile instanceof \Thelia\Model\AdminProfile) { + return $this + ->addUsingAlias(ProfileTableMap::ID, $adminProfile->getProfileId(), $comparison); + } elseif ($adminProfile instanceof ObjectCollection) { + return $this + ->useAdminProfileQuery() + ->filterByPrimaryKeys($adminProfile->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByAdminProfile() only accepts arguments of type \Thelia\Model\AdminProfile or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the AdminProfile relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function joinAdminProfile($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('AdminProfile'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'AdminProfile'); + } + + return $this; + } + + /** + * Use the AdminProfile relation AdminProfile object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\AdminProfileQuery A secondary query class using the current class as primary query + */ + public function useAdminProfileQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinAdminProfile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'AdminProfile', '\Thelia\Model\AdminProfileQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ProfileResource object + * + * @param \Thelia\Model\ProfileResource|ObjectCollection $profileResource the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByProfileResource($profileResource, $comparison = null) + { + if ($profileResource instanceof \Thelia\Model\ProfileResource) { + return $this + ->addUsingAlias(ProfileTableMap::ID, $profileResource->getProfileId(), $comparison); + } elseif ($profileResource instanceof ObjectCollection) { + return $this + ->useProfileResourceQuery() + ->filterByPrimaryKeys($profileResource->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProfileResource() only accepts arguments of type \Thelia\Model\ProfileResource or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProfileResource relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function joinProfileResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProfileResource'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProfileResource'); + } + + return $this; + } + + /** + * Use the ProfileResource relation ProfileResource object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProfileResourceQuery A secondary query class using the current class as primary query + */ + public function useProfileResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProfileResource($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProfileResource', '\Thelia\Model\ProfileResourceQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ProfileModule object + * + * @param \Thelia\Model\ProfileModule|ObjectCollection $profileModule the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByProfileModule($profileModule, $comparison = null) + { + if ($profileModule instanceof \Thelia\Model\ProfileModule) { + return $this + ->addUsingAlias(ProfileTableMap::ID, $profileModule->getProfileId(), $comparison); + } elseif ($profileModule instanceof ObjectCollection) { + return $this + ->useProfileModuleQuery() + ->filterByPrimaryKeys($profileModule->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProfileModule() only accepts arguments of type \Thelia\Model\ProfileModule or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProfileModule relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function joinProfileModule($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProfileModule'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProfileModule'); + } + + return $this; + } + + /** + * Use the ProfileModule relation ProfileModule object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProfileModuleQuery A secondary query class using the current class as primary query + */ + public function useProfileModuleQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProfileModule($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProfileModule', '\Thelia\Model\ProfileModuleQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\ProfileI18n object + * + * @param \Thelia\Model\ProfileI18n|ObjectCollection $profileI18n the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByProfileI18n($profileI18n, $comparison = null) + { + if ($profileI18n instanceof \Thelia\Model\ProfileI18n) { + return $this + ->addUsingAlias(ProfileTableMap::ID, $profileI18n->getId(), $comparison); + } elseif ($profileI18n instanceof ObjectCollection) { + return $this + ->useProfileI18nQuery() + ->filterByPrimaryKeys($profileI18n->getPrimaryKeys()) + ->endUse(); + } else { + throw new PropelException('filterByProfileI18n() only accepts arguments of type \Thelia\Model\ProfileI18n or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the ProfileI18n relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function joinProfileI18n($relationAlias = null, $joinType = 'LEFT JOIN') + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('ProfileI18n'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'ProfileI18n'); + } + + return $this; + } + + /** + * Use the ProfileI18n relation ProfileI18n object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProfileI18nQuery A secondary query class using the current class as primary query + */ + public function useProfileI18nQuery($relationAlias = null, $joinType = 'LEFT JOIN') + { + return $this + ->joinProfileI18n($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProfileI18n', '\Thelia\Model\ProfileI18nQuery'); + } + + /** + * Filter the query by a related Admin object + * using the admin_profile table as cross reference + * + * @param Admin $admin the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByAdmin($admin, $comparison = Criteria::EQUAL) + { + return $this + ->useAdminProfileQuery() + ->filterByAdmin($admin, $comparison) + ->endUse(); + } + + /** + * Filter the query by a related Resource object + * using the profile_resource table as cross reference + * + * @param Resource $resource the related object to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function filterByResource($resource, $comparison = Criteria::EQUAL) + { + return $this + ->useProfileResourceQuery() + ->filterByResource($resource, $comparison) + ->endUse(); + } + + /** + * Exclude object from result + * + * @param ChildProfile $profile Object to remove from the list of results + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function prune($profile = null) + { + if ($profile) { + $this->addUsingAlias(ProfileTableMap::ID, $profile->getId(), Criteria::NOT_EQUAL); + } + + return $this; + } + + /** + * Deletes all rows from the profile table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProfileTableMap::clearInstancePool(); + ProfileTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProfile or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProfile object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProfileTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProfileTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProfileTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProfileTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProfileTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProfileTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProfileTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProfileTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProfileTableMap::CREATED_AT); + } + + // i18n behavior + + /** + * Adds a JOIN clause to the query using the i18n relation + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function joinI18n($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + $relationName = $relationAlias ? $relationAlias : 'ProfileI18n'; + + return $this + ->joinProfileI18n($relationAlias, $joinType) + ->addJoinCondition($relationName, $relationName . '.Locale = ?', $locale); + } + + /** + * Adds a JOIN clause to the query and hydrates the related I18n object. + * Shortcut for $c->joinI18n($locale)->with() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProfileQuery The current query, for fluid interface + */ + public function joinWithI18n($locale = 'en_US', $joinType = Criteria::LEFT_JOIN) + { + $this + ->joinI18n($locale, null, $joinType) + ->with('ProfileI18n'); + $this->with['ProfileI18n']->setIsWithOneToMany(false); + + return $this; + } + + /** + * Use the I18n relation query object + * + * @see useQuery() + * + * @param string $locale Locale to use for the join condition, e.g. 'fr_FR' + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'. Defaults to left join. + * + * @return ChildProfileI18nQuery A secondary query class using the current class as primary query + */ + public function useI18nQuery($locale = 'en_US', $relationAlias = null, $joinType = Criteria::LEFT_JOIN) + { + return $this + ->joinI18n($locale, $relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'ProfileI18n', '\Thelia\Model\ProfileI18nQuery'); + } + +} // ProfileQuery diff --git a/core/lib/Thelia/Model/Base/ProfileResource.php b/core/lib/Thelia/Model/Base/ProfileResource.php new file mode 100644 index 000000000..9f3d246fc --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProfileResource.php @@ -0,0 +1,1649 @@ +read = 0; + $this->write = 0; + } + + /** + * Initializes internal state of Thelia\Model\Base\ProfileResource object. + * @see applyDefaults() + */ + public function __construct() + { + $this->applyDefaultValues(); + } + + /** + * Returns whether the object has been modified. + * + * @return boolean True if the object has been modified. + */ + public function isModified() + { + return !empty($this->modifiedColumns); + } + + /** + * Has specified column been modified? + * + * @param string $col column fully qualified name (TableMap::TYPE_COLNAME), e.g. Book::AUTHOR_ID + * @return boolean True if $col has been modified. + */ + public function isColumnModified($col) + { + return in_array($col, $this->modifiedColumns); + } + + /** + * Get the columns that have been modified in this object. + * @return array A unique list of the modified column names for this object. + */ + public function getModifiedColumns() + { + return array_unique($this->modifiedColumns); + } + + /** + * Returns whether the object has ever been saved. This will + * be false, if the object was retrieved from storage or was created + * and then saved. + * + * @return boolean true, if the object has never been persisted. + */ + public function isNew() + { + return $this->new; + } + + /** + * Setter for the isNew attribute. This method will be called + * by Propel-generated children and objects. + * + * @param boolean $b the state of the object. + */ + public function setNew($b) + { + $this->new = (Boolean) $b; + } + + /** + * Whether this object has been deleted. + * @return boolean The deleted state of this object. + */ + public function isDeleted() + { + return $this->deleted; + } + + /** + * Specify whether this object has been deleted. + * @param boolean $b The deleted state of this object. + * @return void + */ + public function setDeleted($b) + { + $this->deleted = (Boolean) $b; + } + + /** + * Sets the modified state for the object to be false. + * @param string $col If supplied, only the specified column is reset. + * @return void + */ + public function resetModified($col = null) + { + if (null !== $col) { + while (false !== ($offset = array_search($col, $this->modifiedColumns))) { + array_splice($this->modifiedColumns, $offset, 1); + } + } else { + $this->modifiedColumns = array(); + } + } + + /** + * Compares this with another ProfileResource instance. If + * obj is an instance of ProfileResource, delegates to + * equals(ProfileResource). Otherwise, returns false. + * + * @param mixed $obj The object to compare to. + * @return boolean Whether equal to the object specified. + */ + public function equals($obj) + { + $thisclazz = get_class($this); + if (!is_object($obj) || !($obj instanceof $thisclazz)) { + return false; + } + + if ($this === $obj) { + return true; + } + + if (null === $this->getPrimaryKey() + || null === $obj->getPrimaryKey()) { + return false; + } + + return $this->getPrimaryKey() === $obj->getPrimaryKey(); + } + + /** + * If the primary key is not null, return the hashcode of the + * primary key. Otherwise, return the hash code of the object. + * + * @return int Hashcode + */ + public function hashCode() + { + if (null !== $this->getPrimaryKey()) { + return crc32(serialize($this->getPrimaryKey())); + } + + return crc32(serialize(clone $this)); + } + + /** + * Get the associative array of the virtual columns in this object + * + * @return array + */ + public function getVirtualColumns() + { + return $this->virtualColumns; + } + + /** + * Checks the existence of a virtual column in this object + * + * @param string $name The virtual column name + * @return boolean + */ + public function hasVirtualColumn($name) + { + return array_key_exists($name, $this->virtualColumns); + } + + /** + * Get the value of a virtual column in this object + * + * @param string $name The virtual column name + * @return mixed + * + * @throws PropelException + */ + public function getVirtualColumn($name) + { + if (!$this->hasVirtualColumn($name)) { + throw new PropelException(sprintf('Cannot get value of inexistent virtual column %s.', $name)); + } + + return $this->virtualColumns[$name]; + } + + /** + * Set the value of a virtual column in this object + * + * @param string $name The virtual column name + * @param mixed $value The value to give to the virtual column + * + * @return ProfileResource The current object, for fluid interface + */ + public function setVirtualColumn($name, $value) + { + $this->virtualColumns[$name] = $value; + + return $this; + } + + /** + * Logs a message using Propel::log(). + * + * @param string $msg + * @param int $priority One of the Propel::LOG_* logging levels + * @return boolean + */ + protected function log($msg, $priority = Propel::LOG_INFO) + { + return Propel::log(get_class($this) . ': ' . $msg, $priority); + } + + /** + * Populate the current object from a string, using a given parser format + * + * $book = new Book(); + * $book->importFrom('JSON', '{"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, + * or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param string $data The source data to import from + * + * @return ProfileResource The current object, for fluid interface + */ + public function importFrom($parser, $data) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + $this->fromArray($parser->toArray($data), TableMap::TYPE_PHPNAME); + + return $this; + } + + /** + * Export the current object properties to a string, using a given parser format + * + * $book = BookQuery::create()->findPk(9012); + * echo $book->exportTo('JSON'); + * => {"Id":9012,"Title":"Don Juan","ISBN":"0140422161","Price":12.99,"PublisherId":1234,"AuthorId":5678}'); + * + * + * @param mixed $parser A AbstractParser instance, or a format name ('XML', 'YAML', 'JSON', 'CSV') + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy load(ed) columns. Defaults to TRUE. + * @return string The exported data + */ + public function exportTo($parser, $includeLazyLoadColumns = true) + { + if (!$parser instanceof AbstractParser) { + $parser = AbstractParser::getParser($parser); + } + + return $parser->fromArray($this->toArray(TableMap::TYPE_PHPNAME, $includeLazyLoadColumns, array(), true)); + } + + /** + * Clean up internal collections prior to serializing + * Avoids recursive loops that turn into segmentation faults when serializing + */ + public function __sleep() + { + $this->clearAllReferences(); + + return array_keys(get_object_vars($this)); + } + + /** + * Get the [id] column value. + * + * @return int + */ + public function getId() + { + + return $this->id; + } + + /** + * Get the [profile_id] column value. + * + * @return int + */ + public function getProfileId() + { + + return $this->profile_id; + } + + /** + * Get the [resource_id] column value. + * + * @return int + */ + public function getResourceId() + { + + return $this->resource_id; + } + + /** + * Get the [read] column value. + * + * @return int + */ + public function getRead() + { + + return $this->read; + } + + /** + * Get the [write] column value. + * + * @return int + */ + public function getWrite() + { + + return $this->write; + } + + /** + * Get the [optionally formatted] temporal [created_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getCreatedAt($format = NULL) + { + if ($format === null) { + return $this->created_at; + } else { + return $this->created_at instanceof \DateTime ? $this->created_at->format($format) : null; + } + } + + /** + * Get the [optionally formatted] temporal [updated_at] column value. + * + * + * @param string $format The date/time format string (either date()-style or strftime()-style). + * If format is NULL, then the raw \DateTime object will be returned. + * + * @return mixed Formatted date/time value as string or \DateTime object (if format is NULL), NULL if column is NULL, and 0 if column value is 0000-00-00 00:00:00 + * + * @throws PropelException - if unable to parse/validate the date/time value. + */ + public function getUpdatedAt($format = NULL) + { + if ($format === null) { + return $this->updated_at; + } else { + return $this->updated_at instanceof \DateTime ? $this->updated_at->format($format) : null; + } + } + + /** + * Set the value of [id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + */ + public function setId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->id !== $v) { + $this->id = $v; + $this->modifiedColumns[] = ProfileResourceTableMap::ID; + } + + + return $this; + } // setId() + + /** + * Set the value of [profile_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + */ + public function setProfileId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->profile_id !== $v) { + $this->profile_id = $v; + $this->modifiedColumns[] = ProfileResourceTableMap::PROFILE_ID; + } + + if ($this->aProfile !== null && $this->aProfile->getId() !== $v) { + $this->aProfile = null; + } + + + return $this; + } // setProfileId() + + /** + * Set the value of [resource_id] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + */ + public function setResourceId($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->resource_id !== $v) { + $this->resource_id = $v; + $this->modifiedColumns[] = ProfileResourceTableMap::RESOURCE_ID; + } + + if ($this->aResource !== null && $this->aResource->getId() !== $v) { + $this->aResource = null; + } + + + return $this; + } // setResourceId() + + /** + * Set the value of [read] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + */ + public function setRead($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->read !== $v) { + $this->read = $v; + $this->modifiedColumns[] = ProfileResourceTableMap::READ; + } + + + return $this; + } // setRead() + + /** + * Set the value of [write] column. + * + * @param int $v new value + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + */ + public function setWrite($v) + { + if ($v !== null) { + $v = (int) $v; + } + + if ($this->write !== $v) { + $this->write = $v; + $this->modifiedColumns[] = ProfileResourceTableMap::WRITE; + } + + + return $this; + } // setWrite() + + /** + * Sets the value of [created_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + */ + public function setCreatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->created_at !== null || $dt !== null) { + if ($dt !== $this->created_at) { + $this->created_at = $dt; + $this->modifiedColumns[] = ProfileResourceTableMap::CREATED_AT; + } + } // if either are not null + + + return $this; + } // setCreatedAt() + + /** + * Sets the value of [updated_at] column to a normalized version of the date/time value specified. + * + * @param mixed $v string, integer (timestamp), or \DateTime value. + * Empty strings are treated as NULL. + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + */ + public function setUpdatedAt($v) + { + $dt = PropelDateTime::newInstance($v, null, '\DateTime'); + if ($this->updated_at !== null || $dt !== null) { + if ($dt !== $this->updated_at) { + $this->updated_at = $dt; + $this->modifiedColumns[] = ProfileResourceTableMap::UPDATED_AT; + } + } // if either are not null + + + return $this; + } // setUpdatedAt() + + /** + * Indicates whether the columns in this object are only set to default values. + * + * This method can be used in conjunction with isModified() to indicate whether an object is both + * modified _and_ has some values set which are non-default. + * + * @return boolean Whether the columns in this object are only been set with default values. + */ + public function hasOnlyDefaultValues() + { + if ($this->read !== 0) { + return false; + } + + if ($this->write !== 0) { + return false; + } + + // otherwise, everything was equal, so return TRUE + return true; + } // hasOnlyDefaultValues() + + /** + * Hydrates (populates) the object variables with values from the database resultset. + * + * An offset (0-based "start column") is specified so that objects can be hydrated + * with a subset of the columns in the resultset rows. This is needed, for example, + * for results of JOIN queries where the resultset row includes columns from two or + * more tables. + * + * @param array $row The row returned by DataFetcher->fetch(). + * @param int $startcol 0-based offset column which indicates which restultset column to start with. + * @param boolean $rehydrate Whether this object is being re-hydrated from the database. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @return int next starting column + * @throws PropelException - Any caught Exception will be rewrapped as a PropelException. + */ + public function hydrate($row, $startcol = 0, $rehydrate = false, $indexType = TableMap::TYPE_NUM) + { + try { + + + $col = $row[TableMap::TYPE_NUM == $indexType ? 0 + $startcol : ProfileResourceTableMap::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + $this->id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 1 + $startcol : ProfileResourceTableMap::translateFieldName('ProfileId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->profile_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 2 + $startcol : ProfileResourceTableMap::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)]; + $this->resource_id = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 3 + $startcol : ProfileResourceTableMap::translateFieldName('Read', TableMap::TYPE_PHPNAME, $indexType)]; + $this->read = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 4 + $startcol : ProfileResourceTableMap::translateFieldName('Write', TableMap::TYPE_PHPNAME, $indexType)]; + $this->write = (null !== $col) ? (int) $col : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 5 + $startcol : ProfileResourceTableMap::translateFieldName('CreatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->created_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + + $col = $row[TableMap::TYPE_NUM == $indexType ? 6 + $startcol : ProfileResourceTableMap::translateFieldName('UpdatedAt', TableMap::TYPE_PHPNAME, $indexType)]; + if ($col === '0000-00-00 00:00:00') { + $col = null; + } + $this->updated_at = (null !== $col) ? PropelDateTime::newInstance($col, null, '\DateTime') : null; + $this->resetModified(); + + $this->setNew(false); + + if ($rehydrate) { + $this->ensureConsistency(); + } + + return $startcol + 7; // 7 = ProfileResourceTableMap::NUM_HYDRATE_COLUMNS. + + } catch (Exception $e) { + throw new PropelException("Error populating \Thelia\Model\ProfileResource object", 0, $e); + } + } + + /** + * Checks and repairs the internal consistency of the object. + * + * This method is executed after an already-instantiated object is re-hydrated + * from the database. It exists to check any foreign keys to make sure that + * the objects related to the current object are correct based on foreign key. + * + * You can override this method in the stub class, but you should always invoke + * the base method from the overridden method (i.e. parent::ensureConsistency()), + * in case your model changes. + * + * @throws PropelException + */ + public function ensureConsistency() + { + if ($this->aProfile !== null && $this->profile_id !== $this->aProfile->getId()) { + $this->aProfile = null; + } + if ($this->aResource !== null && $this->resource_id !== $this->aResource->getId()) { + $this->aResource = null; + } + } // ensureConsistency + + /** + * Reloads this object from datastore based on primary key and (optionally) resets all associated objects. + * + * This will only work if the object has been saved and has a valid primary key set. + * + * @param boolean $deep (optional) Whether to also de-associated any related objects. + * @param ConnectionInterface $con (optional) The ConnectionInterface connection to use. + * @return void + * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db + */ + public function reload($deep = false, ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("Cannot reload a deleted object."); + } + + if ($this->isNew()) { + throw new PropelException("Cannot reload an unsaved object."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileResourceTableMap::DATABASE_NAME); + } + + // We don't need to alter the object instance pool; we're just modifying this instance + // already in the pool. + + $dataFetcher = ChildProfileResourceQuery::create(null, $this->buildPkeyCriteria())->setFormatter(ModelCriteria::FORMAT_STATEMENT)->find($con); + $row = $dataFetcher->fetch(); + $dataFetcher->close(); + if (!$row) { + throw new PropelException('Cannot find matching row in the database to reload object values.'); + } + $this->hydrate($row, 0, true, $dataFetcher->getIndexType()); // rehydrate + + if ($deep) { // also de-associate any related objects? + + $this->aProfile = null; + $this->aResource = null; + } // if (deep) + } + + /** + * Removes this object from datastore and sets delete attribute. + * + * @param ConnectionInterface $con + * @return void + * @throws PropelException + * @see ProfileResource::setDeleted() + * @see ProfileResource::isDeleted() + */ + public function delete(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("This object has already been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileResourceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + try { + $deleteQuery = ChildProfileResourceQuery::create() + ->filterByPrimaryKey($this->getPrimaryKey()); + $ret = $this->preDelete($con); + if ($ret) { + $deleteQuery->delete($con); + $this->postDelete($con); + $con->commit(); + $this->setDeleted(true); + } else { + $con->commit(); + } + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Persists this object to the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All modified related objects will also be persisted in the doSave() + * method. This method wraps all precipitate database operations in a + * single transaction. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see doSave() + */ + public function save(ConnectionInterface $con = null) + { + if ($this->isDeleted()) { + throw new PropelException("You cannot save an object that has been deleted."); + } + + if ($con === null) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileResourceTableMap::DATABASE_NAME); + } + + $con->beginTransaction(); + $isInsert = $this->isNew(); + try { + $ret = $this->preSave($con); + if ($isInsert) { + $ret = $ret && $this->preInsert($con); + // timestampable behavior + if (!$this->isColumnModified(ProfileResourceTableMap::CREATED_AT)) { + $this->setCreatedAt(time()); + } + if (!$this->isColumnModified(ProfileResourceTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } else { + $ret = $ret && $this->preUpdate($con); + // timestampable behavior + if ($this->isModified() && !$this->isColumnModified(ProfileResourceTableMap::UPDATED_AT)) { + $this->setUpdatedAt(time()); + } + } + if ($ret) { + $affectedRows = $this->doSave($con); + if ($isInsert) { + $this->postInsert($con); + } else { + $this->postUpdate($con); + } + $this->postSave($con); + ProfileResourceTableMap::addInstanceToPool($this); + } else { + $affectedRows = 0; + } + $con->commit(); + + return $affectedRows; + } catch (Exception $e) { + $con->rollBack(); + throw $e; + } + } + + /** + * Performs the work of inserting or updating the row in the database. + * + * If the object is new, it inserts it; otherwise an update is performed. + * All related objects are also updated in this method. + * + * @param ConnectionInterface $con + * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations. + * @throws PropelException + * @see save() + */ + protected function doSave(ConnectionInterface $con) + { + $affectedRows = 0; // initialize var to track total num of affected rows + if (!$this->alreadyInSave) { + $this->alreadyInSave = true; + + // We call the save method on the following object(s) if they + // were passed to this object by their corresponding set + // method. This object relates to these object(s) by a + // foreign key reference. + + if ($this->aProfile !== null) { + if ($this->aProfile->isModified() || $this->aProfile->isNew()) { + $affectedRows += $this->aProfile->save($con); + } + $this->setProfile($this->aProfile); + } + + if ($this->aResource !== null) { + if ($this->aResource->isModified() || $this->aResource->isNew()) { + $affectedRows += $this->aResource->save($con); + } + $this->setResource($this->aResource); + } + + if ($this->isNew() || $this->isModified()) { + // persist changes + if ($this->isNew()) { + $this->doInsert($con); + } else { + $this->doUpdate($con); + } + $affectedRows += 1; + $this->resetModified(); + } + + $this->alreadyInSave = false; + + } + + return $affectedRows; + } // doSave() + + /** + * Insert the row in the database. + * + * @param ConnectionInterface $con + * + * @throws PropelException + * @see doSave() + */ + protected function doInsert(ConnectionInterface $con) + { + $modifiedColumns = array(); + $index = 0; + + $this->modifiedColumns[] = ProfileResourceTableMap::ID; + if (null !== $this->id) { + throw new PropelException('Cannot insert a value for auto-increment primary key (' . ProfileResourceTableMap::ID . ')'); + } + + // check the columns in natural order for more readable SQL queries + if ($this->isColumnModified(ProfileResourceTableMap::ID)) { + $modifiedColumns[':p' . $index++] = 'ID'; + } + if ($this->isColumnModified(ProfileResourceTableMap::PROFILE_ID)) { + $modifiedColumns[':p' . $index++] = 'PROFILE_ID'; + } + if ($this->isColumnModified(ProfileResourceTableMap::RESOURCE_ID)) { + $modifiedColumns[':p' . $index++] = 'RESOURCE_ID'; + } + if ($this->isColumnModified(ProfileResourceTableMap::READ)) { + $modifiedColumns[':p' . $index++] = 'READ'; + } + if ($this->isColumnModified(ProfileResourceTableMap::WRITE)) { + $modifiedColumns[':p' . $index++] = 'WRITE'; + } + if ($this->isColumnModified(ProfileResourceTableMap::CREATED_AT)) { + $modifiedColumns[':p' . $index++] = 'CREATED_AT'; + } + if ($this->isColumnModified(ProfileResourceTableMap::UPDATED_AT)) { + $modifiedColumns[':p' . $index++] = 'UPDATED_AT'; + } + + $sql = sprintf( + 'INSERT INTO profile_resource (%s) VALUES (%s)', + implode(', ', $modifiedColumns), + implode(', ', array_keys($modifiedColumns)) + ); + + try { + $stmt = $con->prepare($sql); + foreach ($modifiedColumns as $identifier => $columnName) { + switch ($columnName) { + case 'ID': + $stmt->bindValue($identifier, $this->id, PDO::PARAM_INT); + break; + case 'PROFILE_ID': + $stmt->bindValue($identifier, $this->profile_id, PDO::PARAM_INT); + break; + case 'RESOURCE_ID': + $stmt->bindValue($identifier, $this->resource_id, PDO::PARAM_INT); + break; + case 'READ': + $stmt->bindValue($identifier, $this->read, PDO::PARAM_INT); + break; + case 'WRITE': + $stmt->bindValue($identifier, $this->write, PDO::PARAM_INT); + break; + case 'CREATED_AT': + $stmt->bindValue($identifier, $this->created_at ? $this->created_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + case 'UPDATED_AT': + $stmt->bindValue($identifier, $this->updated_at ? $this->updated_at->format("Y-m-d H:i:s") : null, PDO::PARAM_STR); + break; + } + } + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), 0, $e); + } + + try { + $pk = $con->lastInsertId(); + } catch (Exception $e) { + throw new PropelException('Unable to get autoincrement id.', 0, $e); + } + $this->setId($pk); + + $this->setNew(false); + } + + /** + * Update the row in the database. + * + * @param ConnectionInterface $con + * + * @return Integer Number of updated rows + * @see doSave() + */ + protected function doUpdate(ConnectionInterface $con) + { + $selectCriteria = $this->buildPkeyCriteria(); + $valuesCriteria = $this->buildCriteria(); + + return $selectCriteria->doUpdate($valuesCriteria, $con); + } + + /** + * Retrieves a field from the object by name passed in as a string. + * + * @param string $name name + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return mixed Value of field. + */ + public function getByName($name, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + $field = $this->getByPosition($pos); + + return $field; + } + + /** + * Retrieves a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @return mixed Value of field at $pos + */ + public function getByPosition($pos) + { + switch ($pos) { + case 0: + return $this->getId(); + break; + case 1: + return $this->getProfileId(); + break; + case 2: + return $this->getResourceId(); + break; + case 3: + return $this->getRead(); + break; + case 4: + return $this->getWrite(); + break; + case 5: + return $this->getCreatedAt(); + break; + case 6: + return $this->getUpdatedAt(); + break; + default: + return null; + break; + } // switch() + } + + /** + * Exports the object as an array. + * + * You can specify the key type of the array by passing one of the class + * type constants. + * + * @param string $keyType (optional) One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to TRUE. + * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion + * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE. + * + * @return array an associative array containing the field names (as keys) and field values + */ + public function toArray($keyType = TableMap::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false) + { + if (isset($alreadyDumpedObjects['ProfileResource'][serialize($this->getPrimaryKey())])) { + return '*RECURSION*'; + } + $alreadyDumpedObjects['ProfileResource'][serialize($this->getPrimaryKey())] = true; + $keys = ProfileResourceTableMap::getFieldNames($keyType); + $result = array( + $keys[0] => $this->getId(), + $keys[1] => $this->getProfileId(), + $keys[2] => $this->getResourceId(), + $keys[3] => $this->getRead(), + $keys[4] => $this->getWrite(), + $keys[5] => $this->getCreatedAt(), + $keys[6] => $this->getUpdatedAt(), + ); + $virtualColumns = $this->virtualColumns; + foreach ($virtualColumns as $key => $virtualColumn) { + $result[$key] = $virtualColumn; + } + + if ($includeForeignObjects) { + if (null !== $this->aProfile) { + $result['Profile'] = $this->aProfile->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + if (null !== $this->aResource) { + $result['Resource'] = $this->aResource->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true); + } + } + + return $result; + } + + /** + * Sets a field from the object by name passed in as a string. + * + * @param string $name + * @param mixed $value field value + * @param string $type The type of fieldname the $name is of: + * one of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * Defaults to TableMap::TYPE_PHPNAME. + * @return void + */ + public function setByName($name, $value, $type = TableMap::TYPE_PHPNAME) + { + $pos = ProfileResourceTableMap::translateFieldName($name, $type, TableMap::TYPE_NUM); + + return $this->setByPosition($pos, $value); + } + + /** + * Sets a field from the object by Position as specified in the xml schema. + * Zero-based. + * + * @param int $pos position in xml schema + * @param mixed $value field value + * @return void + */ + public function setByPosition($pos, $value) + { + switch ($pos) { + case 0: + $this->setId($value); + break; + case 1: + $this->setProfileId($value); + break; + case 2: + $this->setResourceId($value); + break; + case 3: + $this->setRead($value); + break; + case 4: + $this->setWrite($value); + break; + case 5: + $this->setCreatedAt($value); + break; + case 6: + $this->setUpdatedAt($value); + break; + } // switch() + } + + /** + * Populates the object using an array. + * + * This is particularly useful when populating an object from one of the + * request arrays (e.g. $_POST). This method goes through the column + * names, checking to see whether a matching key exists in populated + * array. If so the setByName() method is called for that column. + * + * You can specify the key type of the array by additionally passing one + * of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME, + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * The default key type is the column's TableMap::TYPE_PHPNAME. + * + * @param array $arr An array to populate the object from. + * @param string $keyType The type of keys the array uses. + * @return void + */ + public function fromArray($arr, $keyType = TableMap::TYPE_PHPNAME) + { + $keys = ProfileResourceTableMap::getFieldNames($keyType); + + if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]); + if (array_key_exists($keys[1], $arr)) $this->setProfileId($arr[$keys[1]]); + if (array_key_exists($keys[2], $arr)) $this->setResourceId($arr[$keys[2]]); + if (array_key_exists($keys[3], $arr)) $this->setRead($arr[$keys[3]]); + if (array_key_exists($keys[4], $arr)) $this->setWrite($arr[$keys[4]]); + if (array_key_exists($keys[5], $arr)) $this->setCreatedAt($arr[$keys[5]]); + if (array_key_exists($keys[6], $arr)) $this->setUpdatedAt($arr[$keys[6]]); + } + + /** + * Build a Criteria object containing the values of all modified columns in this object. + * + * @return Criteria The Criteria object containing all modified values. + */ + public function buildCriteria() + { + $criteria = new Criteria(ProfileResourceTableMap::DATABASE_NAME); + + if ($this->isColumnModified(ProfileResourceTableMap::ID)) $criteria->add(ProfileResourceTableMap::ID, $this->id); + if ($this->isColumnModified(ProfileResourceTableMap::PROFILE_ID)) $criteria->add(ProfileResourceTableMap::PROFILE_ID, $this->profile_id); + if ($this->isColumnModified(ProfileResourceTableMap::RESOURCE_ID)) $criteria->add(ProfileResourceTableMap::RESOURCE_ID, $this->resource_id); + if ($this->isColumnModified(ProfileResourceTableMap::READ)) $criteria->add(ProfileResourceTableMap::READ, $this->read); + if ($this->isColumnModified(ProfileResourceTableMap::WRITE)) $criteria->add(ProfileResourceTableMap::WRITE, $this->write); + if ($this->isColumnModified(ProfileResourceTableMap::CREATED_AT)) $criteria->add(ProfileResourceTableMap::CREATED_AT, $this->created_at); + if ($this->isColumnModified(ProfileResourceTableMap::UPDATED_AT)) $criteria->add(ProfileResourceTableMap::UPDATED_AT, $this->updated_at); + + return $criteria; + } + + /** + * Builds a Criteria object containing the primary key for this object. + * + * Unlike buildCriteria() this method includes the primary key values regardless + * of whether or not they have been modified. + * + * @return Criteria The Criteria object containing value(s) for primary key(s). + */ + public function buildPkeyCriteria() + { + $criteria = new Criteria(ProfileResourceTableMap::DATABASE_NAME); + $criteria->add(ProfileResourceTableMap::ID, $this->id); + $criteria->add(ProfileResourceTableMap::PROFILE_ID, $this->profile_id); + $criteria->add(ProfileResourceTableMap::RESOURCE_ID, $this->resource_id); + + return $criteria; + } + + /** + * Returns the composite primary key for this object. + * The array elements will be in same order as specified in XML. + * @return array + */ + public function getPrimaryKey() + { + $pks = array(); + $pks[0] = $this->getId(); + $pks[1] = $this->getProfileId(); + $pks[2] = $this->getResourceId(); + + return $pks; + } + + /** + * Set the [composite] primary key. + * + * @param array $keys The elements of the composite key (order must match the order in XML file). + * @return void + */ + public function setPrimaryKey($keys) + { + $this->setId($keys[0]); + $this->setProfileId($keys[1]); + $this->setResourceId($keys[2]); + } + + /** + * Returns true if the primary key for this object is null. + * @return boolean + */ + public function isPrimaryKeyNull() + { + + return (null === $this->getId()) && (null === $this->getProfileId()) && (null === $this->getResourceId()); + } + + /** + * Sets contents of passed object to values from current object. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param object $copyObj An object of \Thelia\Model\ProfileResource (or compatible) type. + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new. + * @throws PropelException + */ + public function copyInto($copyObj, $deepCopy = false, $makeNew = true) + { + $copyObj->setProfileId($this->getProfileId()); + $copyObj->setResourceId($this->getResourceId()); + $copyObj->setRead($this->getRead()); + $copyObj->setWrite($this->getWrite()); + $copyObj->setCreatedAt($this->getCreatedAt()); + $copyObj->setUpdatedAt($this->getUpdatedAt()); + if ($makeNew) { + $copyObj->setNew(true); + $copyObj->setId(NULL); // this is a auto-increment column, so set to default value + } + } + + /** + * Makes a copy of this object that will be inserted as a new row in table when saved. + * It creates a new object filling in the simple attributes, but skipping any primary + * keys that are defined for the table. + * + * If desired, this method can also make copies of all associated (fkey referrers) + * objects. + * + * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row. + * @return \Thelia\Model\ProfileResource Clone of current object. + * @throws PropelException + */ + public function copy($deepCopy = false) + { + // we use get_class(), because this might be a subclass + $clazz = get_class($this); + $copyObj = new $clazz(); + $this->copyInto($copyObj, $deepCopy); + + return $copyObj; + } + + /** + * Declares an association between this object and a ChildProfile object. + * + * @param ChildProfile $v + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + * @throws PropelException + */ + public function setProfile(ChildProfile $v = null) + { + if ($v === null) { + $this->setProfileId(NULL); + } else { + $this->setProfileId($v->getId()); + } + + $this->aProfile = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildProfile object, it will not be re-added. + if ($v !== null) { + $v->addProfileResource($this); + } + + + return $this; + } + + + /** + * Get the associated ChildProfile object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildProfile The associated ChildProfile object. + * @throws PropelException + */ + public function getProfile(ConnectionInterface $con = null) + { + if ($this->aProfile === null && ($this->profile_id !== null)) { + $this->aProfile = ChildProfileQuery::create()->findPk($this->profile_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aProfile->addProfileResources($this); + */ + } + + return $this->aProfile; + } + + /** + * Declares an association between this object and a ChildResource object. + * + * @param ChildResource $v + * @return \Thelia\Model\ProfileResource The current object (for fluent API support) + * @throws PropelException + */ + public function setResource(ChildResource $v = null) + { + if ($v === null) { + $this->setResourceId(NULL); + } else { + $this->setResourceId($v->getId()); + } + + $this->aResource = $v; + + // Add binding for other direction of this n:n relationship. + // If this object has already been added to the ChildResource object, it will not be re-added. + if ($v !== null) { + $v->addProfileResource($this); + } + + + return $this; + } + + + /** + * Get the associated ChildResource object + * + * @param ConnectionInterface $con Optional Connection object. + * @return ChildResource The associated ChildResource object. + * @throws PropelException + */ + public function getResource(ConnectionInterface $con = null) + { + if ($this->aResource === null && ($this->resource_id !== null)) { + $this->aResource = ChildResourceQuery::create()->findPk($this->resource_id, $con); + /* The following can be used additionally to + guarantee the related object contains a reference + to this object. This level of coupling may, however, be + undesirable since it could result in an only partially populated collection + in the referenced object. + $this->aResource->addProfileResources($this); + */ + } + + return $this->aResource; + } + + /** + * Clears the current object and sets all attributes to their default values + */ + public function clear() + { + $this->id = null; + $this->profile_id = null; + $this->resource_id = null; + $this->read = null; + $this->write = null; + $this->created_at = null; + $this->updated_at = null; + $this->alreadyInSave = false; + $this->clearAllReferences(); + $this->applyDefaultValues(); + $this->resetModified(); + $this->setNew(true); + $this->setDeleted(false); + } + + /** + * Resets all references to other model objects or collections of model objects. + * + * This method is a user-space workaround for PHP's inability to garbage collect + * objects with circular references (even in PHP 5.3). This is currently necessary + * when using Propel in certain daemon or large-volume/high-memory operations. + * + * @param boolean $deep Whether to also clear the references on all referrer objects. + */ + public function clearAllReferences($deep = false) + { + if ($deep) { + } // if ($deep) + + $this->aProfile = null; + $this->aResource = null; + } + + /** + * Return the string representation of this object + * + * @return string + */ + public function __toString() + { + return (string) $this->exportTo(ProfileResourceTableMap::DEFAULT_STRING_FORMAT); + } + + // timestampable behavior + + /** + * Mark the current object so that the update date doesn't get updated during next save + * + * @return ChildProfileResource The current object (for fluent API support) + */ + public function keepUpdateDateUnchanged() + { + $this->modifiedColumns[] = ProfileResourceTableMap::UPDATED_AT; + + return $this; + } + + /** + * Code to be run before persisting the object + * @param ConnectionInterface $con + * @return boolean + */ + public function preSave(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after persisting the object + * @param ConnectionInterface $con + */ + public function postSave(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before inserting to database + * @param ConnectionInterface $con + * @return boolean + */ + public function preInsert(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after inserting to database + * @param ConnectionInterface $con + */ + public function postInsert(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before updating the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preUpdate(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after updating the object in database + * @param ConnectionInterface $con + */ + public function postUpdate(ConnectionInterface $con = null) + { + + } + + /** + * Code to be run before deleting the object in database + * @param ConnectionInterface $con + * @return boolean + */ + public function preDelete(ConnectionInterface $con = null) + { + return true; + } + + /** + * Code to be run after deleting the object in database + * @param ConnectionInterface $con + */ + public function postDelete(ConnectionInterface $con = null) + { + + } + + + /** + * Derived method to catches calls to undefined methods. + * + * Provides magic import/export method support (fromXML()/toXML(), fromYAML()/toYAML(), etc.). + * Allows to define default __call() behavior if you overwrite __call() + * + * @param string $name + * @param mixed $params + * + * @return array|string + */ + public function __call($name, $params) + { + if (0 === strpos($name, 'get')) { + $virtualColumn = substr($name, 3); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + + $virtualColumn = lcfirst($virtualColumn); + if ($this->hasVirtualColumn($virtualColumn)) { + return $this->getVirtualColumn($virtualColumn); + } + } + + if (0 === strpos($name, 'from')) { + $format = substr($name, 4); + + return $this->importFrom($format, reset($params)); + } + + if (0 === strpos($name, 'to')) { + $format = substr($name, 2); + $includeLazyLoadColumns = isset($params[0]) ? $params[0] : true; + + return $this->exportTo($format, $includeLazyLoadColumns); + } + + throw new BadMethodCallException(sprintf('Call to undefined method: %s.', $name)); + } + +} diff --git a/core/lib/Thelia/Model/Base/ProfileResourceQuery.php b/core/lib/Thelia/Model/Base/ProfileResourceQuery.php new file mode 100644 index 000000000..23794538f --- /dev/null +++ b/core/lib/Thelia/Model/Base/ProfileResourceQuery.php @@ -0,0 +1,868 @@ +setModelAlias($modelAlias); + } + if ($criteria instanceof Criteria) { + $query->mergeWith($criteria); + } + + return $query; + } + + /** + * Find object by primary key. + * Propel uses the instance pool to skip the database if the object exists. + * Go fast if the query is untouched. + * + * + * $obj = $c->findPk(array(12, 34, 56), $con); + * + * + * @param array[$id, $profile_id, $resource_id] $key Primary key to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ChildProfileResource|array|mixed the result, formatted by the current formatter + */ + public function findPk($key, $con = null) + { + if ($key === null) { + return null; + } + if ((null !== ($obj = ProfileResourceTableMap::getInstanceFromPool(serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))))) && !$this->formatter) { + // the object is already in the instance pool + return $obj; + } + if ($con === null) { + $con = Propel::getServiceContainer()->getReadConnection(ProfileResourceTableMap::DATABASE_NAME); + } + $this->basePreSelect($con); + if ($this->formatter || $this->modelAlias || $this->with || $this->select + || $this->selectColumns || $this->asColumns || $this->selectModifiers + || $this->map || $this->having || $this->joins) { + return $this->findPkComplex($key, $con); + } else { + return $this->findPkSimple($key, $con); + } + } + + /** + * Find object by primary key using raw SQL to go fast. + * Bypass doSelect() and the object formatter by using generated code. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfileResource A model object, or null if the key is not found + */ + protected function findPkSimple($key, $con) + { + $sql = 'SELECT ID, PROFILE_ID, RESOURCE_ID, READ, WRITE, CREATED_AT, UPDATED_AT FROM profile_resource WHERE ID = :p0 AND PROFILE_ID = :p1 AND RESOURCE_ID = :p2'; + try { + $stmt = $con->prepare($sql); + $stmt->bindValue(':p0', $key[0], PDO::PARAM_INT); + $stmt->bindValue(':p1', $key[1], PDO::PARAM_INT); + $stmt->bindValue(':p2', $key[2], PDO::PARAM_INT); + $stmt->execute(); + } catch (Exception $e) { + Propel::log($e->getMessage(), Propel::LOG_ERR); + throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), 0, $e); + } + $obj = null; + if ($row = $stmt->fetch(\PDO::FETCH_NUM)) { + $obj = new ChildProfileResource(); + $obj->hydrate($row); + ProfileResourceTableMap::addInstanceToPool($obj, serialize(array((string) $key[0], (string) $key[1], (string) $key[2]))); + } + $stmt->closeCursor(); + + return $obj; + } + + /** + * Find object by primary key. + * + * @param mixed $key Primary key to use for the query + * @param ConnectionInterface $con A connection object + * + * @return ChildProfileResource|array|mixed the result, formatted by the current formatter + */ + protected function findPkComplex($key, $con) + { + // As the query uses a PK condition, no limit(1) is necessary. + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKey($key) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->formatOne($dataFetcher); + } + + /** + * Find objects by primary key + * + * $objs = $c->findPks(array(array(12, 56), array(832, 123), array(123, 456)), $con); + * + * @param array $keys Primary keys to use for the query + * @param ConnectionInterface $con an optional connection object + * + * @return ObjectCollection|array|mixed the list of results, formatted by the current formatter + */ + public function findPks($keys, $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getReadConnection($this->getDbName()); + } + $this->basePreSelect($con); + $criteria = $this->isKeepQuery() ? clone $this : $this; + $dataFetcher = $criteria + ->filterByPrimaryKeys($keys) + ->doSelect($con); + + return $criteria->getFormatter()->init($criteria)->format($dataFetcher); + } + + /** + * Filter the query by primary key + * + * @param mixed $key Primary key to use for the query + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByPrimaryKey($key) + { + $this->addUsingAlias(ProfileResourceTableMap::ID, $key[0], Criteria::EQUAL); + $this->addUsingAlias(ProfileResourceTableMap::PROFILE_ID, $key[1], Criteria::EQUAL); + $this->addUsingAlias(ProfileResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL); + + return $this; + } + + /** + * Filter the query by a list of primary keys + * + * @param array $keys The list of primary key to use for the query + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByPrimaryKeys($keys) + { + if (empty($keys)) { + return $this->add(null, '1<>1', Criteria::CUSTOM); + } + foreach ($keys as $key) { + $cton0 = $this->getNewCriterion(ProfileResourceTableMap::ID, $key[0], Criteria::EQUAL); + $cton1 = $this->getNewCriterion(ProfileResourceTableMap::PROFILE_ID, $key[1], Criteria::EQUAL); + $cton0->addAnd($cton1); + $cton2 = $this->getNewCriterion(ProfileResourceTableMap::RESOURCE_ID, $key[2], Criteria::EQUAL); + $cton0->addAnd($cton2); + $this->addOr($cton0); + } + + return $this; + } + + /** + * Filter the query on the id column + * + * Example usage: + * + * $query->filterById(1234); // WHERE id = 1234 + * $query->filterById(array(12, 34)); // WHERE id IN (12, 34) + * $query->filterById(array('min' => 12)); // WHERE id > 12 + * + * + * @param mixed $id The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterById($id = null, $comparison = null) + { + if (is_array($id)) { + $useMinMax = false; + if (isset($id['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::ID, $id['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($id['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::ID, $id['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileResourceTableMap::ID, $id, $comparison); + } + + /** + * Filter the query on the profile_id column + * + * Example usage: + * + * $query->filterByProfileId(1234); // WHERE profile_id = 1234 + * $query->filterByProfileId(array(12, 34)); // WHERE profile_id IN (12, 34) + * $query->filterByProfileId(array('min' => 12)); // WHERE profile_id > 12 + * + * + * @see filterByProfile() + * + * @param mixed $profileId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByProfileId($profileId = null, $comparison = null) + { + if (is_array($profileId)) { + $useMinMax = false; + if (isset($profileId['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::PROFILE_ID, $profileId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($profileId['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::PROFILE_ID, $profileId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileResourceTableMap::PROFILE_ID, $profileId, $comparison); + } + + /** + * Filter the query on the resource_id column + * + * Example usage: + * + * $query->filterByResourceId(1234); // WHERE resource_id = 1234 + * $query->filterByResourceId(array(12, 34)); // WHERE resource_id IN (12, 34) + * $query->filterByResourceId(array('min' => 12)); // WHERE resource_id > 12 + * + * + * @see filterByResource() + * + * @param mixed $resourceId The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByResourceId($resourceId = null, $comparison = null) + { + if (is_array($resourceId)) { + $useMinMax = false; + if (isset($resourceId['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::RESOURCE_ID, $resourceId['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($resourceId['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::RESOURCE_ID, $resourceId['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileResourceTableMap::RESOURCE_ID, $resourceId, $comparison); + } + + /** + * Filter the query on the read column + * + * Example usage: + * + * $query->filterByRead(1234); // WHERE read = 1234 + * $query->filterByRead(array(12, 34)); // WHERE read IN (12, 34) + * $query->filterByRead(array('min' => 12)); // WHERE read > 12 + * + * + * @param mixed $read The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByRead($read = null, $comparison = null) + { + if (is_array($read)) { + $useMinMax = false; + if (isset($read['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::READ, $read['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($read['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::READ, $read['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileResourceTableMap::READ, $read, $comparison); + } + + /** + * Filter the query on the write column + * + * Example usage: + * + * $query->filterByWrite(1234); // WHERE write = 1234 + * $query->filterByWrite(array(12, 34)); // WHERE write IN (12, 34) + * $query->filterByWrite(array('min' => 12)); // WHERE write > 12 + * + * + * @param mixed $write The value to use as filter. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByWrite($write = null, $comparison = null) + { + if (is_array($write)) { + $useMinMax = false; + if (isset($write['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($write['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileResourceTableMap::WRITE, $write, $comparison); + } + + /** + * Filter the query on the created_at column + * + * Example usage: + * + * $query->filterByCreatedAt('2011-03-14'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt('now'); // WHERE created_at = '2011-03-14' + * $query->filterByCreatedAt(array('max' => 'yesterday')); // WHERE created_at > '2011-03-13' + * + * + * @param mixed $createdAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByCreatedAt($createdAt = null, $comparison = null) + { + if (is_array($createdAt)) { + $useMinMax = false; + if (isset($createdAt['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::CREATED_AT, $createdAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($createdAt['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::CREATED_AT, $createdAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileResourceTableMap::CREATED_AT, $createdAt, $comparison); + } + + /** + * Filter the query on the updated_at column + * + * Example usage: + * + * $query->filterByUpdatedAt('2011-03-14'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt('now'); // WHERE updated_at = '2011-03-14' + * $query->filterByUpdatedAt(array('max' => 'yesterday')); // WHERE updated_at > '2011-03-13' + * + * + * @param mixed $updatedAt The value to use as filter. + * Values can be integers (unix timestamps), DateTime objects, or strings. + * Empty strings are treated as NULL. + * Use scalar values for equality. + * Use array values for in_array() equivalent. + * Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByUpdatedAt($updatedAt = null, $comparison = null) + { + if (is_array($updatedAt)) { + $useMinMax = false; + if (isset($updatedAt['min'])) { + $this->addUsingAlias(ProfileResourceTableMap::UPDATED_AT, $updatedAt['min'], Criteria::GREATER_EQUAL); + $useMinMax = true; + } + if (isset($updatedAt['max'])) { + $this->addUsingAlias(ProfileResourceTableMap::UPDATED_AT, $updatedAt['max'], Criteria::LESS_EQUAL); + $useMinMax = true; + } + if ($useMinMax) { + return $this; + } + if (null === $comparison) { + $comparison = Criteria::IN; + } + } + + return $this->addUsingAlias(ProfileResourceTableMap::UPDATED_AT, $updatedAt, $comparison); + } + + /** + * Filter the query by a related \Thelia\Model\Profile object + * + * @param \Thelia\Model\Profile|ObjectCollection $profile The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByProfile($profile, $comparison = null) + { + if ($profile instanceof \Thelia\Model\Profile) { + return $this + ->addUsingAlias(ProfileResourceTableMap::PROFILE_ID, $profile->getId(), $comparison); + } elseif ($profile instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProfileResourceTableMap::PROFILE_ID, $profile->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByProfile() only accepts arguments of type \Thelia\Model\Profile or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Profile relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function joinProfile($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Profile'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Profile'); + } + + return $this; + } + + /** + * Use the Profile relation Profile object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ProfileQuery A secondary query class using the current class as primary query + */ + public function useProfileQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinProfile($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Profile', '\Thelia\Model\ProfileQuery'); + } + + /** + * Filter the query by a related \Thelia\Model\Resource object + * + * @param \Thelia\Model\Resource|ObjectCollection $resource The related object(s) to use as filter + * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function filterByResource($resource, $comparison = null) + { + if ($resource instanceof \Thelia\Model\Resource) { + return $this + ->addUsingAlias(ProfileResourceTableMap::RESOURCE_ID, $resource->getId(), $comparison); + } elseif ($resource instanceof ObjectCollection) { + if (null === $comparison) { + $comparison = Criteria::IN; + } + + return $this + ->addUsingAlias(ProfileResourceTableMap::RESOURCE_ID, $resource->toKeyValue('PrimaryKey', 'Id'), $comparison); + } else { + throw new PropelException('filterByResource() only accepts arguments of type \Thelia\Model\Resource or Collection'); + } + } + + /** + * Adds a JOIN clause to the query using the Resource relation + * + * @param string $relationAlias optional alias for the relation + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function joinResource($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + $tableMap = $this->getTableMap(); + $relationMap = $tableMap->getRelation('Resource'); + + // create a ModelJoin object for this join + $join = new ModelJoin(); + $join->setJoinType($joinType); + $join->setRelationMap($relationMap, $this->useAliasInSQL ? $this->getModelAlias() : null, $relationAlias); + if ($previousJoin = $this->getPreviousJoin()) { + $join->setPreviousJoin($previousJoin); + } + + // add the ModelJoin to the current object + if ($relationAlias) { + $this->addAlias($relationAlias, $relationMap->getRightTable()->getName()); + $this->addJoinObject($join, $relationAlias); + } else { + $this->addJoinObject($join, 'Resource'); + } + + return $this; + } + + /** + * Use the Resource relation Resource object + * + * @see useQuery() + * + * @param string $relationAlias optional alias for the relation, + * to be used as main alias in the secondary query + * @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' + * + * @return \Thelia\Model\ResourceQuery A secondary query class using the current class as primary query + */ + public function useResourceQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) + { + return $this + ->joinResource($relationAlias, $joinType) + ->useQuery($relationAlias ? $relationAlias : 'Resource', '\Thelia\Model\ResourceQuery'); + } + + /** + * Exclude object from result + * + * @param ChildProfileResource $profileResource Object to remove from the list of results + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function prune($profileResource = null) + { + if ($profileResource) { + $this->addCond('pruneCond0', $this->getAliasedColName(ProfileResourceTableMap::ID), $profileResource->getId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond1', $this->getAliasedColName(ProfileResourceTableMap::PROFILE_ID), $profileResource->getProfileId(), Criteria::NOT_EQUAL); + $this->addCond('pruneCond2', $this->getAliasedColName(ProfileResourceTableMap::RESOURCE_ID), $profileResource->getResourceId(), Criteria::NOT_EQUAL); + $this->combine(array('pruneCond0', 'pruneCond1', 'pruneCond2'), Criteria::LOGICAL_OR); + } + + return $this; + } + + /** + * Deletes all rows from the profile_resource table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public function doDeleteAll(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileResourceTableMap::DATABASE_NAME); + } + $affectedRows = 0; // initialize var to track total num of affected rows + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + $affectedRows += parent::doDeleteAll($con); + // Because this db requires some delete cascade/set null emulation, we have to + // clear the cached instance *after* the emulation has happened (since + // instances get re-added by the select statement contained therein). + ProfileResourceTableMap::clearInstancePool(); + ProfileResourceTableMap::clearRelatedInstancePool(); + + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $affectedRows; + } + + /** + * Performs a DELETE on the database, given a ChildProfileResource or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ChildProfileResource object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public function delete(ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileResourceTableMap::DATABASE_NAME); + } + + $criteria = $this; + + // Set the correct dbName + $criteria->setDbName(ProfileResourceTableMap::DATABASE_NAME); + + $affectedRows = 0; // initialize var to track total num of affected rows + + try { + // use transaction because $criteria could contain info + // for more than one table or we could emulating ON DELETE CASCADE, etc. + $con->beginTransaction(); + + + ProfileResourceTableMap::removeInstanceFromPool($criteria); + + $affectedRows += ModelCriteria::delete($con); + ProfileResourceTableMap::clearRelatedInstancePool(); + $con->commit(); + + return $affectedRows; + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + } + + // timestampable behavior + + /** + * Filter by the latest updated + * + * @param int $nbDays Maximum age of the latest update in days + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function recentlyUpdated($nbDays = 7) + { + return $this->addUsingAlias(ProfileResourceTableMap::UPDATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Filter by the latest created + * + * @param int $nbDays Maximum age of in days + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function recentlyCreated($nbDays = 7) + { + return $this->addUsingAlias(ProfileResourceTableMap::CREATED_AT, time() - $nbDays * 24 * 60 * 60, Criteria::GREATER_EQUAL); + } + + /** + * Order by update date desc + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function lastUpdatedFirst() + { + return $this->addDescendingOrderByColumn(ProfileResourceTableMap::UPDATED_AT); + } + + /** + * Order by update date asc + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function firstUpdatedFirst() + { + return $this->addAscendingOrderByColumn(ProfileResourceTableMap::UPDATED_AT); + } + + /** + * Order by create date desc + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function lastCreatedFirst() + { + return $this->addDescendingOrderByColumn(ProfileResourceTableMap::CREATED_AT); + } + + /** + * Order by create date asc + * + * @return ChildProfileResourceQuery The current query, for fluid interface + */ + public function firstCreatedFirst() + { + return $this->addAscendingOrderByColumn(ProfileResourceTableMap::CREATED_AT); + } + +} // ProfileResourceQuery diff --git a/core/lib/Thelia/Model/Map/AdminProfileTableMap.php b/core/lib/Thelia/Model/Map/AdminProfileTableMap.php new file mode 100644 index 000000000..a6407c8e2 --- /dev/null +++ b/core/lib/Thelia/Model/Map/AdminProfileTableMap.php @@ -0,0 +1,509 @@ + array('Id', 'ProfileId', 'AdminId', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'adminId', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(AdminProfileTableMap::ID, AdminProfileTableMap::PROFILE_ID, AdminProfileTableMap::ADMIN_ID, AdminProfileTableMap::CREATED_AT, AdminProfileTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'ADMIN_ID', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'profile_id', 'admin_id', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'AdminId' => 2, 'CreatedAt' => 3, 'UpdatedAt' => 4, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'adminId' => 2, 'createdAt' => 3, 'updatedAt' => 4, ), + self::TYPE_COLNAME => array(AdminProfileTableMap::ID => 0, AdminProfileTableMap::PROFILE_ID => 1, AdminProfileTableMap::ADMIN_ID => 2, AdminProfileTableMap::CREATED_AT => 3, AdminProfileTableMap::UPDATED_AT => 4, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'ADMIN_ID' => 2, 'CREATED_AT' => 3, 'UPDATED_AT' => 4, ), + self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'admin_id' => 2, 'created_at' => 3, 'updated_at' => 4, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('admin_profile'); + $this->setPhpName('AdminProfile'); + $this->setClassName('\\Thelia\\Model\\AdminProfile'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + $this->setIsCrossRef(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignPrimaryKey('PROFILE_ID', 'ProfileId', 'INTEGER' , 'profile', 'ID', true, null, null); + $this->addForeignPrimaryKey('ADMIN_ID', 'AdminId', 'INTEGER' , 'admin', 'ID', true, null, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Profile', '\\Thelia\\Model\\Profile', RelationMap::MANY_TO_ONE, array('profile_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_ONE, array('admin_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\AdminProfile $obj A \Thelia\Model\AdminProfile object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getProfileId(), (string) $obj->getAdminId())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\AdminProfile object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\AdminProfile) { + $key = serialize(array((string) $value->getId(), (string) $value->getProfileId(), (string) $value->getAdminId())); + + } elseif (is_array($value) && count($value) === 3) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\AdminProfile object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ProfileId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ProfileId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('AdminId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? AdminProfileTableMap::CLASS_DEFAULT : AdminProfileTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (AdminProfile object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = AdminProfileTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = AdminProfileTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + AdminProfileTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = AdminProfileTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + AdminProfileTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = AdminProfileTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = AdminProfileTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + AdminProfileTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(AdminProfileTableMap::ID); + $criteria->addSelectColumn(AdminProfileTableMap::PROFILE_ID); + $criteria->addSelectColumn(AdminProfileTableMap::ADMIN_ID); + $criteria->addSelectColumn(AdminProfileTableMap::CREATED_AT); + $criteria->addSelectColumn(AdminProfileTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PROFILE_ID'); + $criteria->addSelectColumn($alias . '.ADMIN_ID'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(AdminProfileTableMap::DATABASE_NAME)->getTable(AdminProfileTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(AdminProfileTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(AdminProfileTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new AdminProfileTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a AdminProfile or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or AdminProfile object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminProfileTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\AdminProfile) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(AdminProfileTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(AdminProfileTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(AdminProfileTableMap::PROFILE_ID, $value[1])); + $criterion->addAnd($criteria->getNewCriterion(AdminProfileTableMap::ADMIN_ID, $value[2])); + $criteria->addOr($criterion); + } + } + + $query = AdminProfileQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { AdminProfileTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { AdminProfileTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the admin_profile table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return AdminProfileQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a AdminProfile or Criteria object. + * + * @param mixed $criteria Criteria or AdminProfile object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(AdminProfileTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from AdminProfile object + } + + if ($criteria->containsKey(AdminProfileTableMap::ID) && $criteria->keyContainsValue(AdminProfileTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.AdminProfileTableMap::ID.')'); + } + + + // Set the correct dbName + $query = AdminProfileQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // AdminProfileTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +AdminProfileTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProfileI18nTableMap.php b/core/lib/Thelia/Model/Map/ProfileI18nTableMap.php new file mode 100644 index 000000000..915f45ec6 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProfileI18nTableMap.php @@ -0,0 +1,497 @@ + array('Id', 'Locale', 'Title', 'Description', 'Chapo', 'Postscriptum', ), + self::TYPE_STUDLYPHPNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_COLNAME => array(ProfileI18nTableMap::ID, ProfileI18nTableMap::LOCALE, ProfileI18nTableMap::TITLE, ProfileI18nTableMap::DESCRIPTION, ProfileI18nTableMap::CHAPO, ProfileI18nTableMap::POSTSCRIPTUM, ), + self::TYPE_RAW_COLNAME => array('ID', 'LOCALE', 'TITLE', 'DESCRIPTION', 'CHAPO', 'POSTSCRIPTUM', ), + self::TYPE_FIELDNAME => array('id', 'locale', 'title', 'description', 'chapo', 'postscriptum', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Locale' => 1, 'Title' => 2, 'Description' => 3, 'Chapo' => 4, 'Postscriptum' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_COLNAME => array(ProfileI18nTableMap::ID => 0, ProfileI18nTableMap::LOCALE => 1, ProfileI18nTableMap::TITLE => 2, ProfileI18nTableMap::DESCRIPTION => 3, ProfileI18nTableMap::CHAPO => 4, ProfileI18nTableMap::POSTSCRIPTUM => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'LOCALE' => 1, 'TITLE' => 2, 'DESCRIPTION' => 3, 'CHAPO' => 4, 'POSTSCRIPTUM' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'locale' => 1, 'title' => 2, 'description' => 3, 'chapo' => 4, 'postscriptum' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('profile_i18n'); + $this->setPhpName('ProfileI18n'); + $this->setClassName('\\Thelia\\Model\\ProfileI18n'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(false); + // columns + $this->addForeignPrimaryKey('ID', 'Id', 'INTEGER' , 'profile', 'ID', true, null, null); + $this->addPrimaryKey('LOCALE', 'Locale', 'VARCHAR', true, 5, 'en_US'); + $this->addColumn('TITLE', 'Title', 'VARCHAR', false, 255, null); + $this->addColumn('DESCRIPTION', 'Description', 'CLOB', false, null, null); + $this->addColumn('CHAPO', 'Chapo', 'LONGVARCHAR', false, null, null); + $this->addColumn('POSTSCRIPTUM', 'Postscriptum', 'LONGVARCHAR', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Profile', '\\Thelia\\Model\\Profile', RelationMap::MANY_TO_ONE, array('id' => 'id', ), 'CASCADE', null); + } // buildRelations() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ProfileI18n $obj A \Thelia\Model\ProfileI18n object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getLocale())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\ProfileI18n object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\ProfileI18n) { + $key = serialize(array((string) $value->getId(), (string) $value->getLocale())); + + } elseif (is_array($value) && count($value) === 2) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProfileI18n object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('Locale', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProfileI18nTableMap::CLASS_DEFAULT : ProfileI18nTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ProfileI18n object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProfileI18nTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProfileI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProfileI18nTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProfileI18nTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProfileI18nTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProfileI18nTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProfileI18nTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ProfileI18nTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ProfileI18nTableMap::ID); + $criteria->addSelectColumn(ProfileI18nTableMap::LOCALE); + $criteria->addSelectColumn(ProfileI18nTableMap::TITLE); + $criteria->addSelectColumn(ProfileI18nTableMap::DESCRIPTION); + $criteria->addSelectColumn(ProfileI18nTableMap::CHAPO); + $criteria->addSelectColumn(ProfileI18nTableMap::POSTSCRIPTUM); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.LOCALE'); + $criteria->addSelectColumn($alias . '.TITLE'); + $criteria->addSelectColumn($alias . '.DESCRIPTION'); + $criteria->addSelectColumn($alias . '.CHAPO'); + $criteria->addSelectColumn($alias . '.POSTSCRIPTUM'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ProfileI18nTableMap::DATABASE_NAME)->getTable(ProfileI18nTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProfileI18nTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProfileI18nTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProfileI18nTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ProfileI18n or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ProfileI18n object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileI18nTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProfileI18n) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProfileI18nTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(ProfileI18nTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProfileI18nTableMap::LOCALE, $value[1])); + $criteria->addOr($criterion); + } + } + + $query = ProfileI18nQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProfileI18nTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProfileI18nTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the profile_i18n table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProfileI18nQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProfileI18n or Criteria object. + * + * @param mixed $criteria Criteria or ProfileI18n object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileI18nTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProfileI18n object + } + + + // Set the correct dbName + $query = ProfileI18nQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProfileI18nTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProfileI18nTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProfileModuleTableMap.php b/core/lib/Thelia/Model/Map/ProfileModuleTableMap.php new file mode 100644 index 000000000..07e640b8f --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProfileModuleTableMap.php @@ -0,0 +1,456 @@ + array('Id', 'ProfileId', 'ModuleId', 'Access', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'moduleId', 'access', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProfileModuleTableMap::ID, ProfileModuleTableMap::PROFILE_ID, ProfileModuleTableMap::MODULE_ID, ProfileModuleTableMap::ACCESS, ProfileModuleTableMap::CREATED_AT, ProfileModuleTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'MODULE_ID', 'ACCESS', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'profile_id', 'module_id', 'access', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'ModuleId' => 2, 'Access' => 3, 'CreatedAt' => 4, 'UpdatedAt' => 5, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'moduleId' => 2, 'access' => 3, 'createdAt' => 4, 'updatedAt' => 5, ), + self::TYPE_COLNAME => array(ProfileModuleTableMap::ID => 0, ProfileModuleTableMap::PROFILE_ID => 1, ProfileModuleTableMap::MODULE_ID => 2, ProfileModuleTableMap::ACCESS => 3, ProfileModuleTableMap::CREATED_AT => 4, ProfileModuleTableMap::UPDATED_AT => 5, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'MODULE_ID' => 2, 'ACCESS' => 3, 'CREATED_AT' => 4, 'UPDATED_AT' => 5, ), + self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'module_id' => 2, 'access' => 3, 'created_at' => 4, 'updated_at' => 5, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('profile_module'); + $this->setPhpName('ProfileModule'); + $this->setClassName('\\Thelia\\Model\\ProfileModule'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignKey('PROFILE_ID', 'ProfileId', 'INTEGER', 'profile', 'ID', true, null, null); + $this->addForeignKey('MODULE_ID', 'ModuleId', 'INTEGER', 'module', 'ID', false, null, null); + $this->addColumn('ACCESS', 'Access', 'TINYINT', false, null, 0); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Profile', '\\Thelia\\Model\\Profile', RelationMap::MANY_TO_ONE, array('profile_id' => 'id', ), 'CASCADE', 'CASCADE'); + $this->addRelation('Module', '\\Thelia\\Model\\Module', RelationMap::MANY_TO_ONE, array('module_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProfileModuleTableMap::CLASS_DEFAULT : ProfileModuleTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ProfileModule object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProfileModuleTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProfileModuleTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProfileModuleTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProfileModuleTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProfileModuleTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProfileModuleTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProfileModuleTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ProfileModuleTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ProfileModuleTableMap::ID); + $criteria->addSelectColumn(ProfileModuleTableMap::PROFILE_ID); + $criteria->addSelectColumn(ProfileModuleTableMap::MODULE_ID); + $criteria->addSelectColumn(ProfileModuleTableMap::ACCESS); + $criteria->addSelectColumn(ProfileModuleTableMap::CREATED_AT); + $criteria->addSelectColumn(ProfileModuleTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PROFILE_ID'); + $criteria->addSelectColumn($alias . '.MODULE_ID'); + $criteria->addSelectColumn($alias . '.ACCESS'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ProfileModuleTableMap::DATABASE_NAME)->getTable(ProfileModuleTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProfileModuleTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProfileModuleTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProfileModuleTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ProfileModule or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ProfileModule object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileModuleTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProfileModule) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProfileModuleTableMap::DATABASE_NAME); + $criteria->add(ProfileModuleTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ProfileModuleQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProfileModuleTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProfileModuleTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the profile_module table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProfileModuleQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProfileModule or Criteria object. + * + * @param mixed $criteria Criteria or ProfileModule object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileModuleTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProfileModule object + } + + if ($criteria->containsKey(ProfileModuleTableMap::ID) && $criteria->keyContainsValue(ProfileModuleTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProfileModuleTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ProfileModuleQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProfileModuleTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProfileModuleTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php b/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php new file mode 100644 index 000000000..4e46d9c33 --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProfileResourceTableMap.php @@ -0,0 +1,525 @@ + array('Id', 'ProfileId', 'ResourceId', 'Read', 'Write', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'profileId', 'resourceId', 'read', 'write', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProfileResourceTableMap::ID, ProfileResourceTableMap::PROFILE_ID, ProfileResourceTableMap::RESOURCE_ID, ProfileResourceTableMap::READ, ProfileResourceTableMap::WRITE, ProfileResourceTableMap::CREATED_AT, ProfileResourceTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'PROFILE_ID', 'RESOURCE_ID', 'READ', 'WRITE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'profile_id', 'resource_id', 'read', 'write', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'ProfileId' => 1, 'ResourceId' => 2, 'Read' => 3, 'Write' => 4, 'CreatedAt' => 5, 'UpdatedAt' => 6, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'profileId' => 1, 'resourceId' => 2, 'read' => 3, 'write' => 4, 'createdAt' => 5, 'updatedAt' => 6, ), + self::TYPE_COLNAME => array(ProfileResourceTableMap::ID => 0, ProfileResourceTableMap::PROFILE_ID => 1, ProfileResourceTableMap::RESOURCE_ID => 2, ProfileResourceTableMap::READ => 3, ProfileResourceTableMap::WRITE => 4, ProfileResourceTableMap::CREATED_AT => 5, ProfileResourceTableMap::UPDATED_AT => 6, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'PROFILE_ID' => 1, 'RESOURCE_ID' => 2, 'READ' => 3, 'WRITE' => 4, 'CREATED_AT' => 5, 'UPDATED_AT' => 6, ), + self::TYPE_FIELDNAME => array('id' => 0, 'profile_id' => 1, 'resource_id' => 2, 'read' => 3, 'write' => 4, 'created_at' => 5, 'updated_at' => 6, ), + self::TYPE_NUM => array(0, 1, 2, 3, 4, 5, 6, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('profile_resource'); + $this->setPhpName('ProfileResource'); + $this->setClassName('\\Thelia\\Model\\ProfileResource'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + $this->setIsCrossRef(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addForeignPrimaryKey('PROFILE_ID', 'ProfileId', 'INTEGER' , 'profile', 'ID', true, null, null); + $this->addForeignPrimaryKey('RESOURCE_ID', 'ResourceId', 'INTEGER' , 'resource', 'ID', true, null, null); + $this->addColumn('READ', 'Read', 'TINYINT', false, null, 0); + $this->addColumn('WRITE', 'Write', 'TINYINT', false, null, 0); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('Profile', '\\Thelia\\Model\\Profile', RelationMap::MANY_TO_ONE, array('profile_id' => 'id', ), 'CASCADE', 'RESTRICT'); + $this->addRelation('Resource', '\\Thelia\\Model\\Resource', RelationMap::MANY_TO_ONE, array('resource_id' => 'id', ), 'CASCADE', 'RESTRICT'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + ); + } // getBehaviors() + + /** + * Adds an object to the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases you may need to explicitly add objects + * to the cache in order to ensure that the same objects are always returned by find*() + * and findPk*() calls. + * + * @param \Thelia\Model\ProfileResource $obj A \Thelia\Model\ProfileResource object. + * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). + */ + public static function addInstanceToPool($obj, $key = null) + { + if (Propel::isInstancePoolingEnabled()) { + if (null === $key) { + $key = serialize(array((string) $obj->getId(), (string) $obj->getProfileId(), (string) $obj->getResourceId())); + } // if key === null + self::$instances[$key] = $obj; + } + } + + /** + * Removes an object from the instance pool. + * + * Propel keeps cached copies of objects in an instance pool when they are retrieved + * from the database. In some cases -- especially when you override doDelete + * methods in your stub classes -- you may need to explicitly remove objects + * from the cache in order to prevent returning objects that no longer exist. + * + * @param mixed $value A \Thelia\Model\ProfileResource object or a primary key value. + */ + public static function removeInstanceFromPool($value) + { + if (Propel::isInstancePoolingEnabled() && null !== $value) { + if (is_object($value) && $value instanceof \Thelia\Model\ProfileResource) { + $key = serialize(array((string) $value->getId(), (string) $value->getProfileId(), (string) $value->getResourceId())); + + } elseif (is_array($value) && count($value) === 3) { + // assume we've been passed a primary key"; + $key = serialize(array((string) $value[0], (string) $value[1], (string) $value[2])); + } elseif ($value instanceof Criteria) { + self::$instances = []; + + return; + } else { + $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or \Thelia\Model\ProfileResource object; got " . (is_object($value) ? get_class($value) . ' object.' : var_export($value, true))); + throw $e; + } + + unset(self::$instances[$key]); + } + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ProfileId', TableMap::TYPE_PHPNAME, $indexType)] === null && $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return serialize(array((string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 1 + $offset : static::translateFieldName('ProfileId', TableMap::TYPE_PHPNAME, $indexType)], (string) $row[TableMap::TYPE_NUM == $indexType ? 2 + $offset : static::translateFieldName('ResourceId', TableMap::TYPE_PHPNAME, $indexType)])); + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return $pks; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProfileResourceTableMap::CLASS_DEFAULT : ProfileResourceTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (ProfileResource object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProfileResourceTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProfileResourceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProfileResourceTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProfileResourceTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProfileResourceTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProfileResourceTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProfileResourceTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ProfileResourceTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ProfileResourceTableMap::ID); + $criteria->addSelectColumn(ProfileResourceTableMap::PROFILE_ID); + $criteria->addSelectColumn(ProfileResourceTableMap::RESOURCE_ID); + $criteria->addSelectColumn(ProfileResourceTableMap::READ); + $criteria->addSelectColumn(ProfileResourceTableMap::WRITE); + $criteria->addSelectColumn(ProfileResourceTableMap::CREATED_AT); + $criteria->addSelectColumn(ProfileResourceTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.PROFILE_ID'); + $criteria->addSelectColumn($alias . '.RESOURCE_ID'); + $criteria->addSelectColumn($alias . '.READ'); + $criteria->addSelectColumn($alias . '.WRITE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ProfileResourceTableMap::DATABASE_NAME)->getTable(ProfileResourceTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProfileResourceTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProfileResourceTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProfileResourceTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a ProfileResource or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or ProfileResource object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileResourceTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\ProfileResource) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProfileResourceTableMap::DATABASE_NAME); + // primary key is composite; we therefore, expect + // the primary key passed to be an array of pkey values + if (count($values) == count($values, COUNT_RECURSIVE)) { + // array is not multi-dimensional + $values = array($values); + } + foreach ($values as $value) { + $criterion = $criteria->getNewCriterion(ProfileResourceTableMap::ID, $value[0]); + $criterion->addAnd($criteria->getNewCriterion(ProfileResourceTableMap::PROFILE_ID, $value[1])); + $criterion->addAnd($criteria->getNewCriterion(ProfileResourceTableMap::RESOURCE_ID, $value[2])); + $criteria->addOr($criterion); + } + } + + $query = ProfileResourceQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProfileResourceTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProfileResourceTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the profile_resource table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProfileResourceQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a ProfileResource or Criteria object. + * + * @param mixed $criteria Criteria or ProfileResource object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileResourceTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from ProfileResource object + } + + if ($criteria->containsKey(ProfileResourceTableMap::ID) && $criteria->keyContainsValue(ProfileResourceTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProfileResourceTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ProfileResourceQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProfileResourceTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProfileResourceTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Map/ProfileTableMap.php b/core/lib/Thelia/Model/Map/ProfileTableMap.php new file mode 100644 index 000000000..076da402c --- /dev/null +++ b/core/lib/Thelia/Model/Map/ProfileTableMap.php @@ -0,0 +1,466 @@ + array('Id', 'Code', 'CreatedAt', 'UpdatedAt', ), + self::TYPE_STUDLYPHPNAME => array('id', 'code', 'createdAt', 'updatedAt', ), + self::TYPE_COLNAME => array(ProfileTableMap::ID, ProfileTableMap::CODE, ProfileTableMap::CREATED_AT, ProfileTableMap::UPDATED_AT, ), + self::TYPE_RAW_COLNAME => array('ID', 'CODE', 'CREATED_AT', 'UPDATED_AT', ), + self::TYPE_FIELDNAME => array('id', 'code', 'created_at', 'updated_at', ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * holds an array of keys for quick access to the fieldnames array + * + * first dimension keys are the type constants + * e.g. self::$fieldKeys[self::TYPE_PHPNAME]['Id'] = 0 + */ + protected static $fieldKeys = array ( + self::TYPE_PHPNAME => array('Id' => 0, 'Code' => 1, 'CreatedAt' => 2, 'UpdatedAt' => 3, ), + self::TYPE_STUDLYPHPNAME => array('id' => 0, 'code' => 1, 'createdAt' => 2, 'updatedAt' => 3, ), + self::TYPE_COLNAME => array(ProfileTableMap::ID => 0, ProfileTableMap::CODE => 1, ProfileTableMap::CREATED_AT => 2, ProfileTableMap::UPDATED_AT => 3, ), + self::TYPE_RAW_COLNAME => array('ID' => 0, 'CODE' => 1, 'CREATED_AT' => 2, 'UPDATED_AT' => 3, ), + self::TYPE_FIELDNAME => array('id' => 0, 'code' => 1, 'created_at' => 2, 'updated_at' => 3, ), + self::TYPE_NUM => array(0, 1, 2, 3, ) + ); + + /** + * Initialize the table attributes and columns + * Relations are not initialized by this method since they are lazy loaded + * + * @return void + * @throws PropelException + */ + public function initialize() + { + // attributes + $this->setName('profile'); + $this->setPhpName('Profile'); + $this->setClassName('\\Thelia\\Model\\Profile'); + $this->setPackage('Thelia.Model'); + $this->setUseIdGenerator(true); + // columns + $this->addPrimaryKey('ID', 'Id', 'INTEGER', true, null, null); + $this->addColumn('CODE', 'Code', 'VARCHAR', true, 30, null); + $this->addColumn('CREATED_AT', 'CreatedAt', 'TIMESTAMP', false, null, null); + $this->addColumn('UPDATED_AT', 'UpdatedAt', 'TIMESTAMP', false, null, null); + } // initialize() + + /** + * Build the RelationMap objects for this table relationships + */ + public function buildRelations() + { + $this->addRelation('AdminProfile', '\\Thelia\\Model\\AdminProfile', RelationMap::ONE_TO_MANY, array('id' => 'profile_id', ), 'CASCADE', 'RESTRICT', 'AdminProfiles'); + $this->addRelation('ProfileResource', '\\Thelia\\Model\\ProfileResource', RelationMap::ONE_TO_MANY, array('id' => 'profile_id', ), 'CASCADE', 'RESTRICT', 'ProfileResources'); + $this->addRelation('ProfileModule', '\\Thelia\\Model\\ProfileModule', RelationMap::ONE_TO_MANY, array('id' => 'profile_id', ), 'CASCADE', 'CASCADE', 'ProfileModules'); + $this->addRelation('ProfileI18n', '\\Thelia\\Model\\ProfileI18n', RelationMap::ONE_TO_MANY, array('id' => 'id', ), 'CASCADE', null, 'ProfileI18ns'); + $this->addRelation('Admin', '\\Thelia\\Model\\Admin', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Admins'); + $this->addRelation('Resource', '\\Thelia\\Model\\Resource', RelationMap::MANY_TO_MANY, array(), 'CASCADE', 'RESTRICT', 'Resources'); + } // buildRelations() + + /** + * + * Gets the list of behaviors registered for this table + * + * @return array Associative array (name => parameters) of behaviors + */ + public function getBehaviors() + { + return array( + 'timestampable' => array('create_column' => 'created_at', 'update_column' => 'updated_at', ), + 'i18n' => array('i18n_table' => '%TABLE%_i18n', 'i18n_phpname' => '%PHPNAME%I18n', 'i18n_columns' => 'title, description, chapo, postscriptum', 'locale_column' => 'locale', 'locale_length' => '5', 'default_locale' => '', 'locale_alias' => '', ), + ); + } // getBehaviors() + /** + * Method to invalidate the instance pool of all tables related to profile * by a foreign key with ON DELETE CASCADE + */ + public static function clearRelatedInstancePool() + { + // Invalidate objects in ".$this->getClassNameFromBuilder($joinedTableTableMapBuilder)." instance pool, + // since one or more of them may be deleted by ON DELETE CASCADE/SETNULL rule. + AdminProfileTableMap::clearInstancePool(); + ProfileResourceTableMap::clearInstancePool(); + ProfileModuleTableMap::clearInstancePool(); + ProfileI18nTableMap::clearInstancePool(); + } + + /** + * Retrieves a string version of the primary key from the DB resultset row that can be used to uniquely identify a row in this table. + * + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, a serialize()d version of the primary key will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + */ + public static function getPrimaryKeyHashFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + // If the PK cannot be derived from the row, return NULL. + if ($row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)] === null) { + return null; + } + + return (string) $row[TableMap::TYPE_NUM == $indexType ? 0 + $offset : static::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType)]; + } + + /** + * Retrieves the primary key from the DB resultset row + * For tables with a single-column primary key, that simple pkey value will be returned. For tables with + * a multi-column primary key, an array of the primary key columns will be returned. + * + * @param array $row resultset row. + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM + * + * @return mixed The primary key of the row + */ + public static function getPrimaryKeyFromRow($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + + return (int) $row[ + $indexType == TableMap::TYPE_NUM + ? 0 + $offset + : self::translateFieldName('Id', TableMap::TYPE_PHPNAME, $indexType) + ]; + } + + /** + * The class that the tableMap will make instances of. + * + * If $withPrefix is true, the returned path + * uses a dot-path notation which is translated into a path + * relative to a location on the PHP include_path. + * (e.g. path.to.MyClass -> 'path/to/MyClass.php') + * + * @param boolean $withPrefix Whether or not to return the path with the class name + * @return string path.to.ClassName + */ + public static function getOMClass($withPrefix = true) + { + return $withPrefix ? ProfileTableMap::CLASS_DEFAULT : ProfileTableMap::OM_CLASS; + } + + /** + * Populates an object of the default type or an object that inherit from the default. + * + * @param array $row row returned by DataFetcher->fetch(). + * @param int $offset The 0-based offset for reading from the resultset row. + * @param string $indexType The index type of $row. Mostly DataFetcher->getIndexType(). + One of the class type constants TableMap::TYPE_PHPNAME, TableMap::TYPE_STUDLYPHPNAME + * TableMap::TYPE_COLNAME, TableMap::TYPE_FIELDNAME, TableMap::TYPE_NUM. + * + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + * @return array (Profile object, last column rank) + */ + public static function populateObject($row, $offset = 0, $indexType = TableMap::TYPE_NUM) + { + $key = ProfileTableMap::getPrimaryKeyHashFromRow($row, $offset, $indexType); + if (null !== ($obj = ProfileTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, $offset, true); // rehydrate + $col = $offset + ProfileTableMap::NUM_HYDRATE_COLUMNS; + } else { + $cls = ProfileTableMap::OM_CLASS; + $obj = new $cls(); + $col = $obj->hydrate($row, $offset, false, $indexType); + ProfileTableMap::addInstanceToPool($obj, $key); + } + + return array($obj, $col); + } + + /** + * The returned array will contain objects of the default type or + * objects that inherit from the default. + * + * @param DataFetcherInterface $dataFetcher + * @return array + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function populateObjects(DataFetcherInterface $dataFetcher) + { + $results = array(); + + // set the class once to avoid overhead in the loop + $cls = static::getOMClass(false); + // populate the object(s) + while ($row = $dataFetcher->fetch()) { + $key = ProfileTableMap::getPrimaryKeyHashFromRow($row, 0, $dataFetcher->getIndexType()); + if (null !== ($obj = ProfileTableMap::getInstanceFromPool($key))) { + // We no longer rehydrate the object, since this can cause data loss. + // See http://www.propelorm.org/ticket/509 + // $obj->hydrate($row, 0, true); // rehydrate + $results[] = $obj; + } else { + $obj = new $cls(); + $obj->hydrate($row); + $results[] = $obj; + ProfileTableMap::addInstanceToPool($obj, $key); + } // if key exists + } + + return $results; + } + /** + * Add all the columns needed to create a new object. + * + * Note: any columns that were marked with lazyLoad="true" in the + * XML schema will not be added to the select list and only loaded + * on demand. + * + * @param Criteria $criteria object containing the columns to add. + * @param string $alias optional table alias + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function addSelectColumns(Criteria $criteria, $alias = null) + { + if (null === $alias) { + $criteria->addSelectColumn(ProfileTableMap::ID); + $criteria->addSelectColumn(ProfileTableMap::CODE); + $criteria->addSelectColumn(ProfileTableMap::CREATED_AT); + $criteria->addSelectColumn(ProfileTableMap::UPDATED_AT); + } else { + $criteria->addSelectColumn($alias . '.ID'); + $criteria->addSelectColumn($alias . '.CODE'); + $criteria->addSelectColumn($alias . '.CREATED_AT'); + $criteria->addSelectColumn($alias . '.UPDATED_AT'); + } + } + + /** + * Returns the TableMap related to this object. + * This method is not needed for general use but a specific application could have a need. + * @return TableMap + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function getTableMap() + { + return Propel::getServiceContainer()->getDatabaseMap(ProfileTableMap::DATABASE_NAME)->getTable(ProfileTableMap::TABLE_NAME); + } + + /** + * Add a TableMap instance to the database for this tableMap class. + */ + public static function buildTableMap() + { + $dbMap = Propel::getServiceContainer()->getDatabaseMap(ProfileTableMap::DATABASE_NAME); + if (!$dbMap->hasTable(ProfileTableMap::TABLE_NAME)) { + $dbMap->addTableObject(new ProfileTableMap()); + } + } + + /** + * Performs a DELETE on the database, given a Profile or Criteria object OR a primary key value. + * + * @param mixed $values Criteria or Profile object or primary key or array of primary keys + * which is used to create the DELETE statement + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows + * if supported by native driver or if emulated using Propel. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doDelete($values, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); + } + + if ($values instanceof Criteria) { + // rename for clarity + $criteria = $values; + } elseif ($values instanceof \Thelia\Model\Profile) { // it's a model object + // create criteria based on pk values + $criteria = $values->buildPkeyCriteria(); + } else { // it's a primary key, or an array of pks + $criteria = new Criteria(ProfileTableMap::DATABASE_NAME); + $criteria->add(ProfileTableMap::ID, (array) $values, Criteria::IN); + } + + $query = ProfileQuery::create()->mergeWith($criteria); + + if ($values instanceof Criteria) { ProfileTableMap::clearInstancePool(); + } elseif (!is_object($values)) { // it's a primary key, or an array of pks + foreach ((array) $values as $singleval) { ProfileTableMap::removeInstanceFromPool($singleval); + } + } + + return $query->delete($con); + } + + /** + * Deletes all rows from the profile table. + * + * @param ConnectionInterface $con the connection to use + * @return int The number of affected rows (if supported by underlying database driver). + */ + public static function doDeleteAll(ConnectionInterface $con = null) + { + return ProfileQuery::create()->doDeleteAll($con); + } + + /** + * Performs an INSERT on the database, given a Profile or Criteria object. + * + * @param mixed $criteria Criteria or Profile object containing data that is used to create the INSERT statement. + * @param ConnectionInterface $con the ConnectionInterface connection to use + * @return mixed The new primary key. + * @throws PropelException Any exceptions caught during processing will be + * rethrown wrapped into a PropelException. + */ + public static function doInsert($criteria, ConnectionInterface $con = null) + { + if (null === $con) { + $con = Propel::getServiceContainer()->getWriteConnection(ProfileTableMap::DATABASE_NAME); + } + + if ($criteria instanceof Criteria) { + $criteria = clone $criteria; // rename for clarity + } else { + $criteria = $criteria->buildCriteria(); // build Criteria from Profile object + } + + if ($criteria->containsKey(ProfileTableMap::ID) && $criteria->keyContainsValue(ProfileTableMap::ID) ) { + throw new PropelException('Cannot insert a value for auto-increment primary key ('.ProfileTableMap::ID.')'); + } + + + // Set the correct dbName + $query = ProfileQuery::create()->mergeWith($criteria); + + try { + // use transaction because $criteria could contain info + // for more than one table (I guess, conceivably) + $con->beginTransaction(); + $pk = $query->doInsert($con); + $con->commit(); + } catch (PropelException $e) { + $con->rollBack(); + throw $e; + } + + return $pk; + } + +} // ProfileTableMap +// This is the static code needed to register the TableMap for this table with the main Propel class. +// +ProfileTableMap::buildTableMap(); diff --git a/core/lib/Thelia/Model/Profile.php b/core/lib/Thelia/Model/Profile.php new file mode 100644 index 000000000..8f3a61edd --- /dev/null +++ b/core/lib/Thelia/Model/Profile.php @@ -0,0 +1,11 @@ + - + @@ -763,23 +763,12 @@ - - - - - - - - + + + - - - - - - - - + +
diff --git a/templates/admin/default/configuration.html b/templates/admin/default/configuration.html index 054b1c6cd..f95b623da 100644 --- a/templates/admin/default/configuration.html +++ b/templates/admin/default/configuration.html @@ -131,15 +131,15 @@ {loop type="auth" name="pcc3" roles="ADMIN" permissions="admin.configuration.profiles"} - {intl l='Back-office profiles'} + {intl l='Administration profiles'} {/loop} {loop type="auth" name="pcc4" roles="ADMIN" permissions="admin.configuration.admin_users"} - {intl l='Back-office users'} - + {intl l='Administrators'} + {/loop} diff --git a/templates/admin/default/profile-edit.html b/templates/admin/default/profile-edit.html index e882dc40d..1c6d2e9a8 100644 --- a/templates/admin/default/profile-edit.html +++ b/templates/admin/default/profile-edit.html @@ -1,126 +1,441 @@ {extends file="admin-layout.tpl"} -{block name="page-title"}{intl l='Edit profile'}{/block} +{block name="page-title"}{intl l='Edit a profile'}{/block} -{block name="check-permissions"}admin.profile.edit{/block} +{block name="check-permissions"}admin.configuration.profiles.edit{/block} {block name="main-content"} -
-
+ {assign oder_tab {$smarty.get.tab|default:$smarty.post.tab|default:'data'}} + {assign asked_country {$smarty.get.country|default:{country ask="default" attr="id"}}} -