Created
July 24, 2014 12:28
-
-
Save ThaDafinser/71504f514ae615fbb4c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return array( | |
'service_manager' => array( | |
'factories' => array( | |
'DatagridManager' => 'LispBase\Mvc\Service\DatagridManagerFactory' | |
) | |
) | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Zend Framework (http://framework.zend.com/) | |
* | |
* @link http://github.com/zendframework/zf2 for the canonical source repository | |
* @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com) | |
* @license http://framework.zend.com/license/new-bsd New BSD License | |
*/ | |
namespace LispBase\ZfcDatagrid; | |
use Zend\ServiceManager\AbstractPluginManager; | |
/** | |
* Plugin manager implementation for form elements. | |
* | |
* Enforces that elements retrieved are instances of ElementInterface. | |
*/ | |
class DatagridManager extends AbstractPluginManager | |
{ | |
/** | |
* Don't share form elements by default | |
* | |
* @var bool | |
*/ | |
protected $shareByDefault = false; | |
public function validatePlugin($plugin) | |
{ | |
} | |
/** | |
* Retrieve a service from the manager by name | |
* | |
* Allows passing an array of options to use when creating the instance. | |
* createFromInvokable() will use these and pass them to the instance | |
* constructor if not null and a non-empty array. | |
* | |
* @param string $name | |
* @param string|array $options | |
* @param bool $usePeeringServiceManagers | |
* @return object | |
*/ | |
public function get($name, $options = array(), $usePeeringServiceManagers = true) | |
{ | |
$instance = new $name(); | |
$instance->setServiceLocator($this->getServiceLocator()); | |
return $instance; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace LispBase\Mvc\Service; | |
use Zend\Mvc\Service\AbstractPluginManagerFactory; | |
use Zend\Form\FormElementManager; | |
use Zend\ServiceManager\ServiceLocatorInterface; | |
class DatagridManagerFactory extends AbstractPluginManagerFactory | |
{ | |
const PLUGIN_MANAGER_CLASS = 'LispBase\ZfcDatagrid\DatagridManager'; | |
/** | |
* Create and return the MVC controller plugin manager | |
* | |
* @param ServiceLocatorInterface $serviceLocator | |
* @return FormElementManager | |
*/ | |
public function createService(ServiceLocatorInterface $serviceLocator) | |
{ | |
$plugins = parent::createService($serviceLocator); | |
$plugins->addPeeringServiceManager($serviceLocator); | |
$plugins->setRetrieveFromPeeringManagerFirst(true); | |
return $plugins; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment