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; }
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; }
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); }
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); }
private function getResourceMap() { $rmf = $this->config->getAssetsFolder() . 'resourcemap.php'; if (is_readable($rmf)) { $content = (include $rmf); } else { $content = array(); } return $content; }
/** * @param $parent * @return GitPackageConfigCategory[] */ private function getCategoriesForParent($parent) { $categories = array(); $allCategories = $this->config->getCategories(); foreach ($allCategories as $category) { if ($category->getParent() == $parent) { $categories[] = $category; } } return $categories; }
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; }
private function removeResources() { $assetsFolder = $this->config->getAssetsFolder(); $rmf = $assetsFolder . 'resourcemap.php'; $siteStart = $this->modx->getOption('site_start'); if (is_readable($rmf)) { $resourceMap = (include $rmf); unlink($rmf); rmdir($assetsFolder); } else { $resourceMap = array(); } foreach ($resourceMap as $pageTitle => $id) { if ($id == $siteStart) { continue; } $this->modx->updateCollection('modResource', array('parent' => 0), array('parent' => $id)); $this->modx->removeObject('modResource', array('id' => $id)); } }
private function updateCategories(&$notUsedCategories) { $notUsedCategories = array_keys($this->oldConfig->getCategories()); $notUsedCategories = array_flip($notUsedCategories); /** @var GitPackageConfigCategory[] $categories */ $categories = $this->newConfig->getCategories(); foreach ($categories as $name => $category) { $catId = $this->modx->gitpackagemanagement->findCategory($category->getParents(), $this->category->id); /** @var modCategory $categoryObject */ $categoryObject = $this->modx->getObject('modCategory', $catId); if (!$categoryObject) { $categoryObject = $this->modx->newObject('modCategory'); $categoryObject->set('category', $category->getName()); } $parent = $category->getParentObject(); if (!empty($parent)) { $catId = $this->modx->gitpackagemanagement->findCategory($parent->getParents(), $this->category->id); /** @var modCategory $parentObject */ $parentObject = $this->modx->getObject('modCategory', $catId); if ($parentObject) { $parent = $parentObject->id; } else { $parent = $this->category->id; } } else { $parent = $this->category->id; } $categoryObject->set('parent', $parent); $categoryObject->save(); $this->categoriesMap[$name] = $categoryObject->id; if (isset($notUsedCategories[$name])) { unset($notUsedCategories[$name]); } } return true; }
private function setResourceMap() { $rmf = $this->config->getAssetsFolder() . 'resourcemap.php'; file_put_contents($rmf, '<?php return ' . var_export($this->resourceMap, true) . ';'); }