Snippets in TextMate are a very powerful feature that can be used to insert code that you do not want to type again and again, or like in my case might have forgotten over a certain time.
The next code listing shows the snippet providing a basic custom Phing task class skeleton which can be utilized over and over at the beginning of the implementation activities.
<?phpTo apply the snippet, after installing it, on a PHP source file it can either be selected from the Bundles menue or more comfortable via the assigned tab trigger i.e. ctask. After triggering the snippet it's possible to properly name the task under development and dynamically set it's first property, which is also treated as a mandatory property in the extracted _validateProperties method.
require_once 'phing/Task.php';
class ${1:CustomName}Task extends Task
{
private \$_${2:property} = null;
/**
* @param string \$${2:property} ${3:description}
*/
public function set${2/./\u$0/}(\$${2:property})
{
\$this->_${2:property} = trim(\$${2:property});
}
/**
* Initializes the task environment if necessary
*/
public function init()
{
}
/**
* Does the task main work or delegates it
* @throws BuildException
*/
public function main()
{
\$this->_validateProperties();
}
/**
* Validates the task properties
* @throws BuildException
*/
private function _validateProperties()
{
if (is_null(\$this->_${2:property})) {
throw new BuildException('${4:message}.');
}$0
}
}
The outro image shows the above stated snippet in the TextMate Bundle Editor and it's configuration.

1 comment:
Its highly informative. I would be visiting your blog hereafter regularly to gather valuable information.
Post a Comment