Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Item13897: Pulled bootstrapping code into Foswiki::Config.
- Foswiki::Config takes bootstrapping over from Configure::Load. - Added new base base class Foswiki::AppObject which must be the base for all classess depending on initialized $Foswiki::App object. Defines app attribute and a convinience method create() which calls new() with an additional named parameter 'app'. So, an AppObject can create another AppObject using notation: $this->create('Foswiki::AppObject::Descendant', param1 => $param1, param2 => $param2, ); - Added $FOSWIKI_HOME/bin/run_app script for testing the Foswiki::App class. Temporary, will be removed later.
- Loading branch information
Showing
7 changed files
with
467 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!env perl | ||
use Cwd; | ||
use lib Cwd::abs_path("../lib"); | ||
use Foswiki::App; | ||
exit Foswiki::App->run; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# See bottom of file for license and copyright information | ||
|
||
package Foswiki::AppObject; | ||
use v5.14; | ||
|
||
=begin TML | ||
---+ Class Foswiki::AppObject; | ||
This is the base class for all classes which cannot be instantiated without | ||
active =Foswiki::App= object. | ||
=cut | ||
|
||
use Assert; | ||
use Foswiki::Exception; | ||
|
||
use Moo; | ||
use namespace::clean; | ||
extends qw(Foswiki::Object); | ||
|
||
has app => ( | ||
is => 'ro', | ||
weak_ref => 1, | ||
isa => Foswiki::Object::isaCLASS( 'app', 'Foswiki::App', noUndef => 1, ), | ||
required => 1, | ||
); | ||
|
||
=begin TML | ||
---++ ObjectMethod create($className, %initArgs) | ||
Creates a new object of =Foswiki::AppObject= based class. It's a wrapper to | ||
the =new()= constructor which automatically passes =app= parameter to the newly | ||
created object. | ||
=cut | ||
|
||
sub create { | ||
my $this = shift; | ||
my $class = shift; | ||
|
||
unless ( $class->isa(__PACKAGE__) ) { | ||
Foswiki::Exception::Fatal->throw( | ||
text => "Class $class is not a " . __PACKAGE__ . " descendant." ); | ||
} | ||
|
||
return $class->new( app => $this->app, @_ ); | ||
} | ||
|
||
1; | ||
__END__ | ||
Foswiki - The Free and Open Source Wiki, http://foswiki.org/ | ||
Copyright (C) 2013 Foswiki Contributors. Foswiki Contributors | ||
are listed in the AUTHORS file in the root of this distribution. | ||
NOTE: Please extend that file, not this notice. | ||
This program is free software; you can redistribute it and/or | ||
modify it under the terms of the GNU General Public License | ||
as published by the Free Software Foundation; either version 2 | ||
of the License, or (at your option) any later version. For | ||
more details read LICENSE in the root of this distribution. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
As per the GPL, removal of this notice is prohibited. |
Oops, something went wrong.