Skip to content

Commit

Permalink
Version 1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
gillesbourgeat committed Feb 28, 2016
1 parent c21f353 commit 502a041
Show file tree
Hide file tree
Showing 28 changed files with 122 additions and 179 deletions.
6 changes: 1 addition & 5 deletions Action/AttributeTypeAction.php
Expand Up @@ -2,10 +2,6 @@
/*************************************************************************************/
/* This file is part of the module AttributeType */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
Expand All @@ -22,7 +18,7 @@
/**
* Class AttributeTypeAction
* @package AttributeType\Action
* @author Gilles Bourgeat <gbourgeat@openstudio.fr>
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class AttributeTypeAction implements EventSubscriberInterface
{
Expand Down
8 changes: 4 additions & 4 deletions AttributeType.php
Expand Up @@ -3,7 +3,7 @@
/* This file is part of the module AttributeType */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* email : gilles.bourgeat@gmail.com */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
Expand All @@ -20,7 +20,7 @@
/**
* Class AttributeType
* @package AttributeType
* @author Gilles Bourgeat <gbourgeat@openstudio.fr>
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class AttributeType extends BaseModule
{
Expand All @@ -33,10 +33,10 @@ class AttributeType extends BaseModule
*/
public function postActivation(ConnectionInterface $con = null)
{
if (!self::getConfigValue('is_initialized', false)) {
if (!$this->getConfigValue('is_initialized', false)) {
$database = new Database($con);
$database->insertSql(null, [__DIR__ . "/Config/thelia.sql", __DIR__ . "/Config/insert.sql"]);
self::setConfigValue('is_initialized', true);
$this->setConfigValue('is_initialized', true);
}
}

Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,12 @@
# 1.2.2

- Fix check auth
- Fix methods and variables visibility

# 1.2.1

- -Fix double translation and Exception

# 1.2

- Add static methods getAttributeAv and getAttributeAvs in model AttributeType
Expand Down
4 changes: 2 additions & 2 deletions Config/module.xml
Expand Up @@ -16,10 +16,10 @@
<language>en_US</language>
<language>fr_FR</language>
</languages>
<version>1.2.1</version>
<version>1.2.2</version>
<author>
<name>Gilles Bourgeat</name>
<email>gbourgeat@openstudio.fr</email>
<email>gilles.bourgeat@gmail.com</email>
<website>https://github.com/gillesbourgeat</website>
</author>
<type>classic</type>
Expand Down
2 changes: 0 additions & 2 deletions Config/sqldb.map

This file was deleted.

28 changes: 12 additions & 16 deletions Controller/AttributeTypeAttributeAvController.php
Expand Up @@ -2,10 +2,6 @@
/*************************************************************************************/
/* This file is part of the module AttributeType */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
Expand All @@ -26,23 +22,23 @@
/**
* Class AttributeTypeAttributeAvController
* @package AttributeType\Controller
* @author Gilles Bourgeat <gbourgeat@openstudio.fr>
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class AttributeTypeAttributeAvController extends AttributeTypeController
{
/** @var Lang[] */
private $langs = array();
protected $langs = array();

/** @var AttributeAttributeType[] */
private $attributeAttributeTypes = array();
protected $attributeAttributeTypes = array();

/**
* @param int $attribute_id
* @return null|\Symfony\Component\HttpFoundation\Response|\Thelia\Core\HttpFoundation\Response
*/
public function updateMetaAction($attribute_id)
{
if (null !== $response = $this->checkAuth(array(AdminResources::MODULE), 'AttributeType', AccessManager::UPDATE)) {
if (null !== $response = $this->checkAuth(array(AdminResources::ATTRIBUTE), null, AccessManager::UPDATE)) {
return $response;
}

Expand All @@ -56,8 +52,8 @@ public function updateMetaAction($attribute_id)
foreach ($attributeAvs as $attributeAvId => $attributeAv) {
foreach ($attributeAv['lang'] as $langId => $lang) {
foreach ($lang['attribute_type'] as $attributeTypeId => $value) {
self::dispatchEvent(
self::getAttributeAttributeType($attributeTypeId, $attribute_id),
$this->dispatchEvent(
$this->getAttributeAttributeType($attributeTypeId, $attribute_id),
$attributeAvId,
$langId,
$value
Expand All @@ -74,7 +70,7 @@ public function updateMetaAction($attribute_id)
$form
);

return self::viewAttribute($attribute_id);
return $this->viewAttribute($attribute_id);
}
}

Expand All @@ -85,14 +81,14 @@ public function updateMetaAction($attribute_id)
* @param string $value
* @throws \Exception
*/
public function dispatchEvent(AttributeAttributeType $attributeAttributeType, $attributeAvId, $langId, $value)
protected function dispatchEvent(AttributeAttributeType $attributeAttributeType, $attributeAvId, $langId, $value)
{
$eventName = AttributeTypeEvents::ATTRIBUTE_TYPE_AV_META_UPDATE;

$attributeAvMeta = AttributeTypeAvMetaQuery::create()
->filterByAttributeAvId($attributeAvId)
->filterByAttributeAttributeTypeId($attributeAttributeType->getId())
->filterByLocale(self::getLocale($langId))
->filterByLocale($this->getLocale($langId))
->findOne();

// create if not exist
Expand All @@ -102,7 +98,7 @@ public function dispatchEvent(AttributeAttributeType $attributeAttributeType, $a
$attributeAvMeta = (new AttributeTypeAvMeta())
->setAttributeAvId($attributeAvId)
->setAttributeAttributeTypeId($attributeAttributeType->getId())
->setLocale(self::getLocale($langId));
->setLocale($this->getLocale($langId));
}

$attributeAvMeta->setValue($value);
Expand All @@ -119,7 +115,7 @@ public function dispatchEvent(AttributeAttributeType $attributeAttributeType, $a
* @return AttributeAttributeType
* @throws \Exception
*/
private function getAttributeAttributeType($attributeTypeId, $attributeId)
protected function getAttributeAttributeType($attributeTypeId, $attributeId)
{
if (!isset($this->attributeAttributeTypes[$attributeTypeId])) {
$this->attributeAttributeTypes[$attributeTypeId] = AttributeAttributeTypeQuery::create()
Expand All @@ -140,7 +136,7 @@ private function getAttributeAttributeType($attributeTypeId, $attributeId)
* @return string
* @throws \Exception
*/
private function getLocale($langId)
protected function getLocale($langId)
{
if (!isset($this->langs[$langId])) {
$this->langs[$langId] = LangQuery::create()->findPk($langId);
Expand Down
20 changes: 8 additions & 12 deletions Controller/AttributeTypeAttributeController.php
Expand Up @@ -2,10 +2,6 @@
/*************************************************************************************/
/* This file is part of the module AttributeType */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
Expand All @@ -25,7 +21,7 @@
/**
* Class AttributeTypeAttributeController
* @package AttributeType\Controller
* @author Gilles Bourgeat <gbourgeat@openstudio.fr>
* @author Gilles Bourgeat <gilles.bourgeat@gmail.com>
*/
class AttributeTypeAttributeController extends AttributeTypeController
{
Expand All @@ -36,7 +32,7 @@ class AttributeTypeAttributeController extends AttributeTypeController
*/
public function associateAction($attribute_type_id, $attribute_id)
{
if (null !== $response = $this->checkAuth(array(AdminResources::MODULE), 'AttributeType', AccessManager::UPDATE)) {
if (null !== $response = $this->checkAuth(array(AdminResources::ATTRIBUTE), null, AccessManager::UPDATE)) {
return $response;
}

Expand All @@ -47,7 +43,7 @@ public function associateAction($attribute_type_id, $attribute_id)

$this->dispatch(
AttributeTypeEvents::ATTRIBUTE_TYPE_ASSOCIATE,
self::getEventAssociation($attribute_type_id, $attribute_id)
$this->getEventAssociation($attribute_type_id, $attribute_id)
);

return $this->generateSuccessRedirect($form);
Expand All @@ -58,7 +54,7 @@ public function associateAction($attribute_type_id, $attribute_id)
$form
);

return self::viewAttribute($attribute_id);
return $this->viewAttribute($attribute_id);
}
}

Expand All @@ -69,7 +65,7 @@ public function associateAction($attribute_type_id, $attribute_id)
*/
public function dissociateAction($attribute_type_id, $attribute_id)
{
if (null !== $response = $this->checkAuth(array(AdminResources::MODULE), 'AttributeType', AccessManager::UPDATE)) {
if (null !== $response = $this->checkAuth(array(AdminResources::ATTRIBUTE), null, AccessManager::UPDATE)) {
return $response;
}

Expand All @@ -80,7 +76,7 @@ public function dissociateAction($attribute_type_id, $attribute_id)

$this->dispatch(
AttributeTypeEvents::ATTRIBUTE_TYPE_DISSOCIATE,
self::getEventAssociation($attribute_type_id, $attribute_id)
$this->getEventAssociation($attribute_type_id, $attribute_id)
);

return $this->generateSuccessRedirect($form);
Expand All @@ -91,7 +87,7 @@ public function dissociateAction($attribute_type_id, $attribute_id)
$form
);

return self::viewAttribute($attribute_id);
return $this->viewAttribute($attribute_id);
}
}

Expand All @@ -101,7 +97,7 @@ public function dissociateAction($attribute_type_id, $attribute_id)
* @return AttributeTypeEvent
* @throws \Exception
*/
private function getEventAssociation($attribute_type_id, $attribute_id)
protected function getEventAssociation($attribute_type_id, $attribute_id)
{
if (null === $attribute = AttributeQuery::create()->findPk($attribute_id)) {
throw new \Exception(Translator::getInstance()->trans(
Expand Down

0 comments on commit 502a041

Please sign in to comment.