Gc\Module\Model::install PHP Method

install() public static method

Install module
public static install ( Zend\ModuleManager\ModuleManager $moduleManager, string $moduleName ) : boolean | integer
$moduleManager Zend\ModuleManager\ModuleManager Module manager
$moduleName string Module Name
return boolean | integer
    public static function install(ModuleManager $moduleManager, $moduleName)
    {
        try {
            $object = $moduleManager->loadModule($moduleName);
        } catch (\Exception $e) {
            //Don't care
        }
        if (empty($object) or !$object->install()) {
            return false;
        }
        $model = new Model();
        $model->setName($moduleName);
        $model->save();
        $select = new Sql\Select();
        $select->from('user_acl_resource')->columns(array('id'))->where->equalTo('resource', 'modules');
        $insert = new Sql\Insert();
        $insert->into('user_acl_permission')->values(array('permission' => $moduleName, 'user_acl_resource_id' => $model->fetchOne($select)));
        $model->execute($insert);
        return $model->getId();
    }

Usage Example

Example #1
0
 /**
  * Sets up the fixture, for example, opens a network connection.
  * This method is called before a test is executed.
  *
  * @return void
  */
 public function setUp()
 {
     $this->init();
     $this->view = ViewModel::fromArray(array('name' => 'View Name', 'identifier' => 'View identifier', 'description' => 'View Description', 'content' => 'View Content'));
     $this->view->save();
     $this->layout = LayoutModel::fromArray(array('name' => 'Layout Name', 'identifier' => 'Layout identifier', 'description' => 'Layout Description', 'content' => 'Layout Content'));
     $this->layout->save();
     $this->documentType = DocumentTypeModel::fromArray(array('name' => 'Document Type Name', 'description' => 'Document Type description', 'icon_id' => 1, 'defaultview_id' => $this->view->getId(), 'user_id' => $this->user->getId()));
     $this->documentType->save();
     $this->document = DocumentModel::fromArray(array('name' => 'Document name', 'url_key' => 'url-key', 'status' => DocumentModel::STATUS_ENABLE, 'show_in_nav' => true, 'user_id' => $this->user->getId(), 'document_type_id' => $this->documentType->getId(), 'view_id' => $this->view->getId(), 'layout_id' => $this->layout->getId(), 'parent_id' => null));
     $this->document->save();
     ModuleModel::install(Registry::get('Application')->getServiceManager()->get('CustomModules'), 'Blog');
 }
All Usage Examples Of Gc\Module\Model::install