Implemented Module enable/disable setting from configuration.
Implemented dependencies checking to set CMS_MODULE.is_enabled. Implemented the persistence of CMS_USER.roles
This commit is contained in:
@@ -200,29 +200,10 @@ feature -- Query: module
|
||||
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
|
||||
-- Enabled module typed `a_type', if any.
|
||||
--| usage: if attached module ({FOO_MODULE}) as mod then ...
|
||||
local
|
||||
l_type: TYPE [detachable CMS_MODULE]
|
||||
do
|
||||
across
|
||||
setup.modules as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if not Result.is_enabled then
|
||||
Result := Void
|
||||
else
|
||||
l_type := Result.generating_type
|
||||
if a_type ~ l_type then
|
||||
-- Found
|
||||
elseif
|
||||
attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type)
|
||||
then
|
||||
-- Found
|
||||
else
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
Result := setup.modules.item (a_type)
|
||||
if Result /= Void and then not Result.is_enabled then
|
||||
Result := Void
|
||||
end
|
||||
ensure
|
||||
Result /= Void implies (Result.is_enabled) -- and a_type.is_conforming_to (Result.generating_type))
|
||||
|
||||
@@ -23,11 +23,15 @@ feature -- Access
|
||||
-- Description of the module.
|
||||
|
||||
package: STRING
|
||||
--
|
||||
-- Associated package.
|
||||
-- Mostly to group modules by package/category.
|
||||
|
||||
version: STRING
|
||||
-- Version od the module?
|
||||
|
||||
dependencies: detachable LIST [TYPE [CMS_MODULE]]
|
||||
-- Optional dependencies.
|
||||
|
||||
feature {CMS_API} -- Module Initialization
|
||||
|
||||
initialize (api: CMS_API)
|
||||
@@ -42,6 +46,18 @@ feature {CMS_API} -- Module Initialization
|
||||
is_initialized: is_initialized
|
||||
end
|
||||
|
||||
add_dependency (m: TYPE [CMS_MODULE])
|
||||
local
|
||||
deps: like dependencies
|
||||
do
|
||||
deps := dependencies
|
||||
if deps = Void then
|
||||
create {ARRAYED_LIST [TYPE [CMS_MODULE]]} deps.make (1)
|
||||
dependencies := deps
|
||||
end
|
||||
deps.force (m)
|
||||
end
|
||||
|
||||
feature -- Status
|
||||
|
||||
is_initialized: BOOLEAN
|
||||
|
||||
@@ -21,6 +21,54 @@ feature {NONE} -- Initialization
|
||||
|
||||
feature -- Access
|
||||
|
||||
item (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
|
||||
-- Module typed `a_type', if any.
|
||||
--| usage: if attached {FOO_MODULE} item ({FOO_MODULE}) as mod then ...
|
||||
local
|
||||
l_type: TYPE [detachable CMS_MODULE]
|
||||
do
|
||||
across
|
||||
modules as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
l_type := Result.generating_type
|
||||
if a_type ~ l_type then
|
||||
-- Found
|
||||
elseif
|
||||
-- Hack: use conformance of type, and reverse conformance of type of type.
|
||||
attached a_type.attempt (Result) and then attached l_type.generating_type.attempt (a_type)
|
||||
then
|
||||
-- Found
|
||||
else
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
ensure
|
||||
Result /= Void implies (Result.is_enabled)
|
||||
end
|
||||
|
||||
item_by_name (a_name: READABLE_STRING_GENERAL): detachable CMS_MODULE
|
||||
-- (first) module named `a_name', if any.
|
||||
--| usage: if attached {FOO_MODULE} item_by_name ("foo") as mod then ...
|
||||
do
|
||||
across
|
||||
modules as ic
|
||||
until
|
||||
Result /= Void
|
||||
loop
|
||||
Result := ic.item
|
||||
if not a_name.is_case_insensitive_equal (Result.name) then
|
||||
Result := Void
|
||||
end
|
||||
end
|
||||
ensure
|
||||
Result /= Void implies a_name.is_case_insensitive_equal (Result.name)
|
||||
end
|
||||
|
||||
feature -- Access: iteration
|
||||
|
||||
new_cursor: INDEXABLE_ITERATION_CURSOR [CMS_MODULE]
|
||||
-- <Precursor>
|
||||
do
|
||||
@@ -77,4 +125,7 @@ feature {NONE} -- Implementation
|
||||
modules: ARRAYED_LIST [CMS_MODULE]
|
||||
-- List of available modules.
|
||||
|
||||
;note
|
||||
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user