Skip to content

Commit

Permalink
Build script
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyklapatch committed Jul 30, 2018
1 parent 3b2483e commit f129a21
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
31 changes: 30 additions & 1 deletion _build/build.transport.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ function getSnippetContent($filename = '') {
return $o;
}

function getChunkContent($filename)
{
$o = file_get_contents($filename);
return $o;
}

$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
Expand All @@ -21,7 +27,7 @@ function getSnippetContent($filename = '') {

if (!defined('MOREPROVIDER_BUILD')) {
/* define version */
define('PKG_NAME', 'Commerce_ProjectName');
define('PKG_NAME', 'Commerce_DigitalProduct');
define('PKG_NAMESPACE', 'commerce_digitalproduct');
define('PKG_VERSION', '1.0.0');
define('PKG_RELEASE', 'pl');
Expand Down Expand Up @@ -85,6 +91,29 @@ function getSnippetContent($filename = '') {
unset($settings,$setting,$attributes);
}

/* Create category */
$category = $modx->newObject('modCategory');
$category->set('id', 1);
$category->set('category', 'Commerce_DigitalProduct');

/* Add snippets */
$modx->log(modX::LOG_LEVEL_INFO, 'Adding in snippets.');
$snippets = include $sources['data'] . 'transport.snippets.php';
if (is_array($snippets)) {
$category->addMany($snippets);
} else {
$modx->log(modX::LOG_LEVEL_FATAL, 'Adding snippets failed.');
}

/* Add chunks */
$modx->log(modX::LOG_LEVEL_INFO, 'Adding in chunks.');
$snippets = include $sources['data'] . 'transport.chunks.php';
if (is_array($chunks)) {
$category->addMany($chunks);
} else {
$modx->log(modX::LOG_LEVEL_FATAL, 'Adding chunks failed.');
}

// Add the validator to check server requirements
$vehicle->validate('php', array('source' => $sources['validators'] . 'requirements.script.php'));

Expand Down
11 changes: 11 additions & 0 deletions _build/data/transport.chunks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

$chunks = array();
$chunks[0] = $modx->newObject('modChunk');
$chunks[0]->fromArray(array(
'id' => 0,
'name' => 'digitalproduct.file_error',
'description' => 'Default error template for Commerce Digital Product.',
'snippet' => getChunkContent($sources['source_core'] . '/elements/chunks/digitalproduct.file_error.tpl'),
), '', true, true);
return $chunks;
11 changes: 11 additions & 0 deletions _build/data/transport.snippets.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

$snippets = array();
$snippets[0] = $modx->newObject('modSnippet');
$snippets[0]->fromArray(array(
'id' => 0,
'name' => 'digitalproduct.get_file',
'description' => 'Insert into a resource uncached to get a file based on secret.',
'snippet' => getSnippetContent($sources['source_core'] . '/elements/snippets/digitalproduct.get_file.php'),
), '', true, true);
return $snippets;
11 changes: 8 additions & 3 deletions core/components/commerce_digitalproduct/docs/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
++ Digitalproduct for Commerc
++ Released on 7/19/2018
++++++++++++++++++++++++++
Digitalproduct for Commerce

1.0.0-pl Released on 7/30/2018
==============
- First public release

1.0.0-dev Released on 7/19/2018
==============
- First dev release

0 comments on commit f129a21

Please sign in to comment.