Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F56285370
Application.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
Application.php
View Options
<?php
/**
* _, __, _, _ __, _ _, _, _
* / \ |_) (_ | | \ | /_\ |\ |
* \ / |_) , ) | |_/ | | | | \|
* ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
*
* Application class
*
* @package ObsidianWorkspaces
* @subpackage Apps
* @author Sébastien Santoro aka Dereckson <dereckson@espace-win.org>
* @license http://www.opensource.org/licenses/bsd-license.php BSD
* @filesource
*/
namespace
Waystone\Workspaces\Engines\Apps
;
use
Waystone\Workspaces\Engines\Controller\Controller
;
use
Waystone\Workspaces\Engines\Errors\ErrorHandling
;
use
Waystone\Workspaces\Engines\Workspaces\WorkspaceConfiguration
;
use
Collection
;
use
Exception
;
/**
* Application class
*
* This class describes an application
*/
abstract
class
Application
extends
Controller
{
/**
* @var string The application name
*/
public
static
$name
;
/**
* @var ApplicationContext The current application context
*/
public
$context
;
/**
* @var Collection[] The collections, keys as collections roles and values as
* collections names.
*/
public
$collections
=
[];
/**
* Initializes the controller resources
*/
public
function
initialize
()
{
$this
->
collections
=
$this
->
loadCollections
();
try
{
$this
->
onAfterInitialize
();
}
catch
(
Exception
$ex
)
{
ErrorHandling
::
messageAndDie
(
GENERAL_ERROR
,
$ex
->
getMessage
(),
"Can't load application"
);
}
}
/**
* Loads the collection
*/
private
function
loadCollections
()
:
array
{
$loadedCollections
=
[];
$workspaceCollections
=
$this
->
context
->
workspace
->
configuration
->
collections
;
foreach
(
$this
->
context
->
configuration
->
useCollections
as
$role
=>
$name
)
{
if
(!
array_key_exists
(
$name
,
$workspaceCollections
))
{
$name
=
WorkspaceConfiguration
::
getCollectionNameWithPrefix
(
$this
->
context
->
workspace
,
$name
);
if
(!
array_key_exists
(
$name
,
$workspaceCollections
))
{
throw
new
Exception
(
"Collection not found: $name"
);
}
}
$loadedCollections
[
$role
]
=
Collection
::
load
(
$name
,
$workspaceCollections
[
$name
]);
}
return
$loadedCollections
;
}
protected
function
onAfterInitialize
()
:
void
{
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 6, 15:27 (4 d, 5 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4229796
Default Alt Text
Application.php (2 KB)
Attached To
Mode
rOBSIDIAN Obsidian Workspaces
Attached
Detach File
Event Timeline
Log In to Comment