CMS-Drupal
view release on metacpan or search on metacpan
lib/CMS/Drupal.pm view on Meta::CPAN
'prefix' => "myapp_"
);
=head1 DESCRIPTION
This module provides a Perl interface to a Drupal CMS website.
Since you can't do anything with Drupal until you can talk to the database,
this module doesn't do anything with the constructor but return a new object.
You can get a database handle to your Drupal by calling ->dbh() with your
database credentials as parameters.
You will need the appropriate DBI driver installed to connect to your
database. The DBI will hint at what you need if you don't have it, so
long as you set the 'driver' parameter correctly.
=head1 METHODS
=head2 new
Instantiates an object in the CMS::Drupal class.
lib/CMS/Drupal.pm view on Meta::CPAN
command prompt:
$ DRUPAL_TEST_CREDS=database,foo,driver,SQLite
$ perl t/20_valid_drupal.t
=back
B<End Quote>
If you leave the environment variable set, in future you won't have to supply
any credentials when calling this module's ->dbh() method:
my $drupal = CMS::Drupal->new;
my $dbh = $drupal->dbh; # fatal error usually
It is not recommended to keep your credentials for a production database in
your environment as it's pretty easy to read it ...
=head1 SEE ALSO
=over 4
=item *
L<CMS::Drupal::Types|CMS::Drupal::Types>
lib/CMS/Drupal/Admin/MaintenanceMode.pm view on Meta::CPAN
currently in maintenance mode, and to put it into and take it out
of maintenance mode.
You might like to put the site into maintenance mode before running
a script that reads from the DB, or perhaps you would like to have
a monitoring tool able to shut off public access to the site if
something bad happens.
Note that this and all CMS::Drupal::* Perl packages interact with
the database directly, not with the website. You must have the
user credentials for your database in order to use these tools.
=head1 METHODS
=head2 maintenance_mode_check
Returns 1 if the site is currently in maintenance mode, otherwise
returns 0. Takes one argument; your active $dbh.
=head2 maintenance_mode_on
lib/CMS/Drupal/Modules.pm view on Meta::CPAN
But what about contributed modules, such as
Commerce Addressbook
We'll just pretend that it's a Commerce core module and put your Perl package in with the rest of the Commerce interface:
CMS::Drupal::Modules::Commerce::AddressBook.pm
=head1 TESTING
The parent module L<CMS::Drupal|CMS::Drupal> has a feature enabling automatic connection if your Drupal credentials are set
in the environment variable DRUPAL_TEST_CREDS ... this is not recommended for production systems
because of the obvious security risk. But it is handy for testing your module against a test database.
See the documentation for L<CMS::Drupal|CMS::Drupal> for more information.
=head1 SEE ALSO
=over 4
=item *
t/20_valid_drupal.t view on Meta::CPAN
isa_ok( $drupal, 'CMS::Drupal' );
my %params;
my $skip = 0;
if ( exists $ENV{'DRUPAL_TEST_CREDS'} ) {
%params = ( split ',', $ENV{'DRUPAL_TEST_CREDS'} );
} else {
print <<EOT;
No database credentials found in ENV.
Skipping Drupal database tests.
If you want to run these tests in the future,
set the value of DRUPAL_TEST_CREDS in your ENV as
documented in the source of this file,
$me
EOT
$skip++;
}
SKIP: {
skip "No database credentials supplied", 7, if $skip;
###########
can_ok( 'CMS::Drupal', 'dbh' );
my $dbh;
lives_ok { $dbh = $drupal->dbh( %params ) }
'Get a $dbh';
isa_ok( $dbh, "DBI::db" );
###########
t/40_admin_maintenance_mode.t view on Meta::CPAN
my $drupal = CMS::Drupal->new;
my %params;
my $skip = 0;
if ( exists $ENV{'DRUPAL_TEST_CREDS'} ) {
%params = ( split ',', $ENV{'DRUPAL_TEST_CREDS'} );
} else {
print <<EOT;
No database credentials found in ENV.
Skipping Drupal database tests.
If you want to run these tests in the future,
set the value of DRUPAL_TEST_CREDS in your ENV as
documented in the source of this file,
$me
EOT
$skip++;
}
SKIP: {
skip "No database credentials supplied", 18, if $skip;
###########
my $dbh;
lives_ok { $dbh = $drupal->dbh( %params ) } 'Get a $dbh';
isa_ok( $dbh, "DBI::db" );
my $rv1;
lives_ok {
$rv1 = $dbh->do( qq/
( run in 0.819 second using v1.01-cache-2.11-cpan-4d50c553e7e )