public function fromArray($config)
 {
     if (isset($config['key'])) {
         $this->key = $config['key'];
     } else {
         $this->gitPackageConfig->error->addError('Settings - key is not set', true);
         return false;
     }
     if (isset($config['type'])) {
         $this->type = $config['type'];
     } else {
         $this->type = 'textfield';
     }
     if (isset($config['area'])) {
         $this->area = $config['area'];
     } else {
         $this->area = 'default';
     }
     if (isset($config['namespace'])) {
         $this->namespace = $config['namespace'];
     } else {
         $this->namespace = $this->gitPackageConfig->getLowCaseName();
     }
     if (isset($config['value'])) {
         $this->value = $config['value'];
     }
     return true;
 }
 public function fromArray($config)
 {
     if (isset($config['resolver'])) {
         $this->resolver->fromArray($config['resolver']);
     }
     if (isset($config['readme'])) {
         $this->readme = $config['readme'];
     }
     if (isset($config['license'])) {
         $this->license = $config['license'];
     }
     if (isset($config['changelog'])) {
         $this->changelog = $config['changelog'];
     }
     if (isset($config['setupOptions'])) {
         $this->setupOptions = $config['setupOptions'];
     }
     if (isset($config['schemaPath'])) {
         $this->schemaPath = '/' . ltrim($config['schemaPath'], '/');
     } else {
         $this->schemaPath = '/core/components/' . $this->config->getLowCaseName() . '/' . 'model/schema/' . $this->config->getLowCaseName() . '.mysql.schema.xml';
     }
     if (isset($config['attributes']) && is_array($config['attributes'])) {
         foreach ($config['attributes'] as $key => $attributes) {
             if (is_array($attributes)) {
                 $this->attributes[$key] = $attributes;
             }
         }
     }
     return true;
 }
コード例 #3
0
 private function preserveCore()
 {
     $src = $this->packagePath . $this->object->dir_name . '/core/components/' . $this->config->getLowCaseName() . '/';
     $dest = rtrim($this->modx->getOption('core_path'), '/') . '/components/' . $this->config->getLowCaseName() . '/';
     $this->modx->gitpackagemanagement->deleteDir($dest);
     $this->modx->gitpackagemanagement->recurse_copy($src, $dest);
 }
コード例 #4
0
    private function buildSchema()
    {
        $modelPath = $this->packagePath . $this->object->dir_name . "/core/components/" . $this->config->getLowCaseName() . "/" . 'model/';
        $modelPath = str_replace('\\', '/', $modelPath);
        $manager = $this->modx->getManager();
        $generator = $manager->getGenerator();
        $generator->classTemplate = <<<EOD
<?php
/**
 * [+phpdoc-package+]
 */
class [+class+] extends [+extends+] {}
?>
EOD;
        $generator->platformTemplate = <<<EOD
<?php
/**
 * [+phpdoc-package+]
 */
require_once (strtr(realpath(dirname(dirname(__FILE__))), '\\\\', '/') . '/[+class-lowercase+].class.php');
class [+class+]_[+platform+] extends [+class+] {}
?>
EOD;
        $generator->mapHeader = <<<EOD
<?php
/**
 * [+phpdoc-package+]
 */
EOD;
        $buildOptions = $this->config->getBuild();
        $generator->parseSchema($this->packagePath . $this->object->dir_name . $buildOptions->getSchemaPath(), $modelPath);
    }
コード例 #5
0
 private function removeActions()
 {
     /** @var modAction[] $actions */
     $actions = $this->modx->getCollection('modAction', array('namespace' => $this->config->getLowCaseName()));
     foreach ($actions as $action) {
         $action->remove();
     }
 }
コード例 #6
0
 /**
  * Clears MODX cache and sets placeholders
  */
 private function clearCache()
 {
     $this->modx->cacheManager->delete('system_settings/config', array('cache_key' => ''));
     $results = array();
     $partitions = array('menu' => array());
     $this->modx->cacheManager->refresh($partitions, $results);
     $this->modx->setPlaceholder('+' . $this->config->getLowCaseName() . '.core_path', $this->packageCorePath);
     $this->modx->setPlaceholder('+' . $this->config->getLowCaseName() . '.assets_path', $this->packageAssetsPath);
     $this->modx->setPlaceholder('+' . $this->config->getLowCaseName() . '.assets_url', $this->packageAssetsUrl);
 }
 protected function setProperties($properties)
 {
     foreach ($properties as $property) {
         $prop = array();
         if (isset($property['name'])) {
             $prop['name'] = $property['name'];
         } else {
             return false;
         }
         if (isset($property['description'])) {
             $prop['desc'] = $property['description'];
         } else {
             $prop['desc'] = $this->config->getLowCaseName() . '.' . strtolower($this->getName()) . '.' . $prop['name'];
         }
         if (isset($property['type'])) {
             $prop['type'] = $property['type'];
         } else {
             $prop['type'] = 'textfield';
         }
         if (isset($property['options'])) {
             $prop['options'] = $property['options'];
         } else {
             $prop['options'] = '';
         }
         if (isset($property['value'])) {
             $prop['value'] = $property['value'];
         } else {
             $prop['value'] = '';
         }
         if (isset($property['lexicon'])) {
             $prop['lexicon'] = $property['lexicon'];
         } else {
             $prop['lexicon'] = $this->config->getLowCaseName() . ':properties';
         }
         if (isset($property['area'])) {
             $prop['area'] = $property['area'];
         } else {
             $prop['area'] = '';
         }
         $this->properties[] = $prop;
     }
     return true;
 }
コード例 #8
0
 /**
  * @param string $modelPath
  * @param xPDOManager $manager
  */
 private function recreateDatabase($modelPath, $manager)
 {
     if ($this->oldConfig->getDatabase() != null) {
         $this->modx->addPackage($this->oldConfig->getLowCaseName(), $modelPath, $this->oldConfig->getDatabase()->getPrefix());
         foreach ($this->oldConfig->getDatabase()->getSimpleObjects() as $simpleObject) {
             $this->modx->loadClass($simpleObject);
         }
         foreach ($this->oldConfig->getDatabase()->getTables() as $table) {
             $manager->removeObjectContainer($table);
         }
     }
     if ($this->newConfig->getDatabase() != null) {
         $this->modx->addPackage($this->newConfig->getLowCaseName(), $modelPath, $this->newConfig->getDatabase()->getPrefix());
         foreach ($this->newConfig->getDatabase()->getSimpleObjects() as $simpleObject) {
             $this->modx->loadClass($simpleObject);
         }
         foreach ($this->newConfig->getDatabase()->getTables() as $table) {
             $manager->createObjectContainer($table);
         }
     }
 }
コード例 #9
0
 private function loadSmarty()
 {
     $this->smarty = $this->modx->getService('smarty', 'smarty.modSmarty');
     $this->smarty->setTemplatePath($this->modx->gitpackagemanagement->getOption('templatesPath') . '/gitpackagebuild/');
     $this->smarty->assign('lowercasename', $this->config->getLowCaseName());
 }