install() публичный статический Метод

Install module
public static install ( Zend\ModuleManager\ModuleManager $moduleManager, string $moduleName ) : boolean | integer
$moduleManager Zend\ModuleManager\ModuleManager Module manager
$moduleName string Module Name
Результат boolean | integer
Пример #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');
 }
Пример #2
0
 /**
  * Install module
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function installAction()
 {
     $form = new ModuleForm();
     if ($this->getRequest()->isPost()) {
         $form->setData($this->getRequest()->getPost()->toArray());
         if (!$form->isValid()) {
             $this->flashMessenger()->addErrorMessage('Invalid module');
             $this->useFlashMessenger();
         } else {
             $moduleName = $form->getInputFilter()->get('module')->getValue();
             $moduleId = ModuleModel::install($this->getServiceLocator()->get('CustomModules'), $moduleName);
             if ($moduleId === false) {
                 $this->flashMessenger()->addErrorMessage('Can not install this module');
                 return $this->redirect()->toRoute('module');
             } else {
                 $this->flashMessenger()->addSuccessMessage('Module installed');
                 return $this->redirect()->toRoute('module');
             }
         }
     }
     return array('form' => $form);
 }
Пример #3
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();
     ModuleModel::install(Registry::get('Application')->getServiceManager()->get('CustomModules'), 'Social');
 }
Пример #4
0
 /**
  * Insert data into database
  *
  * @param \Zend\Db\Adapter\Adapter $dbAdapter Database adapter
  * @param string                   $template  Template name
  * @param string                   $sqlType   Sql database type
  *
  * @return \Zend\View\Model\JsonModel|null
  */
 protected function installTemplate($dbAdapter, $template, $sqlType)
 {
     $templatePath = GC_APPLICATION_PATH . sprintf('/data/install/design/%s', $template);
     $info = new Info();
     $info->fromFile($templatePath . '/design.info');
     $filePath = sprintf('%s/sql/%s.sql', $templatePath, $sqlType);
     if (!file_exists($filePath)) {
         return $this->returnJson(array('success' => false, 'message' => sprintf('Could not find data for this template and driver: Driver %s, path %s', $sqlType, $templatePath)));
     }
     $designInfos = $info->getInfos();
     if (!empty($designInfos['modules'])) {
         $modules = $this->getServiceLocator()->get('CustomModules');
         foreach ($designInfos['modules'] as $module) {
             ModuleModel::install($modules, $module);
         }
     }
     $sql = file_get_contents($filePath);
     $dbAdapter->getDriver()->getConnection()->getResource()->exec($sql);
     File::copyDirectory($templatePath . '/frontend', GC_PUBLIC_PATH . '/frontend');
     if (file_exists($templatePath . '/files')) {
         File::copyDirectory($templatePath . '/files', GC_MEDIA_PATH . '/files');
     }
     File::copyDirectory($templatePath . '/templates', GC_APPLICATION_PATH . '/templates');
 }
Пример #5
0
 /**
  * Test
  *
  * @return void
  */
 public function testInstallAndUninstall()
 {
     $modules = Registry::get('Application')->getServiceManager()->get('CustomModules');
     Model::uninstall($modules->getModule('Blog'), Model::fromName('Blog'));
     $this->assertInternalType('integer', (int) Model::install($modules, 'Blog'));
     $this->assertTrue(Model::uninstall($modules->getModule('Blog'), Model::fromName('Blog')));
 }