Skip to content

Commit

Permalink
Remove extra indentation from classes
Browse files Browse the repository at this point in the history
  • Loading branch information
gabor-udvari committed Sep 25, 2015
1 parent 7464d05 commit abb5c60
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 160 deletions.
22 changes: 11 additions & 11 deletions Actions.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
<?php

namespace thebuggenie\modules\bootgenie;
namespace thebuggenie\modules\bootgenie;

use thebuggenie\core\framework;
use thebuggenie\core\framework;

/**
* actions for the bootgenie module
*/
class Actions extends framework\Action
{

public function runIndex(framework\Request $request)
{
}
/**
* actions for the bootgenie module
*/
class Actions extends framework\Action
{

public function runIndex(framework\Request $request)
{
}

}

279 changes: 139 additions & 140 deletions Bootgenie.php
Original file line number Diff line number Diff line change
@@ -1,167 +1,166 @@
<?php

namespace thebuggenie\modules\bootgenie;
namespace thebuggenie\modules\bootgenie;

use thebuggenie\core\framework;
use thebuggenie\core\framework;

/**
* Autogenerated module Bootgenie
*
* @author
* @version 0.1
* @license http://opensource.org/licenses/MPL-2.0 Mozilla Public License 2.0 (MPL 2.0)
* @package bootgenie
* @subpackage core
*
* @Table(name="\thebuggenie\core\entities\tables\Modules")
*/
class Bootgenie extends \thebuggenie\core\entities\Module
{

const VERSION = '0.1';

protected $_name = 'bootgenie';
protected $_longname = 'Bootgenie';
protected $_description = 'Bootgenie description here';
protected $_module_config_title = 'Bootgenie';
protected $_module_config_description = 'Set up the Bootgenie module from this section';

protected $_overridemap = ['components'=>[], 'actions'=>[]];
/**
* Autogenerated module Bootgenie
*
* @author
* @version 0.1
* @license http://opensource.org/licenses/MPL-2.0 Mozilla Public License 2.0 (MPL 2.0)
* @package bootgenie
* @subpackage core
*
* @Table(name="\thebuggenie\core\entities\tables\Modules")
*/
class Bootgenie extends \thebuggenie\core\entities\Module
{

protected $debug = false;
const VERSION = '0.1';

protected function _initialize()
{
define('BOOTGENIE_PATH', THEBUGGENIE_PATH . 'modules/bootgenie/');
protected $_name = 'bootgenie';
protected $_longname = 'Bootgenie';
protected $_description = 'Bootgenie description here';
protected $_module_config_title = 'Bootgenie';
protected $_module_config_description = 'Set up the Bootgenie module from this section';

// Add override rules
self::addOverride('main/index', 'bootgenie/main_index', 'action');
self::addOverride('main/menulinks', 'bootgenie/main_menulinks', 'component');
protected $_overridemap = ['components'=>[], 'actions'=>[]];

self::addOverride('publish/showarticle', 'bootgenie/publish_showarticle', 'action');
self::addOverride('publish/specialarticle', 'bootgenie/publish_specialarticle', 'action');
self::addOverride('publish/articledisplay', 'bootgenie/publish_articledisplay', 'component');
self::addOverride('publish/menustriplinks', 'bootgenie/publish_menustriplinks', 'component');
self::addOverride('publish/whatlinkshere', 'bootgenie/publish_whatlinkshere', 'component');
self::addOverride('publish/tools', 'bootgenie/publish_tools', 'component');
self::addOverride('publish/latestArticles', 'bootgenie/publish_latestArticles', 'component');
protected $debug = false;

// Disable for testing
// $this->_enabled = false;
}
protected function _initialize()
{
define('BOOTGENIE_PATH', THEBUGGENIE_PATH . 'modules/bootgenie/');

// Add override rules
self::addOverride('main/index', 'bootgenie/main_index', 'action');
self::addOverride('main/menulinks', 'bootgenie/main_menulinks', 'component');

self::addOverride('publish/showarticle', 'bootgenie/publish_showarticle', 'action');
self::addOverride('publish/specialarticle', 'bootgenie/publish_specialarticle', 'action');
self::addOverride('publish/articledisplay', 'bootgenie/publish_articledisplay', 'component');
self::addOverride('publish/menustriplinks', 'bootgenie/publish_menustriplinks', 'component');
self::addOverride('publish/whatlinkshere', 'bootgenie/publish_whatlinkshere', 'component');
self::addOverride('publish/tools', 'bootgenie/publish_tools', 'component');
self::addOverride('publish/latestArticles', 'bootgenie/publish_latestArticles', 'component');

// Disable for testing
// $this->_enabled = false;
}

protected function _addListeners()
{
if ( $this->_enabled == true ) {
// listen for renderTemplate (overwrite module action templates)
framework\Event::listen('core', 'self::performAction::renderTemplate', array($this, 'listen_renderTemplate'));
// listen for renderBegins (overwrite layout and components)
framework\Event::listen('core', '\thebuggenie\core\framework\Context::renderBegins', array($this, 'listen_renderBegins'));
}
protected function _addListeners()
{
if ( $this->_enabled == true ) {
// listen for renderTemplate (overwrite module action templates)
framework\Event::listen('core', 'self::performAction::renderTemplate', array($this, 'listen_renderTemplate'));
// listen for renderBegins (overwrite layout and components)
framework\Event::listen('core', '\thebuggenie\core\framework\Context::renderBegins', array($this, 'listen_renderBegins'));
}
}

protected function _install($scope)
{
}
protected function _install($scope)
{
}

protected function _loadFixtures($scope)
{
}
protected function _loadFixtures($scope)
{
}

protected function _uninstall()
{
}
protected function _uninstall()
{
}

/**
* Return an instance of this module
*
* @return Bootgenie
*/
public static function getModule()
{
return framework\Context::getModule('bootgenie');
}
/**
* Return an instance of this module
*
* @return Bootgenie
*/
public static function getModule()
{
return framework\Context::getModule('bootgenie');
}

/**
* Add an override rule to the override map
*
* @return NULL
*/
public function addOverride($original, $override, $type='component')
{
// $new_array = [$original => $override];
if ( $type == 'component' ){
$this->_overridemap['components'][$original] = $override;
} elseif ( $type == 'action' ){
$this->_overridemap['actions'][$original] = $override;
}
/**
* Add an override rule to the override map
*
* @return NULL
*/
public function addOverride($original, $override, $type='component')
{
// $new_array = [$original => $override];
if ( $type == 'component' ){
$this->_overridemap['components'][$original] = $override;
} elseif ( $type == 'action' ){
$this->_overridemap['actions'][$original] = $override;
}
}

/**
* Get an override map compatible with framework\Routing::setComponentOverrideMap
*
* @return array
*/
public function getComponentOverrideMap()
{
$return_array = [];
foreach($this->_overridemap['components'] as $key=>$value){
list($module, $method) = explode('/', $value);
$return_array[$key] = ['module'=>$module, 'method'=>$method];
}
return $return_array;
/**
* Get an override map compatible with framework\Routing::setComponentOverrideMap
*
* @return array
*/
public function getComponentOverrideMap()
{
$return_array = [];
foreach($this->_overridemap['components'] as $key=>$value){
list($module, $method) = explode('/', $value);
$return_array[$key] = ['module'=>$module, 'method'=>$method];
}
return $return_array;
}

/**
* Get an override map containing all the actions
*
* @return array
*/
public function getActionOverrideMap()
{
$return_array = [];
foreach($this->_overridemap['actions'] as $key=>$value){
list($class, $action) = explode('/', $key);
$return_array[$key] = ['class'=>$class, 'action'=>$action, 'template'=>$value];
}
return $return_array;
/**
* Get an override map containing all the actions
*
* @return array
*/
public function getActionOverrideMap()
{
$return_array = [];
foreach($this->_overridemap['actions'] as $key=>$value){
list($class, $action) = explode('/', $key);
$return_array[$key] = ['class'=>$class, 'action'=>$action, 'template'=>$value];
}
return $return_array;
}

/**
* Listen to the renderTemplate function and override any template
*
* @param framework\Event $event Event with the 'class' and 'action' parameters
*
* @return array
*/
public function listen_renderTemplate(framework\Event $event)
{
// set override map for components
framework\Context::getRouting()->setComponentOverrideMap( self::getComponentOverrideMap() );

// set override map for actions
$actionmap = self::getActionOverrideMap();
$template = framework\Context::getResponse()->getTemplate();
foreach( $actionmap as $value){
if ( stripos($event->getParameter('class'), $value['class']) !== FALSE && stripos($template, $value['action']) !== FALSE) {
framework\Context::getResponse()->setTemplate($value['template']);
}
/**
* Listen to the renderTemplate function and override any template
*
* @param framework\Event $event Event with the 'class' and 'action' parameters
*
* @return array
*/
public function listen_renderTemplate(framework\Event $event)
{
// set override map for components
framework\Context::getRouting()->setComponentOverrideMap( self::getComponentOverrideMap() );

// set override map for actions
$actionmap = self::getActionOverrideMap();
$template = framework\Context::getResponse()->getTemplate();
foreach( $actionmap as $value){
if ( stripos($event->getParameter('class'), $value['class']) !== FALSE && stripos($template, $value['action']) !== FALSE) {
framework\Context::getResponse()->setTemplate($value['template']);
}
$event->setProcessed();
// $event->setReturnValue(''); // not needed
}
$event->setProcessed();
// $event->setReturnValue(''); // not needed
}

public function listen_renderBegins(framework\Event $event)
{
// Set core layout path
framework\Context::getResponse()->setLayoutPath(BOOTGENIE_PATH . 'templates');

if ($this->debug) {
echo '<div class="alert alert-info" role="alert">';
echo '<p>page: '.framework\Context::getResponse()->getPage().'</p>';
echo '<p>template: '.framework\Context::getResponse()->getTemplate().'</p>';
echo '</div>';
}
public function listen_renderBegins(framework\Event $event)
{
// Set core layout path
framework\Context::getResponse()->setLayoutPath(BOOTGENIE_PATH . 'templates');

if ($this->debug) {
echo '<div class="alert alert-info" role="alert">';
echo '<p>page: '.framework\Context::getResponse()->getPage().'</p>';
echo '<p>template: '.framework\Context::getResponse()->getTemplate().'</p>';
echo '</div>';
}

}
}
17 changes: 8 additions & 9 deletions Components.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<?php

namespace thebuggenie\modules\bootgenie;
namespace thebuggenie\modules\bootgenie;

use thebuggenie\core\framework;
use thebuggenie\core\framework;

/**
* actions for the bootgenie module
*/
class Components extends framework\ActionComponent
{

}
/**
* actions for the bootgenie module
*/
class Components extends framework\ActionComponent
{

}

0 comments on commit abb5c60

Please sign in to comment.