I am new in Yii. And some things in this framework i am understand well. But i am can't understand how work Yii::app() and where i can find Yii::app()->user->checkAccess method?
Should you are explain me it. Thanks!
Yii::app()->user is the user component, which is defined in your config file (usually /protected/config/main.php). In the components array you will find a 'user' component. The default class for this is CWebUser, so probably 'checkAccess' is defined in CWebUser (did not check this though).
You can write your own class extending CWebUser if you want to override this property (it's not a method).
See your /protected/config/main.php file, and then you may find authManager section in components. In my case, I set the class of authManager to CDbAuthManager. In that class, checkAccess method is defined.
Related
Hi there I have asked this on Gitter, but hope that someone here may be able to help.
I have two different routes that have the same moduleId. I have also set up a setting object within the routes with some data to differentiate what gets rendered. Everything works fine when I navigate to one of these routes from somewhere else, but if I navigate from one to the other neither the constructor or the activate are fired. am i missing something??
I had this problem and it took me a while to find a solution - this should help you I hope;
You need to add the determineActivationStrategy() method into your class, and then return as below.
import {activationStrategy} from "aurelia-router";
export class ExampleViewModel {
determineActivationStrategy() {
return activationStrategy.replace;
}
}
This will force the VM to be replaced when you're routing to it from itself.
Here's some more info on the different Activation Strategy types;
activationStrategy.no-change – reuse instance with no lifecycle events
activationStrategy.invokeLifecycle – call lifecycle methods on the ViewModel instance each time the route switches
activationStrategy.replace – construct new instance of ViewModel and invoke full lifecycle on it
Taken from here ZombieCodeKill - Aurelia Routing Beyond the Basics
Found the answer here :) Although not a complete fix out of the box, the implementation is possible
It's come up several times that I have wanted to access a property of a component which is bound to another property. I've spent days trying to figure out how to do this and failed. Below is a simple example of what I'm trying to do.
TabView {
Component.onCompleted: console.log(style.frameOverlap)
// OR tvStyle.frameOverlap
style: TabViewStyle {
id: tvStyle
frameOverlap: 5
}
}
Nothing like this works. I'm completely baffled about how to access these members either statically or as an instance. Can someone please explain to me whether something like this is possible?
Thanks.
The short answer is that you need to write:
Component.onCompleted: console.log(__styleItem.frameOverlap)
The longer answer is that the 'style' property is a Component. Component is something that remembers a tree of declarations, and can create objects as needed. However, it does not expose that remembered declaration, so when you try to access the frameOverlap property, it's not there.
In theory, you can call style.createObject to create an object, and examine its properties, but that would create another unnecessary instance, so you can look at TabView.qml, notice that it creates an instance already using Loader, and stores that in a property called __styleItem, and so use the code I gave above.
Of course, accessing internal properties is not a particularly good idea, but might be OK in practice. Ideally, one should be able to instantiate TabViewStyle and bind the instance to the style property, with TabView figuring out whether it's Component or object, but I'm not sure it's possible.
I'm working on styling the breadcrumb module.
Am I able to remove this class: RadSiteMap? I'd like to add my own styles to it.
I'm not sure you can remove that particular class, because I believe it is automatically generated by the control as it renders (you'd have to inherit from it and override this behavior, and even then I'm not sure it's possible).
your best bet is to use CSS to override that class properties. What you can do however, is use an external template (http://www.sitefinity.com/blogs/joshmorales/posts/josh-morales-blog/2011/05/10/mapping_external_templates_for_sitefinity_4_widgets) which will allow you to change the default CSS styles applied to the control (for breadcrum it has a wrapper class of "sfBreadcrumbWrp" and label class of "sfBreadcrumbLabel"
These are defined right in the template and can be changed as needed.
I hope this is helpful!
A Java class has properties and methods for manipulating those properties. An ExtJS class has properties, methods and configOptions.
Conceptually, what is the difference between configOptions and properties? Why we need both?
As per my understanding…
configs - are passed in the constructor, which defines behavior of the class, configs should not be changed at run-time because it will not have any effect, suppose you need to specify a title for the panel then you can add a config e.g. { title : 'some title' } that will be used by panel to set title of the panel at render time, but after that, even if you try to change title, you can't alter the property by simply changing that config option.
properties - are used to store information which is useful for that class, this is normally not passed through constructor but should have getter and setter methods, you can change property at run-time (if setter method is defined) and class object should detect this change, there can be read only properties also which are modified by class object only we shouldn't change it all.
More Info
Sencha: Properties vs Configs, in the Ext 4 Documentation
My answer to this question is a little simplistic and idealistic. I'm afraid trying to give a full answer that covers all the subtleties is more likely to add to the confusion rather than clarifying the situation.
Config options are used to configure an object when it is created. Trying to set them as properties on the object after it has been instantiated will often have no effect.
Ext.create('Ext.panel.Panel', {
// config options go here
});
An object will have lots of properties but only the ones listed in the Properties section should be considered public properties. While there's nothing to stop you accessing the private properties you should only do it as a last resort, try to use the documented methods to manipulate them instead where possible.
// rendered is a public property used to indicate whether the panel has been rendered
if (panel.rendered) {
// could just do panel.el but that isn't a public property, so use getEl instead
var el = panel.getEl();
...
}
One reason why the lines get blurred is that objects generally copy their configs onto themselves like this:
Ext.apply(this, config);
This results in all the config options becoming private properties, at least initially. Internally classes can then manipulate those properties as appropriate but externally accessing those properties is a breach of encapsulation and should be avoided.
I would like to change existing prestashop module without copying it and creating new one. I know that it is possible to override .tpl files in prestashop, but is it possible to do same thing with php classes? For instance I would like to change blockcart so that it can be hooked on top. Since original version doesnt have that hook I need to change install() function! I can`t change original source (it would be bad idea isn't it...) file I need to override install() function by inheriting blockcart module. Is it possible to do so and where I can find example?
I use my own override to the FrontController class to allow the display of module output at arbitrary points in tpl files - this means that the module doesn't need to support a particular hook. It is implemented via a smarty plugin, so you can for example use:
{plugin module='blockcart' hook='rightColumn'}
The above will force the module to output what it would display if hooked to the right column where the above is tag inserted (which can be anywhere in any tpl file). You can "unhook" the module from the right column so that it only displays where you want it to using this technique. I have used it on a production site with great success.
There's a series of articles describing how it works (with the required code) available at:
Prestashop 1.4 Plugins
In Prestashop 1.4 you can override core classes and module templates
Today this is not possible to override a module php file but we are working on it.
in override\modules\blockcart\blockcart.php (create it if it does not exist yet)
<?php
class BlockCartOverride extends BlockCart
{
public function hookDisplayTop($params)
{
return parent::hookTop($params);
}
}
?>
like this you can override any module to be hookable on any default or custom hook.
don't forget to delete cache/class_index.php for the override to work :)
Since version 1.6.0.11 of PrestaShop, there is a new feature that allows developers to override a module’s instance classes.
Override a module’s instance class by extending it
To override a module’s instance class, you have to extend it, giving the extended class the same name and adding Override suffix:
<?php
if (!defined('_PS_VERSION_'))
exit;
class BlockUserInfoOverride extends BlockUserInfo
{
public function hookDisplayNav($params)
{
return '<div class="header_user_info"><a>Test</a></div>';
// return $this->display(__FILE__, 'nav.tpl');
}
}
Source: http://build.prestashop.com/howtos/module/how-to-override-modules/
Keep in mind that in 1.7.x era - nowadays - you can override module main classes but not controllers. To be able to override controllers you have to override the core classes (to detect any possible overrides) and then do whatever you like. Alternatively, you have to get the original files as backup and put the modified in the same place on install and the reverse procedure on uninstall.