I am new to Zend and still learning.
I need to read some configuration data from the database and keep it in session. I want this data in all the pages, so I need to intercept all the request and check if the session contains the required data, if not I will fetch it from the database and put it in the session.
I would like to know the best place to put the code in. In Java we used to check that in a filter. I am guessing here I have to put this is in an Action Helper. Just wanted to check what options I have and what are the best practices.
Thanks for any suggestions.
for that purposes you may use Zend_Registry singleton class for providing accessibility of session data from every point of ZF-project. For storing session data there are also several classes, e.g. Zend_Session class
I would definitely put this in a Controller Plugin class. eg.
Application_Controllerplugins_SessConfig extends Zend_Controller_Plugin_Abstract
This way you can catch the request early on, and do whatever you want with the data...
This is another answer of mine on SSL routing, but the logic is the same for the plugin class: How to implement SSL in Zend MVC
i am about to implement a similar solution whereby an application instance (which is to be rolled out to various customers) needs certain settings-data to be editable by admin via cms and thus am storing it in the db. i am then going to retrieve and add these settings [as a sub-object] to the config class (which in turn is added to the registry in the bootstrap. this seems like the cleanest solution to me as then all config data are stored in the one place, regardless of their source being an ini file or the db.
i'd be interested to hear other opinions on how this is done.
rob ganly
Related
I have a very specific use case for AEM so maybe you have a solution or an alternative.
I'd need to be able to store the html version of the page in JCR (as it is stored in the dispatcher) so that I would be able to retrieve it in a separate API call from a different system.
Have you had this problem before, or do you have any idea how that could be achieved?
Many thanks
I would strongly suggest not to have the .html page stored inside the AEM instance as that is not core objectives of the AEM as content management system. You should use your dispatcher instance (cached files) and try to keep it on an FTP server and share the file URL with different instances as a data.
Again, please note that AEM instances are very sensitive and should mainly focus on the pages/components. In this case, you are storing the page which is generated out of the components and every time when they generated or modified you need to update this again. it will be a burden. Hence, I am suggesting to take it from the dispatcher instance which will happen as part of the publishing process.
Let me know if you have any other thoughts.
I'm developing a custom module that has to send some information to a Web Service after a Product is inserted, updated or deleted.
In order to ensure that all the fields required by the Web Service exist, I have decided that the module should be the one in charge to put them in the Product form. I achieved It by extending the commerce_product_product_form function.
But now, I have noticed that the values for the fields that I have added are not saved, so I supposed that I have to define a custom table in the module to store the additional information.
I have taken the example from AutoSKU regarding how to save and load data for Product Types form. But, what I've not found is how to do, or what are the hooks for saving and loading data for the Product form.
So, my questions are:
Is It correct what I'm thinking about creating a new table for storing the additional information that I require or can It be implemented as part of the existent routines that the commerce module handles?
If the module has to save and load the data by using a custom table, What are the hooks that I should use in order to append the form data and save It to the module tables?
If I can store the information using the commerce routines, What should be the way and/or the hooks to define the custom form fieds?
Can you tell me if there is any example about how to achieve this?, I have seen some modules but, basically all of them just modified a behavior of the existent fields, they don't add new fields, as far as I could see. The modules that I have reviewed are:
commerce_custom_product
commerce_dressing_room
commerce_fancy_attributes
commerce_tickets
I would like to achieve this by using the commerce and Drupal best practices but I need to finish this module as soon as possible. So, in the meanwhile I'll be saving the data to a custom table and loading the additional information in the commerce_product_product_form hook and saving the information in the commerce_product_save hook.
For loading the data I have tried with the hook_commerce_product_load and hook_entity_load, but for some reason the call seems never happening (I'm sending some information to Watch Dog but It's never displayed), I also have tried by clearing the cache without any change.
Any help would be appreciate.
Thanks in advanced
Are these fields going to be created during normal use of the application (hourly/daily)? Or are they only being added at the beginning (initialization process)?
If the latter, you could create an install script similar to the ones found with many, many modules out there (module-name.install).
Have you considered adding the fields to the content type?
i want to reset password using email which is defalt provided by laravel 5.
i don't have any idea or knowledge how is password reset code sent to email and use that password to do reset in laravel.
I have mail configuration correct now i want to send the user the password from email.
How to send email having password to gmail and how to put password and update password in our laravel project.
For us to really help you, it is much better if you give something a try and if it doesn't work then post the code so that we can help you debug and improve it.
To begin with, I would suggest reading the documentation on how this all works.
Next, this blog post lays the whole process out from start to finish on how to implement password reset functionality using the default files that come with Laravel. There is too much to post the whole process here so I suggest you attempt to follow it then when/if you run in to trouble then you have something that you can actually post for us to help you on.
Finally, this package provides the auth scaffold that was removed in Laravel 5 that you might find useful as it provides all the views etc for registering, logging in and resetting passwords.
Check those out, give it a go and then come back to us with specific issues that you are having and post the code that is causing the issues and we can help you much more from there.
EDIT to clarify on comments
Trait
A Trait is intended to reduce some limitations of single inheritance
by enabling a developer to reuse sets of methods freely in several
independent classes living in different class hierarchies. The
semantics of the combination of Traits and classes is defined in a way
which reduces complexity, and avoids the typical problems associated
with multiple inheritance and Mixins.
A Trait is similar to a class, but only intended to group
functionality in a fine-grained and consistent way. It is not possible
to instantiate a Trait on its own. It is an addition to traditional
inheritance and enables horizontal composition of behavior; that is,
the application of class members without requiring inheritance.
This is from the PHP docs, essentially it groups a whole load of functionality for us to use.
In this case the ResetsPasswords holds all of the actual code that resets the password and is called in to the Controller that handles this using use ResetsPasswords;.
I have resources to which I want to bind visibility for many roles of user. How can I bind the Zend_Auth with the Zend_ACL and get resources from the database.
There are more than plenty of ways to accomplish what your doing... Presuming you already have an ACL class created in your library and another class that does the actual verifying, I like to store the actual roles/resources in a config file and just load it in during bootstrap, then using the ACL class to iterate through and create the roles and resources.
Like I said there's plenty of places to find this, one would be here on SO Need guidance to start with Zend ACL
I would also suggest, that with any site you find info or a tutorial on - start with the actual documentation first: http://framework.zend.com/manual/en/learning.multiuser.html
The learning curve is the hardest boundary with it, but once your past it gets simpler.
I hope that helps even slightly.
I m trying to find the best way to build my UI based on whos logged in.
The scenario is, there are (at the moment) 2 types of user normal and super-user the super-user will normally see more controls than a normal user
I was gonna do some heavy inheritance, ie create by default SomeDialog or if super-user is logged instanciate SomeDialogSuper instead, however I have some concerns:
I find that with gwt-ext when doing a lot of inheritance you need to create a lot of panel when you are going to inject things at a later stage.
The multiple SomeDialog and then SomeDialogSuper sound like a bad idea and a nighthmare to maintain
Then I though well I could use some convention so I don't have to worry too much about which control is instantiate but I m not terribly sure how to do this
Any pointers ?
We store GUI layouts in XML "page" files stored on the server which makes requirements like yours easy to handle (use "normal_user.xml" or "superuser.xml"). The page files are marshaled into a tree of serializable factory/DTO instances that are used to create the actual widgets on the client side.
We have built a large HR portal on a framework that uses this approach. That framework is now open source. Have a look at GWT Portlets.
Use deferred binding.
http://code.google.com/support/bin/answer.py?answer=59657&topic=10211