Hydrate SeoForm under SEO Tab

This commit is contained in:
touffies
2013-11-28 12:12:24 +01:00
parent 083f3bfa8c
commit 5980ff44fc

View File

@@ -23,50 +23,56 @@
namespace Thelia\Controller\Admin;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Event\Product\ProductAddCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteEvent;
use Symfony\Component\HttpFoundation\JsonResponse;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\Product\ProductUpdateEvent;
use Thelia\Core\Event\Product\ProductCreateEvent;
use Thelia\Core\Security\AccessManager;
use Thelia\Model\ProductQuery;
use Thelia\Form\ProductModificationForm;
use Thelia\Form\ProductCreationForm;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\Product\ProductAddCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteCategoryEvent;
use Thelia\Core\Event\Product\ProductDeleteEvent;
use Thelia\Core\Event\Product\ProductToggleVisibilityEvent;
use Thelia\Core\Event\Product\ProductDeleteContentEvent;
use Thelia\Core\Event\Product\ProductAddContentEvent;
use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\ProductAssociatedContentQuery;
use Thelia\Model\AccessoryQuery;
use Thelia\Model\CategoryQuery;
use Thelia\Core\Event\Product\ProductAddAccessoryEvent;
use Thelia\Core\Event\Product\ProductDeleteAccessoryEvent;
use Thelia\Model\ProductSaleElementsQuery;
use Thelia\Core\Event\Product\ProductCombinationGenerationEvent;
use Thelia\Core\Event\Product\ProductSetTemplateEvent;
use Thelia\Core\Event\UpdatePositionEvent;
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementDeleteEvent;
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementUpdateEvent;
use Thelia\Core\Event\ProductSaleElement\ProductSaleElementCreateEvent;
use Thelia\Core\Security\Resource\AdminResources;
use Thelia\Core\Security\AccessManager;
use Thelia\Model\AccessoryQuery;
use Thelia\Model\CategoryQuery;
use Thelia\Model\FolderQuery;
use Thelia\Model\ContentQuery;
use Thelia\Model\AttributeQuery;
use Thelia\Model\AttributeAvQuery;
use Thelia\Form\ProductSaleElementUpdateForm;
use Thelia\Model\ProductQuery;
use Thelia\Model\ProductAssociatedContentQuery;
use Thelia\Model\ProductSaleElementsQuery;
use Thelia\Model\ProductPriceQuery;
use Thelia\Form\ProductDefaultSaleElementUpdateForm;
use Thelia\Model\ProductPrice;
use Thelia\Model\Currency;
use Symfony\Component\HttpFoundation\JsonResponse;
use Thelia\TaxEngine\Calculator;
use Thelia\Model\Country;
use Thelia\Tools\NumberFormat;
use Thelia\Model\Product;
use Thelia\Model\CurrencyQuery;
use Thelia\Model\Country;
use Thelia\Model\Product;
use Thelia\Form\ProductCreationForm;
use Thelia\Form\ProductModificationForm;
use Thelia\Form\ProductSaleElementUpdateForm;
use Thelia\Form\ProductDefaultSaleElementUpdateForm;
use Thelia\Form\ProductCombinationGenerationForm;
use Thelia\Core\Event\Product\ProductCombinationGenerationEvent;
use Thelia\Core\Event\Product\ProductSetTemplateEvent;
use Thelia\Form\SeoForm;
use Thelia\TaxEngine\Calculator;
use Thelia\Tools\NumberFormat;
/**
* Manages products
@@ -89,7 +95,8 @@ class ProductController extends AbstractCrudController
TheliaEvents::PRODUCT_DELETE,
TheliaEvents::PRODUCT_TOGGLE_VISIBILITY,
TheliaEvents::PRODUCT_UPDATE_POSITION
TheliaEvents::PRODUCT_UPDATE_POSITION,
TheliaEvents::PRODUCT_UPDATE_SEO
);
}
@@ -153,9 +160,9 @@ class ProductController extends AbstractCrudController
protected function getUpdateEvent($formData)
{
$changeEvent = new ProductUpdateEvent($formData['id']);
// Create and dispatch the change event
$changeEvent
->setLocale($formData['locale'])
->setTitle($formData['title'])
@@ -163,10 +170,10 @@ class ProductController extends AbstractCrudController
->setDescription($formData['description'])
->setPostscriptum($formData['postscriptum'])
->setVisible($formData['visible'])
->setUrl($formData['url'])
->setDefaultCategory($formData['default_category'])
;
;
// Create and dispatch the change event
return $changeEvent;
}
@@ -307,6 +314,20 @@ class ProductController extends AbstractCrudController
$this->getParserContext()->addForm($combinationPseForm);
}
// The "SEO" tab form
$data = array(
'id' => $object->getId(),
'locale' => $object->getLocale(),
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
'meta_title' => $object->getMetaTitle(),
'meta_description' => $object->getMetaDescription(),
'meta_keyword' => $object->getMetaKeyword()
);
$seoForm = new SeoForm($this->getRequest(), "form", $data);
$this->getParserContext()->addForm($seoForm);
// The "General" tab form
$data = array(
'id' => $object->getId(),
@@ -317,7 +338,6 @@ class ProductController extends AbstractCrudController
'description' => $object->getDescription(),
'postscriptum' => $object->getPostscriptum(),
'visible' => $object->getVisible(),
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
'default_category' => $object->getDefaultCategoryId()
);