php - Magento Design Patterns -


magento, imho, represents php system built on thought-out coding principles - reuseable design patterns being 1 of them. in terms of example of php system, think can considered pretty cutting edge , therefore worth considering architectural point of view.

as understand it, there many design patterns available oop developer. seeing such patterns being put use in open-source system such magento allows developer view examples of such patterns in real use , in situ, rather in examples can rather achedemic, , little misleading.

as such, wondering patterns, other ones have listed below, magento programmers have used when developing magento.

as note, understand of these patterns in place consequence of being built on zend framework, mvc / front controller being couple of them,

the obvious ones are:

factory:

$product = mage::getmodel('catalog/product'); 

singleton:

$category = mage::getsingleton('catalog/session'); 

registry:

$currentcategory = mage::registry('current_category'); 

prototype:

mage:getmodel('catalog/product')->gettypeinstance(); 

event-observer pair:

# php mage::dispatchevent('event_name', array('key'=>$value));  # config.xml <config>     <global>         <events>             <event_name>                 <observers>                     <unique_name>                         <class>class_name</class>                         <method>methodname</method>                     </unique_name>                 </observers>             </event_name>         </events>     </global> </config> 

object pool:

$id = mage::objects()->save($object); $object = mage::objects($id); 

iterator:

mage::getmodel('catalog/product')->getcollection(); 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -