Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thelia loop Overriding #1787

Merged
merged 6 commits into from Nov 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions core/lib/Thelia/Config/Resources/action.xml
Expand Up @@ -216,6 +216,7 @@
<argument type="service" id="service_container"/>
<tag name="kernel.event_subscriber"/>
</service>

</services>

</config>
27 changes: 27 additions & 0 deletions core/lib/Thelia/Core/Event/Loop/LoopExtendsArgDefinitionsEvent.php
@@ -0,0 +1,27 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* 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. */
/*************************************************************************************/


namespace Thelia\Core\Event\Loop;

/**
* Class LoopExtendsArgDefinitionsEvent
* @package Thelia\Core\Event\Loop
* @author Julien Chanséaume <julien@thelia.net>
*/
class LoopExtendsArgDefinitionsEvent extends LoopExtendsEvent
{
public function getArgumentCollection()
{
return $this->loop->getArgumentCollection();
}
}
45 changes: 45 additions & 0 deletions core/lib/Thelia/Core/Event/Loop/LoopExtendsBuildArrayEvent.php
@@ -0,0 +1,45 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* 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. */
/*************************************************************************************/


namespace Thelia\Core\Event\Loop;

use Thelia\Core\Template\Element\BaseLoop;

/**
* Class LoopExtendsBuildArrayEvent
* @package Thelia\Core\Event\Loop
* @author Julien Chanséaume <julien@thelia.net>
*/
class LoopExtendsBuildArrayEvent extends LoopExtendsEvent
{
/** @var array $array */
protected $array;

/**
* LoopExtendsBuildArrayEvent constructor.
* @param array $array
*/
public function __construct(BaseLoop $loop, array $array)
{
parent::__construct($loop);
$this->array = $array;
}

/**
* @return array
*/
public function getArray()
{
return $this->array;
}
}
@@ -0,0 +1,46 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* 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. */
/*************************************************************************************/


namespace Thelia\Core\Event\Loop;

use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Template\Element\BaseLoop;

/**
* Class LoopExtendsBuildModelCriteriaEvent
* @package Thelia\Core\Event\Loop
* @author Julien Chanséaume <julien@thelia.net>
*/
class LoopExtendsBuildModelCriteriaEvent extends LoopExtendsEvent
{
/** @var ModelCriteria $modelCriteria */
protected $modelCriteria;

/**
* LoopExtendsBuildModelCriteria constructor.
* @param ModelCriteria $modelCriteria
*/
public function __construct(BaseLoop $loop, ModelCriteria $modelCriteria)
{
parent::__construct($loop);
$this->modelCriteria = $modelCriteria;
}

/**
* @return ModelCriteria
*/
public function getModelCriteria()
{
return $this->modelCriteria;
}
}
57 changes: 57 additions & 0 deletions core/lib/Thelia/Core/Event/Loop/LoopExtendsEvent.php
@@ -0,0 +1,57 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* 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. */
/*************************************************************************************/


namespace Thelia\Core\Event\Loop;

use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Template\Element\BaseLoop;

/**
* Class LoopExtendsEvent
* @package Thelia\Core\Event\Loop
* @author Julien Chanséaume <julien@thelia.net>
*/
class LoopExtendsEvent extends ActionEvent
{
/** @var BaseLoop|null $loop */
protected $loop = null;

/**
* LoopExtendsEvent constructor.
* @param null|BaseLoop $loop
*/
public function __construct(BaseLoop $loop)
{
$this->loop = $loop;
}

/**
* Get the loop
*
* @return null|BaseLoop
*/
public function getLoop()
{
return $this->loop;
}

/**
* Get the loop name
*
* @return null|string
*/
public function getLoopName()
{
return $this->loop->getLoopName();
}
}
56 changes: 56 additions & 0 deletions core/lib/Thelia/Core/Event/Loop/LoopExtendsInitializeArgsEvent.php
@@ -0,0 +1,56 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* 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. */
/*************************************************************************************/


namespace Thelia\Core\Event\Loop;

use Thelia\Core\Template\Element\BaseLoop;

/**
* Class LoopExtendsInitializeArgsEvent
* @package Thelia\Core\Event\Loop
* @author Julien Chanséaume <julien@thelia.net>
*/
class LoopExtendsInitializeArgsEvent extends LoopExtendsEvent
{
/** @var array the loop parameters when called. an array of name => value pairs */
protected $loopParameters;

/**
* LoopExtendsInitializeArgs constructor.
* @param array $loopParameters
*/
public function __construct(BaseLoop $loop, array $loopParameters)
{
parent::__construct($loop);
$this->loopParameters = $loopParameters;
}

/**
* The loop parameters when called. an array of name => value pairs.
*
* @return array the loop parameters when called. an array of name => value pairs
*/
public function getLoopParameters()
{
return $this->loopParameters;
}

/**
* @param array $loopParameters
*/
public function setLoopParameters($loopParameters)
{
$this->loopParameters = $loopParameters;
return $this;
}
}
46 changes: 46 additions & 0 deletions core/lib/Thelia/Core/Event/Loop/LoopExtendsParseResultsEvent.php
@@ -0,0 +1,46 @@
<?php
/*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* 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. */
/*************************************************************************************/


namespace Thelia\Core\Event\Loop;

use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult;

/**
* Class LoopExtendsParseResultsEvent
* @package Thelia\Core\Event\Loop
* @author Julien Chanséaume <julien@thelia.net>
*/
class LoopExtendsParseResultsEvent extends LoopExtendsEvent
{
/** @var LoopResult $loopResult */
protected $loopResult;

/**
* LoopExtendsParseResultsEvent constructor.
* @param LoopResult $loopResult
*/
public function __construct(BaseLoop $loop, LoopResult $loopResult)
{
parent::__construct($loop);
$this->loopResult = $loopResult;
}

/**
* @return LoopResult
*/
public function getLoopResult()
{
return $this->loopResult;
}
}
21 changes: 21 additions & 0 deletions core/lib/Thelia/Core/Event/TheliaEvents.php
Expand Up @@ -544,6 +544,27 @@ final class TheliaEvents
*/
const AFTER_COUPON_CONDITION_UPDATE = "action.after_update_coupon_condition";

// -- Loop ---------------------------------------------

const LOOP_EXTENDS_ARG_DEFINITIONS = "loop.extends.arg_definitions";
const LOOP_EXTENDS_INITIALIZE_ARGS = "loop.extends.initialize_args";
const LOOP_EXTENDS_BUILD_MODEL_CRITERIA = "loop.extends.build_model_criteria";
const LOOP_EXTENDS_BUILD_ARRAY = "loop.extends.build_array";
const LOOP_EXTENDS_PARSE_RESULTS = "loop.extends.parse_results";

/**
* Generate the event name for a specific loop
*
* @param string $eventName the event name
* @param string $loopName the loop name
*
* @return string the event name for the loop
*/
public static function getLoopExtendsEvent($eventName, $loopName)
{
return sprintf("%s.%s", $eventName, $loopName);
}

// -- Configuration management ---------------------------------------------

const CONFIG_CREATE = "action.createConfig";
Expand Down