Skip to content

Commit

Permalink
feature: artifact support
Browse files Browse the repository at this point in the history
  • Loading branch information
dkarlovi committed Oct 24, 2018
1 parent 40ae28f commit d897bca
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Version20181023141014 extends AbstractPimcoreMigration
public function up(Schema $schema)
{
$processesTable = $schema->getTable("process_manager_processes");
$processesTable->addColumn("artifact", "asset", ['notnull' => true]);
$processesTable->addColumn("artifact", "integer", ["notnull" => false]);
}

/**
Expand Down
16 changes: 14 additions & 2 deletions src/ProcessManagerBundle/Model/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ public function getPercentage() {
}

/**
* @param Asset $artifact
* @param null|Asset $artifact
*/
public function setArtifact(Asset $artifact)
public function setArtifact(?Asset $artifact)
{
$this->artifact = $artifact;
}
Expand All @@ -295,4 +295,16 @@ public function getArtifact()
{
return $this->artifact;
}

/**
* @return null|int
*/
public function getArtifactId()
{
if (null === $this->artifact) {
return null;
}

return $this->artifact->getId();
}
}
17 changes: 17 additions & 0 deletions src/ProcessManagerBundle/Model/Process/Dao.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace ProcessManagerBundle\Model\Process;

use Pimcore\Model\Asset;
use Pimcore\Model\Dao\AbstractDao;

class Dao extends AbstractDao
Expand Down Expand Up @@ -71,6 +72,8 @@ public function save()

if (is_bool($value)) {
$value = (int)$value;
} elseif ($value instanceof Asset) {
$value = $value->getId();
}

$buffer[$k] = $value;
Expand All @@ -93,4 +96,18 @@ public function delete()
{
$this->db->delete($this->tableName, ['id' => $this->model->getId()]);
}

/**
* @param array $data
*/
protected function assignVariablesToModel($data)
{
foreach($data as $key => &$value) {
if ($key === "artifact") {
$value = Asset::getById($value);
}
}

$this->model->setValues($data);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ ProcessManagerBundle\Model\Process:
expose: true
type: int
groups: [List, Detailed]
artifact:
expose: true
accessor:
getter: getArtifactId
groups: [List, Detailed]
virtual_properties:
getPercentage:
serialized_name: percentage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ pimcore.plugin.processmanager.processes = Class.create({
iconCls : 'pimcore_icon_download',
tooltip: t('processmanager_artifact_download'),
handler: function(grid, rowIndex) {
var id = grid.getStore().getAt(rowIndex).get('id');
var id = grid.getStore().getAt(rowIndex).get('artifact');
pimcore.helpers.download("/admin/asset/download?id=" + id)
}.bind(this)
}
Expand Down

0 comments on commit d897bca

Please sign in to comment.