From 3b9e70ea44c869042a0cd9e30fbf5efa635aef1d Mon Sep 17 00:00:00 2001 From: Donald Atkinson Date: Tue, 11 Aug 2015 03:49:29 -0600 Subject: [PATCH] Abstract out Package Name creation Allows for custom names in extended implementations. If it becomes desirable to include naming logic in the library, this will additionally make it easier to do so. Sample Extension: class ExtractExtra extends \Teleport\Action\Extract { protected function getName() { // No profile prefix return $this->tpl['name']; } } --- src/Teleport/Action/Extract.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/Teleport/Action/Extract.php b/src/Teleport/Action/Extract.php index 5b5f8f8..b821f8f 100644 --- a/src/Teleport/Action/Extract.php +++ b/src/Teleport/Action/Extract.php @@ -56,7 +56,7 @@ public function process() $this->tpl = $this->loadTpl($this->tpl); - $this->package = $this->createPackage($this->profile->code . '_' . $this->tpl['name'], $this->getVersion(), $this->getSequence()); + $this->package = $this->createPackage($this->getName(), $this->getVersion(), $this->getSequence()); if (isset($this->tpl['attributes'])) { foreach ($this->tpl['attributes'] as $attribute => $attributeValue) { @@ -175,6 +175,16 @@ protected function createPackage($name, $version, $release = '') return $this->package; } + /** + * Get the base Name of the Package, typically for creation of the filename. + * + * return string The base name of the Package + */ + protected function getName() + { + return $this->profile->code . '_' . $this->tpl['name']; + } + /** * Get a package version for this snapshot. *