Tuesday, 5 January 2016

Zend Framework 2 Service Manager

Zend Framework 2 Service Manager

Question: What is Service Manager?
Service Manager is component which have lot of services and used to set/get the service on the requirement. It implemented on "Service Locator" design Pattern.


Question: What is Service Locator?
The Service Locator is a service/object locator, which are used to retrieving other objects.


Question: What is Service Locator Pattern?
Service Locator Pattern is a design Pattern which is used to locate various services. this design pattern used by "Service Locator Service" to get the appropriate service.


Question: What are Service Factories?
Instead of getting actual object instance or a class name, We can also the ServiceManager to invoke a provided factory to get the object instance.


Question: How to create Service Factories?Giv an Example?
You can also create your own serverice factory using Zend\ServiceManager\FactoryInterface and Zend\ServiceManager\ServiceLocatorInterface.
See Example
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class MyNewFactory implements FactoryInterface
{
    public function createService(ServiceLocatorInterface $serviceLocator)
    {
  /** Return the data  

    Return the data **/  
       
    }
}

//Set the Factory
$serviceManager->setFactory('my-new-factory-name', new MyFactory()); 

//Get the Factory
$serviceManager->get('my-new-factory-name'));


Question: How to register an Object in Service manager?
$serviceManager->setService('new_obj_class1', new stdClass());
$serviceManager->setService('new_obj_class1'); // an instance of stdClass



Question: How to create aliases of any registered service?
$serviceManager->setService('my-object', $myObject);
$serviceManager->setAlias('my-alias1', 'my-object');
$serviceManager->setAlias('my-alias2', 'my-alias1')
/** my-object, my-alias1 and my-alias2 return same object **/



Question: What is use of setInvokableClass?
setInvokableClass allows you to tell the ServiceManager what class to instantiate when a particular service is requested.
$serviceManager->setInvokableClass('service-name', 'Fully\Qualified\ClassName');


Question: What is file location path Where we can set the configuration setting?
/module/module-name/config/module.config.php



Question: What are various service manager setting which we can set?
We can set abstract_factories, aliases,factories,invokables, services and shared.


Question: Give an example of service manager config?
return array(
    'service_manager' => array(
        'abstract_factories' => array(            
            'Module-Name\Service\FallbackFactory',
        ),
        'aliases' => array(            
            'SomeModule\Model\User' => 'User',            
            'AdminUser' => 'User',            
            'SuperUser' => 'AdminUser',
        ),
        'factories' => array(            
            'User'     => 'SomeModule\Service\UserFactory',
            'UserForm' => function ($serviceManager) {
            $formObject = new SomeModule\Form\User();
            $formObject->setInputFilter($serviceManager->get('UserInputFilter'));
            return $formObject;
            },
        ),
        'invokables' => array(
            'UserInputFilter' => 'SomeModule\InputFilter\User',
        ),
        'services' => array(
            // Auth is the service names
            // Values are objects
            'Auth' => new SomeModule\Authentication\AuthenticationService(),
        ),
        'shared' => array(            
            'UserForm' => false,
        ),
    ),
);





Friday, 1 January 2016

jQuery Mobile interview questions and answers

jQuery mobile interview questions and answers

jQuery Mobile is a UI framework which is written in javaScript language and used for creating mobile web applications. It works on all popular smartphones and tablets. jQuery Mobile uses HTML5 & CSS3.



What is Initial release of JQuery Mobile?
October 16, 2010


Question: What is Latest version of jQuery Mobile?
Version: 1.4.5
Dated: October 31, 2014


Question: In which language, jQuery mobile is written?
JavaScript


Question: Where it is used?
It is "Mobile application framework" which is used for creating mobile web applications.


Question: What is offical website of jQuery Mobile?
http://jquerymobile.com/


Question: What are Features of jQuery Mobile?
  • Compatible with all major desktop browsers as well as all major mobile platforms (Android, iOS, Windows Phone, Blackberry, WebOS, Symbian)
  • Built on top of jQuery core.
  • Lightweight to optimize speed.
  • The same underlying codebase will automatically scale to any screen.
  • HTML5-driven.
  • AJAX-powered navigation with animated page.
  • UI widgets



Question: Why Use jQuery Mobile?
1. Write Less, Do more
2. Its works on Android, Blackberry, iOS and Iphone
3. Its optimized


Question: Describe few HTML tags used in jQuery Mobile?
data-role="page": Page displayed in the browser.
data-role="header": Creates a toolbar at the top of the page.
data-role="main": Content of the page, like text, images, buttons and forms etc.
"ui-content": Adds extra padding and margin inside the page content
data-role="footer": creates a toolbar at the bottom of the page


Question: How to Add Back Button?
<a class="ui-btn" data-rel="back" href="https://www.blogger.com/blogger.g?blogID=5911253879674558037#">Go Back</a>


Question: What is jQuery Mobile Themeing?
jQuery Mobile provides a powerful theming that allows developers to customize color schemes & CSS aspects of UI features.