本文整理汇总了PHP中modPackageBuilder::setPackageAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP modPackageBuilder::setPackageAttributes方法的具体用法?PHP modPackageBuilder::setPackageAttributes怎么用?PHP modPackageBuilder::setPackageAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modPackageBuilder
的用法示例。
在下文中一共展示了modPackageBuilder::setPackageAttributes方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: array
}
}
$vehicle = $builder->createVehicle($category, $attr);
/* now pack in resolvers */
$vehicle->resolve('file', array('source' => $sources['source_assets'], 'target' => "return MODX_ASSETS_PATH . 'components/';"));
$vehicle->resolve('file', array('source' => $sources['source_core'], 'target' => "return MODX_CORE_PATH . 'components/';"));
foreach ($BUILD_RESOLVERS as $resolver) {
if ($vehicle->resolve('php', array('source' => $sources['resolvers'] . 'resolve.' . $resolver . '.php'))) {
$modx->log(modX::LOG_LEVEL_INFO, 'Added resolver "' . $resolver . '" to category.');
} else {
$modx->log(modX::LOG_LEVEL_INFO, 'Could not add resolver "' . $resolver . '" to category.');
}
}
flush();
$builder->putVehicle($vehicle);
$builder->setPackageAttributes(array('changelog' => file_get_contents($sources['docs'] . 'changelog.txt'), 'license' => file_get_contents($sources['docs'] . 'license.txt'), 'readme' => file_get_contents($sources['docs'] . 'readme.txt')));
$modx->log(modX::LOG_LEVEL_INFO, 'Added package attributes and setup options.');
/* zip up package */
$modx->log(modX::LOG_LEVEL_INFO, 'Packing up transport package zip...');
$builder->pack();
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
$signature = $builder->getSignature();
$signature = $builder->getSignature();
if (defined('PKG_AUTO_INSTALL') && PKG_AUTO_INSTALL) {
$sig = explode('-', $signature);
$versionSignature = explode('.', $sig[1]);
示例2: array
} else {
$attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false);
foreach ($settings as $setting) {
$vehicle = $builder->createVehicle($setting, $attributes);
$builder->putVehicle($vehicle);
}
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in ' . count($settings) . ' System Settings.');
}
unset($settings, $setting, $attributes);
//-- ADD IN THE CONTEXT MENU ITEMS
$modx->log(modX::LOG_LEVEL_INFO, 'Packaging in menu...');
$menu = (include $sources['data'] . 'transport.menu.php');
if (empty($menu)) {
$modx->log(modX::LOG_LEVEL_ERROR, 'Could not package in menu.');
}
$vehicle = $builder->createVehicle($menu, array(xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => true, xPDOTransport::UNIQUE_KEY => 'text', xPDOTransport::RELATED_OBJECTS => true, xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array('Action' => array(xPDOTransport::PRESERVE_KEYS => false, xPDOTransport::UPDATE_OBJECT => true, xPDOTransport::UNIQUE_KEY => array('namespace', 'controller')))));
$modx->log(modX::LOG_LEVEL_INFO, 'Adding in PHP resolvers...');
$vehicle->resolve('php', array('source' => $sources['resolvers'] . 'resolve.tables.php'));
$builder->putVehicle($vehicle);
unset($vehicle, $menu);
//-- ADD DOCS (changelog, license) TO THE PACKAGE
$modx->log(modX::LOG_LEVEL_INFO, 'Adding package attributes and setup options...');
$builder->setPackageAttributes(array('license' => file_get_contents($sources['docs'] . 'license.txt'), 'readme' => file_get_contents($sources['docs'] . 'readme.txt'), 'changelog' => file_get_contents($sources['docs'] . 'changelog.txt'), 'setup-options' => array('source' => $sources['build'] . 'setup.options.php')));
/* zip up package */
$modx->log(modX::LOG_LEVEL_INFO, 'Packing up transport package zip...');
$builder->pack();
$tend = explode(" ", microtime());
$tend = $tend[1] + $tend[0];
$totalTime = sprintf("%2.4f s", $tend - $tstart);
$modx->log(modX::LOG_LEVEL_INFO, "\n<br />Package Built.<br />\nExecution time: {$totalTime}\n");
exit;
示例3: microtime
/* create a transport vehicle for the data object */
$vehicle = $builder->createVehicle($snippet,array(
xPDOTransport::PRESERVE_KEYS => false,
xPDOTransport::UPDATE_OBJECT => true,
xPDOTransport::UNIQUE_KEY => 'name',
));
$vehicle->resolve('file',array(
'source' => $sources['source_core'],
'target' => "return MODX_CORE_PATH . 'components/';",
));
$builder->putVehicle($vehicle);
/* now pack in the license file, readme and setup options */
$builder->setPackageAttributes(array(
'license' => file_get_contents($sources['source_core'] . '/docs/license.txt'),
'readme' => file_get_contents($sources['source_core'] . '/docs/readme.txt'),
'changelog' => file_get_contents($sources['source_core'] . '/docs/changelog.txt'),
));
/* zip up the package */
$builder->pack();
$mtime= microtime();
$mtime= explode(" ", $mtime);
$mtime= $mtime[1] + $mtime[0];
$tend= $mtime;
$totalTime= ($tend - $tstart);
$totalTime= sprintf("%2.4f s", $totalTime);
$modx->log(xPDO::LOG_LEVEL_INFO, "Package Built.");
$modx->log(xPDO::LOG_LEVEL_INFO, "Execution time: {$totalTime}");
示例4: array
$attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false);
foreach ($settings as $setting) {
$vehicle = $builder->createVehicle($setting, $attributes);
$builder->putVehicle($vehicle);
}
$modx->log(modX::LOG_LEVEL_INFO, 'Packaged in ' . count($settings) . ' System Settings.');
unset($settings, $setting, $attributes);
}
}
/* Next-to-last step - pack in the license file, readme.txt, changelog,
* and setup options
*/
$attr = array('license' => file_get_contents($sources['docs'] . 'license.txt'), 'readme' => file_get_contents($sources['docs'] . 'readme.txt'), 'changelog' => file_get_contents($sources['docs'] . 'changelog.txt'));
if (!empty($props['install.options'])) {
$attr['setup-options'] = array('source' => $sources['install_options'] . 'user.input.php');
} else {
$attr['setup-options'] = array();
}
$builder->setPackageAttributes($attr);
/* Last step - zip up the package */
$builder->pack();
/* report how long it took */
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
$modx->log(xPDO::LOG_LEVEL_INFO, "Package Built.");
$modx->log(xPDO::LOG_LEVEL_INFO, "Execution time: {$totalTime}");
exit;
示例5: array
$vehicle = $builder->createVehicle($category, $attr);
$vehicles[] = $vehicle;
/* CONTEXT */
$attr = array(xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false, xPDOTransport::UNIQUE_KEY => 'key');
$vehicle = $builder->createVehicle($context, $attr);
$vehicles[] = $vehicle;
/* USER GROUP */
$attr = array(xPDOTransport::PRESERVE_KEYS => false, xPDOTransport::UPDATE_OBJECT => false, xPDOTransport::UNIQUE_KEY => 'name');
$vehicle = $builder->createVehicle($usergroup, $attr);
$vehicles[] = $vehicle;
/* Resolve the files on the last vehicle */
$vehicle = end($vehicles);
$vehicle->resolve('file', array('source' => $sources['source_assets'], 'target' => "return MODX_ASSETS_PATH . 'components/';"));
$vehicle->resolve('file', array('source' => $sources['source_core'], 'target' => "return MODX_CORE_PATH . 'components/';"));
$vehicle->resolve('php', array('type' => 'php', 'source' => $sources['resolvers'] . 'resolver.php'));
/* Pack the vehicles*/
foreach ($vehicles as $vehicle) {
$builder->putVehicle($vehicle);
}
/* Pack in the license file, readme and setup options */
$builder->setPackageAttributes(array('license' => file_get_contents($sources['docs'] . 'LICENSE.txt'), 'readme' => file_get_contents($sources['docs'] . 'README.txt')));
/* zip up the package */
$builder->pack();
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
echo "\nExecution time: {$totalTime}\n";
exit;
示例6: array
$vehicle->resolve('file', array('source' => $sources['source_core'], 'target' => "return MODX_CORE_PATH . 'components/';"));
foreach ($BUILD_RESOLVERS as $resolver) {
if ($vehicle->resolve('php', array('source' => $sources['resolvers'] . 'resolve.' . $resolver . '.php'))) {
$modx->log(modX::LOG_LEVEL_INFO, 'Added resolver "' . $resolver . '" to category.');
} else {
$modx->log(modX::LOG_LEVEL_INFO, 'Could not add resolver "' . $resolver . '" to category.');
}
}
flush();
$builder->putVehicle($vehicle);
/* now pack in the license file, readme and setup options */
$package_attributes = array('changelog' => file_get_contents($sources['docs'] . 'changelog.txt'), 'license' => file_get_contents($sources['docs'] . 'license.txt'), 'readme' => file_get_contents($sources['docs'] . 'readme.txt'), 'chunks' => $BUILD_CHUNKS, 'setup-options' => array('source' => $sources['build'] . 'setup.options.php'));
if (file_exists($sources['build'] . 'setup.options.php')) {
$package_attributes['setup-options'] = array('source' => $sources['build'] . 'setup.options.php');
}
$builder->setPackageAttributes($package_attributes);
$modx->log(modX::LOG_LEVEL_INFO, 'Added package attributes and setup options.');
/* zip up package */
$modx->log(modX::LOG_LEVEL_INFO, 'Packing up transport package zip...');
$builder->pack();
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
$signature = $builder->getSignature();
if (defined('PKG_AUTO_INSTALL') && PKG_AUTO_INSTALL) {
$sig = explode('-', $signature);
$versionSignature = explode('.', $sig[1]);
/* @var modTransportPackage $package */
示例7: array
} else {
$modx->log(xPDO::LOG_LEVEL_ERROR, 'Could not set plugin properties.');
}
$attributes = array(xPDOTransport::UNIQUE_KEY => 'name', xPDOTransport::PRESERVE_KEYS => false, xPDOTransport::UPDATE_OBJECT => true, xPDOTransport::RELATED_OBJECTS => true, xPDOTransport::RELATED_OBJECT_ATTRIBUTES => array('PluginEvents' => array(xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false, xPDOTransport::UNIQUE_KEY => array('pluginid', 'event'))));
$vehicle = $builder->createVehicle($plugin, $attributes);
$vehicle->resolve('file', array('source' => $sources['source_assets'], 'target' => "return MODX_ASSETS_PATH . 'components/';"));
$vehicle->resolve('file', array('source' => $sources['source_core'], 'target' => "return MODX_CORE_PATH . 'components/';"));
$vehicle->resolve('php', array('source' => $sources['resolvers'] . 'resolve.whicheditor.php'));
$builder->putVehicle($vehicle);
/* load system settings */
$settings = (include $sources['data'] . 'transport.settings.php');
$attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => false);
foreach ($settings as $setting) {
$vehicle = $builder->createVehicle($setting, $attributes);
$builder->putVehicle($vehicle);
}
/* now pack in the license file, readme and setup options */
$modx->log(xPDO::LOG_LEVEL_INFO, 'Setting Package Attributes...');
flush();
$builder->setPackageAttributes(array('license' => file_get_contents($sources['docs'] . 'license.txt')));
$modx->log(xPDO::LOG_LEVEL_INFO, 'Zipping up package...');
flush();
$builder->pack();
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
$modx->log(modX::LOG_LEVEL_INFO, "\n<br />Package Built.<br />\nExecution time: {$totalTime}\n");
exit;
示例8: array
$vehicle = $builder->createVehicle($Setting, $attributes);
$builder->putVehicle($vehicle);
$Setting = $modx->newObject('modSystemSetting');
$Setting->fromArray(array('key' => 'gmarker.region', 'value' => '', 'xtype' => 'textfield', 'namespace' => PKG_NAME_LOWER, 'area' => 'default'), '', true, true);
$vehicle = $builder->createVehicle($Setting, $attributes);
$builder->putVehicle($vehicle);
//------------------------------------------------------------------------------
//! Files
//------------------------------------------------------------------------------
/*
// Assets
$vehicle->resolve('file', array(
'source' => MODX_ASSETS_PATH .'components/'.PKG_NAME_LOWER.'/assets/components/'.PKG_NAME_LOWER,
'target' => "return MODX_ASSETS_PATH . 'components/';",
));
$builder->putVehicle($vehicle);
*/
// Core: TODO - this shouldn't be hard-coded!
$vehicle->resolve('file', array('source' => MODX_ASSETS_PATH . 'components/' . PKG_NAME_LOWER . '/core/components/' . PKG_NAME_LOWER, 'target' => "return MODX_CORE_PATH . 'components/';"));
$builder->putVehicle($vehicle);
//------------------------------------------------------------------------------
//! DOCS
//------------------------------------------------------------------------------
$builder->setPackageAttributes(array('license' => file_get_contents(MODX_ASSETS_PATH . 'components/' . PKG_NAME_LOWER . '/core/components/' . PKG_NAME_LOWER . '/docs/license.txt'), 'readme' => file_get_contents(MODX_ASSETS_PATH . 'components/' . PKG_NAME_LOWER . '/core/components/' . PKG_NAME_LOWER . '/docs/readme.txt'), 'changelog' => file_get_contents(MODX_ASSETS_PATH . 'components/' . PKG_NAME_LOWER . '/core/components/' . PKG_NAME_LOWER . '/docs/changelog.txt')));
// Add everything we put into the category
$vehicle = $builder->createVehicle($Category, $cat_attributes);
$builder->putVehicle($vehicle);
// Zip up the package
$builder->pack();
echo '<br/>Package complete. Check your ' . MODX_CORE_PATH . 'packages/ directory for the newly created package.';
/*EOF*/
示例9: setPackageAttributes
public function setPackageAttributes($attributes)
{
$this->builder->setPackageAttributes($attributes);
}
示例10: build
//.........这里部分代码省略.........
if ($chunks) {
$Category->addMany($chunks);
}
if ($plugins) {
$Category->addMany($plugins);
}
if ($snippets) {
$Category->addMany($snippets);
}
if ($templates) {
$Category->addMany($templates);
}
if ($tvs) {
$Category->addMany($tvs);
}
// TODO: skip this if there are no elements
//if (empty($chunks) && empty($plugins) && empty($snippets) && empty($templates) && empty($tvs)) {
$build_attributes = array();
$build_attributes = $this->get_build_attributes($Category, 'modCategory');
$this->modx->log(modX::LOG_LEVEL_DEBUG, 'build_attributes for ' . $Category->_class . "\n" . print_r($build_attributes, true));
$vehicle = $builder->createVehicle($Category, $build_attributes);
//}
//$builder->putVehicle($vehicle);
// Files...: TODO: these need their own builder
// We package these from the temporary copies inside of repoman's cache.
// Assets
if (file_exists($this->build_assets_path) && is_dir($this->build_assets_path)) {
$this->modx->log(modX::LOG_LEVEL_INFO, 'Packing assets from ' . $this->build_assets_path);
$vehicle->resolve('file', array('source' => rtrim($this->build_assets_path, '/'), 'target' => "return MODX_ASSETS_PATH . 'components/';"));
}
// Core
if (file_exists($this->build_core_path) && is_dir($this->build_core_path)) {
$this->modx->log(modX::LOG_LEVEL_INFO, 'Packing core files from ' . $this->build_core_path);
$vehicle->resolve('file', array('source' => rtrim($this->build_core_path, '/'), 'target' => "return MODX_CORE_PATH . 'components/';"));
}
$builder->putVehicle($vehicle);
// Migrations: we attach our all-purpose resolver to handle migrations
$config = $this->config;
$config['source'] = dirname(__FILE__) . '/resolver.php';
$attributes = array('vehicle_class' => 'xPDOScriptVehicle');
$vehicle = $builder->createVehicle($config, $attributes);
$builder->putVehicle($vehicle);
// Add Version Setting
$repoman_version_build_attributes = array(xPDOTransport::UNIQUE_KEY => 'key', xPDOTransport::PRESERVE_KEYS => true, xPDOTransport::UPDATE_OBJECT => true);
$VersionSetting = $this->modx->newObject('modSystemSetting');
$VersionSetting->set('key', $this->get('namespace') . '.version');
$VersionSetting->set('value', $this->get('version'));
$VersionSetting->set('xtype', 'textfield');
$VersionSetting->set('namespace', $this->get('namespace'));
$VersionSetting->set('area', $this->get('namespace') . ':default');
$vehicle = $builder->createVehicle($VersionSetting, $repoman_version_build_attributes);
$builder->putVehicle($vehicle);
// Optionally Load Seed data
$dirs = $this->get_seed_dirs($pkg_root_dir);
foreach ($dirs as $d) {
$objects = $this->crawl_dir($d);
foreach ($objects as $classname => $info) {
foreach ($info as $k => $Obj) {
$build_attributes = $this->get_build_attributes($Obj, $classname);
$this->modx->log(modX::LOG_LEVEL_DEBUG, $classname . ' created');
$vehicle = $builder->createVehicle($Obj, $build_attributes);
$builder->putVehicle($vehicle);
}
}
}
// Package Attributes (Documents)
$dir = $this->get_docs_path($pkg_root_dir);
// defaults
$docs = array('readme' => 'This package was built using Repoman (https://github.com/craftsmancoding/repoman/)', 'changelog' => 'No change log defined.', 'license' => file_get_contents(dirname(dirname(dirname(__FILE__))) . '/docs/license.txt'));
if (file_exists($dir) && is_dir($dir)) {
$files = array();
$build_docs = $this->get('build_docs');
if (!empty($build_docs) && is_array($build_docs)) {
foreach ($build_docs as $d) {
$files[] = $dir . $d;
}
} else {
$files = glob($dir . '*.{html,txt}', GLOB_BRACE);
}
foreach ($files as $f) {
$stub = basename($f, '.txt');
$stub = basename($stub, '.html');
$docs[$stub] = file_get_contents($f);
if (strtolower($stub) == 'readme') {
$docs['readme'] = $docs['readme'] . "\n\n" . 'This package was built using Repoman (https://github.com/craftsmancoding/repoman/)';
}
$this->modx->log(modX::LOG_LEVEL_INFO, "Adding doc {$stub} from {$f}");
}
} else {
$this->modx->log(modX::LOG_LEVEL_INFO, 'No documents found in ' . $dir);
}
$builder->setPackageAttributes($docs);
// Zip up the package
$builder->pack();
$zip = strtolower($sanitized_package_name) . '-' . $this->get('version') . '-' . $this->get('release') . '.transport.zip';
$this->modx->log(modX::LOG_LEVEL_INFO, 'Build complete: ' . MODX_CORE_PATH . 'packages/' . $zip);
if (!file_exists(MODX_CORE_PATH . 'packages/' . $zip)) {
throw new Exception('Transport package not created: ' . $zip . ' Please review the logs.');
}
}
示例11: array
'source' => $sources['source_assets'],
'target' => "return MODX_ASSETS_PATH . 'components/';",
));
*/
$vehicle->resolve('file', array('source' => $sources['source_core'], 'target' => "return MODX_CORE_PATH . 'components/';"));
foreach ($BUILD_RESOLVERS as $resolver) {
if ($vehicle->resolve('php', array('source' => $sources['resolvers'] . 'resolve.' . $resolver . '.php'))) {
$modx->log(modX::LOG_LEVEL_INFO, 'Added resolver "' . $resolver . '" to category.');
} else {
$modx->log(modX::LOG_LEVEL_INFO, 'Could not add resolver "' . $resolver . '" to category.');
}
}
flush();
$builder->putVehicle($vehicle);
/* now pack in the license file, readme and setup options */
$builder->setPackageAttributes(array('changelog' => file_get_contents($sources['docs'] . 'changelog.txt'), 'license' => file_get_contents($sources['docs'] . 'license.txt'), 'readme' => file_get_contents($sources['docs'] . 'readme.txt'), 'chunks' => @$BUILD_CHUNKS, 'setup-options' => array('source' => $sources['build'] . 'setup.options.php'), 'resolve_files_remove' => false));
$modx->log(modX::LOG_LEVEL_INFO, 'Added package attributes and setup options.');
/* zip up package */
$modx->log(modX::LOG_LEVEL_INFO, 'Packing up transport package zip...');
$builder->pack();
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
$signature = $builder->getSignature();
if (defined('PKG_AUTO_INSTALL') && PKG_AUTO_INSTALL) {
$sig = explode('-', $signature);
$versionSignature = explode('.', $sig[1]);
/* @var modTransportPackage $package */