Perl::Dist::WiX::Fragment::CreateFolder - A <Fragment> tag that creates a folder.


Perl-Dist-WiX documentation Contained in the Perl-Dist-WiX distribution.

Index


Code Index:

NAME

Top

Perl::Dist::WiX::Fragment::CreateFolder - A <Fragment> tag that creates a folder.

VERSION

Top

This document describes Perl::Dist::WiX::Fragment::CreateFolder version 1.500.

SYNOPSIS

Top

	my $fragment = Perl::Dist::WiX::Fragment::CreateFolder->new(
		directory_id => 'Cpan',       # Must be the ID of an already existing directory.
		id           => 'CPANFolder', # Used to create the ID of the CreateFolder object
	);

DESCRIPTION

Top

This object defines a <Fragment> tag that contains the other tags required in order to create a folder when the MSI is installed.

METHODS

Top

This class inherits from WiX3::XML::Fragment and shares its API.

There are no additional routines added.

new

The new constructor takes a series of parameters, validates then and returns a new Perl::Dist::WiX::Fragment::Environment object.

It inherits all the parameters described in the WiX3::XML::Fragment->new() method documentation.

It also adds one more required parameter, documented below.

directory_id

The id of the directory to create.

SUPPORT

Top

Bugs should be reported via the CPAN bug tracker at

http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Perl-Dist-WiX

For other issues, contact the author.

AUTHOR

Top

Curtis Jewell <csjewell@cpan.org>

SEE ALSO

Top

Perl::Dist::WiX

COPYRIGHT

Top


Perl-Dist-WiX documentation Contained in the Perl-Dist-WiX distribution.
package Perl::Dist::WiX::Fragment::CreateFolder;

use 5.010;
use Moose;
use Params::Util qw( _STRING  );
use MooseX::Types::Moose qw( Str );
use WiX3::XML::CreateFolder;
use WiX3::XML::DirectoryRef;
use WiX3::XML::Component;

our $VERSION = '1.500';
$VERSION =~ s/_//ms;

extends 'WiX3::XML::Fragment';
with 'WiX3::Role::Traceable';

has directory_id => (
	is       => 'ro',
	isa      => Str,
	reader   => '_get_directory_id',
	required => 1,
);


# Called by Moose::Object->new()
sub BUILDARGS {
	my $class = shift;
	my %args;

	# Process and check arguments.
	if ( @_ == 1 && 'HASH' eq ref $_[0] ) {
		%args = %{ $_[0] };
	} elsif ( 0 == @_ % 2 ) {
		%args = @_;
	} else {
		PDWiX->throw( 'Parameters incorrect (not a hashref or a hash)'
			  . ' for ::Fragment::CreateFolder' );
	}

	# ID is required for ::Fragment::CreateFolder.
	if ( not exists $args{'id'} ) {
		PDWiX::Parameter->throw(
			parameter => 'id',
			where     => '::Fragment::CreateFolder->new'
		);
	}

	return {
		id           => "Create$args{id}",
		directory_id => $args{'directory_id'} };
} ## end sub BUILDARGS



# Called by Moose::Object->new()
sub BUILD {
	my $self = shift;

	# Get the information we need.
	my $id             = $self->get_id();
	my $directory_tree = Perl::Dist::WiX::DirectoryTree->instance();

	my $directory_id = $self->_get_directory_id();
	my $directory_object =
	  $directory_tree->get_directory_object("D_$directory_id");

	# Start creating tags.
	my $tag1 = WiX3::XML::CreateFolder->new();
	my $tag2 = WiX3::XML::Component->new( id => $id );
	my $tag3 =
	  WiX3::XML::DirectoryRef->new( directory_object => $directory_object,
	  );

	# Get all the child tags correctly in the tree.
	$tag2->add_child_tag($tag1);
	$tag3->add_child_tag($tag2);
	$self->add_child_tag($tag3);

	# Announce ourselves.
	$self->trace_line( 2,
		    'Creating directory creation entry for directory '
		  . "id D_$directory_id\n" );

	return;
} ## end sub BUILD


# The fragment is already generated. No need to regenerate.
sub _regenerate { ## no critic(ProhibitUnusedPrivateSubroutines)
	return;
}

# No duplicates will be here to check.
sub _check_duplicates { ## no critic(ProhibitUnusedPrivateSubroutines)
	return;
}

no Moose;
__PACKAGE__->meta->make_immutable;

1;

__END__