-
Notifications
You must be signed in to change notification settings - Fork 14
Conversation
@@ -22,6 +23,7 @@ | |||
'LearnZF2Authentication', | |||
'LearnZF2Captcha', | |||
'LearnZF2AjaxImageGallery', | |||
'LearnZF2Themes', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require two modules ? Themes
and LearnZF2Themes
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. Still thinking how to make it simple. Got any suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only LearnZF2Themes
@samsonasik @acelaya Would you mind doing a review? |
} | ||
?> | ||
</div> | ||
<p>This is where all the magic happens. The system retrives the theme name from the Config |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/retrives/retrieves
Sometimes I'm amazed by my stupidity and the code I write... |
$headScript->prependFile($publicDir.$file); | ||
} | ||
|
||
return new self(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update this as well as code updated.
$serviceLocator->setAllowOverride(false); | ||
} | ||
|
||
return $serviceLocator; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imo, the zf2 factory should create another instance that may pull service from serviceLocator, not a serviceLocator instance itself, @acelaya do you have some opinion about it ? I think it can be replaced by SharedEventManager, in Module class:
use LearnZF2Themes\Service\ReloadService;
$shm->attach(ReloadService::class, 'reload', function($e) use ($this->service) {
$reloadService = $e->getTarget();
// do the re-set config here..., or use attachAggregate with passed listener \
// that handle it
$reloadService->getEventManager()
->attachAggregate($this->service->get('ConfigChangerListener'));
});
in ConfigChangerListener
, we can do:
and in the LearnZF2Themes\Service\ReloadService
, we can do :
namespace LearnZF2Themes\Service;
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerAwareInterface;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\EventManagerAwareTrait;
class ReloadService implements EventManagerAwareInterface
{
use EventManagerAwareTrait;
public function reload()
{
$this->getEventManager()->trigger(__FUNCTION__, $this);
}
}
So, in controller, we can do:
$this->reloadService->reload();
more clear imo ^^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I'm a little bit disconnected on this subject. I'll take a look at
it this afternoon
Alejandro Celaya Alastrué
El 21/10/2015 10:43, "Abdul Malik Ikhsan" notifications@github.com
escribió:
In
module/LearnZF2Themes/src/LearnZF2Themes/Factory/ReloadConfigFactory.php
#158 (comment):
\* {@inheritdoc}
*/
- public function __invoke(ServiceLocatorInterface $serviceLocator)
- {
$request = $serviceLocator->get('Request');
if ($request->isPost()) {
$config = $serviceLocator->get('Config');
$themeName = $request->getPost()['themeName'];
$serviceLocator->setAllowOverride(true);
$config['theme']['name'] = $themeName;
$serviceLocator->setService('Config', $config);
$serviceLocator->setAllowOverride(false);
}
return $serviceLocator;
imo, the zf2 factory should create another instance that may pull service
from serviceLocator, not a serviceLocator instance itself, @acelaya
https://github.com/acelaya do you have some opinion about it ? I think
it can be replaced by SharedEventManager, in Module class:use LearnZF2Themes\Service\ReloadService;$shm->attach(ReloadService::class, 'reload', function($e) use ($this->service) { $reloadService = $e->getTarget(); // do the re-set config here..., or use attachAggregate with passed listener \ // that handle it $reloadService->getEventManager() ->attachAggregate($this->service->get('ConfigChangerListener'));});
in ConfigChangerListener, we can do:
and in the LearnZF2Themes\Service\ReloadService , we can do :
namespace LearnZF2Themes\Service;use Zend\EventManager\EventManager;use Zend\EventManager\EventManagerAwareInterface;use Zend\EventManager\EventManagerInterface;use Zend\EventManager\EventManagerAwareTrait;class ReloadService implements EventManagerAwareInterface { use EventManagerAwareTrait; public function reload() { $this->getEventManager()->trigger(FUNCTION, $this); }}
So, in controller, we can do:
$this->reloadService->reload();
more clear imo ^^
—
Reply to this email directly or view it on GitHub
https://github.com/sitrunlab/LearnZF2/pull/158/files#r42596990.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's ok, thank you ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could actually work. Gonna try and see. Thanks!
Bitbucket is down and travis has failed installing PhantomJS. |
usually won't take long, hopefully on your next commit, the bitbucket service back again ;) Warm regards, Abdul Malik Ikhsan Pada 21 Okt 2015, pukul 17.27, Stanimir Dimitrov notifications@github.com menulis:
|
/** | ||
* @var \Zend\getServiceManager\ServiceManager | ||
*/ | ||
private $service = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to assign to null here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like having default values, althought null is not necessery, it's more clear that the property is null by default. Odd habit.
$app = $event->getApplication(); | ||
$this->service = $app->getServiceManager(); | ||
$eventManager = $app->getEventManager(); | ||
$sharedEventManager = $app->getEventManager()->getSharedManager(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be shortcut-ed with:
$sharedEventManager = $eventManager->getSharedManager();
I implemented the module in my CMS and it took me 5 mins for the whole process. There the module loads for ~300ms. Nothing more to add. Ready for merge in no one has anything to say. |
@acelaya could you do final review before it got merged? |
I'm not probably going to be able to review it until weekend. Alejandro Celaya Alastrué
|
Ok ;), thank you ;) Warm regards, Abdul Malik Ikhsan Pada 22 Okt 2015, pukul 20.28, Alejandro Celaya notifications@github.com menulis:
|
@stanimirdim92 you're missing migration command to add this module to sql that will be generated in |
add migrations class
*/ | ||
public function up(Schema $schema) | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need sql update here, I will do during merge
Forward port #158 * stanimir/theme-switcher: (25 commits) #158 LearnZF2Themes sql add migrations class module fix feedback fixes styleci............... forgot the new unit tests... stylceci stylceci stylceci added custom event listener fixed tutorial code removed phpunit phar styleci fixes, again feedback from samsonasik added code in index.php styleci added styles, fixed theme reloading, althought it sucks with that SM in controller :X added styles, fixed theme reloading, althought it sucks with that SM in controller :X styleci fixes, config paths fixes, added 100% code coverage. styleci fixes, config paths fixes, added 100% code coverage. ...
* stanimir/theme-switcher: (25 commits) #158 LearnZF2Themes sql add migrations class module fix feedback fixes styleci............... forgot the new unit tests... stylceci stylceci stylceci added custom event listener fixed tutorial code removed phpunit phar styleci fixes, again feedback from samsonasik added code in index.php styleci added styles, fixed theme reloading, althought it sucks with that SM in controller :X added styles, fixed theme reloading, althought it sucks with that SM in controller :X styleci fixes, config paths fixes, added 100% code coverage. styleci fixes, config paths fixes, added 100% code coverage. ...
merged after rebase at db4af03 ;) |
@stanimirdim92 the module is life now http://learnzf2.sitrun-tech.com/learn-zf2-themes , thanks ;) |
Theme switcher is working now, but you have to manually refresh the page to change th text.
TODO:
unit testsFix some code bugs, better cohesion and couplingMove getConfig() logic to a factory classAdd styles for all themesSimplifyMerge both modules into one