ILIAS  release_8 Revision v8.24
ILIAS\ContentPage\PageMetrics\PageMetricsService Class Reference
+ Inheritance diagram for ILIAS\ContentPage\PageMetrics\PageMetricsService:
+ Collaboration diagram for ILIAS\ContentPage\PageMetrics\PageMetricsService:

Public Member Functions

 __construct (PageMetricsRepository $pageMetricsRepository, Factory $refinery)
 
 store (StorePageMetricsCommand $command)
 
 get (GetPageMetricsCommand $command)
 

Protected Member Functions

 doesPageExistsForLanguage (int $contentPageId, string $language)
 
 ensurePageObjectExists (int $contentPageId, string $language)
 

Private Attributes

PageMetricsRepository $pageMetricsRepository
 
Factory $refinery
 

Additional Inherited Members

- Data Fields inherited from ilContentPageObjectConstants
const OBJ_TYPE = 'copa'
 
const HTTP_PARAM_PAGE_EDITOR_STYLE_CONTEXT = 'page_editor_style'
 
const UI_CMD_VIEW = 'view'
 
const UI_CMD_EDIT = 'edit'
 
const UI_CMD_UPDATE = 'update'
 
const UI_CMD_COPAGE_DOWNLOAD_FILE = 'downloadFile'
 
const UI_CMD_COPAGE_DISPLAY_FULLSCREEN = 'displayMediaFullscreen'
 
const UI_CMD_COPAGE_DISPLAY_MEDIA = 'displayMedia'
 
const UI_CMD_COPAGE_DOWNLOAD_PARAGRAPH = 'download_paragraph'
 
const UI_CMD_COPAGE_EDIT = 'edit'
 
const UI_CMD_STYLES_EDIT = 'editStyleProperties'
 
const UI_TAB_ID_CONTENT = 'content'
 
const UI_TAB_ID_INFO = 'info_short'
 
const UI_TAB_ID_SETTINGS = 'settings'
 
const UI_TAB_ID_STYLE = 'style'
 
const UI_TAB_ID_I18N = 'i18n'
 
const UI_TAB_ID_LP = 'learning_progress'
 
const UI_TAB_ID_EXPORT = 'export'
 
const UI_TAB_ID_PERMISSIONS = 'perm_settings'
 

Detailed Description

Definition at line 37 of file PageMetricsService.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\ContentPage\PageMetrics\PageMetricsService::__construct ( PageMetricsRepository  $pageMetricsRepository,
Factory  $refinery 
)

Member Function Documentation

◆ doesPageExistsForLanguage()

ILIAS\ContentPage\PageMetrics\PageMetricsService::doesPageExistsForLanguage ( int  $contentPageId,
string  $language 
)
protected

Definition at line 48 of file PageMetricsService.php.

48 : bool
49 {
50 return ilContentPagePage::_exists(self::OBJ_TYPE, $contentPageId, $language, true);
51 }
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.

References ILIAS\ContentPage\PageMetrics\Entity\PageMetrics\$contentPageId, ILIAS\ContentPage\PageMetrics\Entity\PageMetrics\$language, and ilPageObject\_exists().

Referenced by ILIAS\ContentPage\PageMetrics\PageMetricsService\ensurePageObjectExists().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ensurePageObjectExists()

ILIAS\ContentPage\PageMetrics\PageMetricsService::ensurePageObjectExists ( int  $contentPageId,
string  $language 
)
protected

Definition at line 53 of file PageMetricsService.php.

53 : void
54 {
56 $pageObject = new ilContentPagePage();
57 $pageObject->setParentId($contentPageId);
58 $pageObject->setId($contentPageId);
59 $pageObject->setLanguage($language);
60 $pageObject->createFromXML();
61 }
62 }
doesPageExistsForLanguage(int $contentPageId, string $language)

References ILIAS\ContentPage\PageMetrics\Entity\PageMetrics\$contentPageId, ILIAS\ContentPage\PageMetrics\Entity\PageMetrics\$language, and ILIAS\ContentPage\PageMetrics\PageMetricsService\doesPageExistsForLanguage().

Referenced by ILIAS\ContentPage\PageMetrics\PageMetricsService\store().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

ILIAS\ContentPage\PageMetrics\PageMetricsService::get ( GetPageMetricsCommand  $command)
Parameters
GetPageMetricsCommand$command
Returns
PageMetrics
Exceptions
CouldNotFindPageMetrics

Definition at line 97 of file PageMetricsService.php.

97 : PageMetrics
98 {
99 return $this->pageMetricsRepository->findBy(
100 $command->getContentPageId(),
101 $command->getContentPageId(),
102 $command->getLanguage()
103 );
104 }

◆ store()

ILIAS\ContentPage\PageMetrics\PageMetricsService::store ( StorePageMetricsCommand  $command)
Parameters
StorePageMetricsCommand$command
Exceptions
ilException

Definition at line 68 of file PageMetricsService.php.

68 : void
69 {
70 $this->ensurePageObjectExists($command->getContentPageId(), $command->getLanguage());
71
72 $pageObjectGUI = new ilContentPagePageGUI($command->getContentPageId(), 0, false, $command->getLanguage());
73 $pageObjectGUI->setEnabledTabs(false);
74 $pageObjectGUI->setFileDownloadLink(ILIAS_HTTP_PATH);
75 $pageObjectGUI->setFullscreenLink(ILIAS_HTTP_PATH);
76 $pageObjectGUI->setSourcecodeDownloadScript(ILIAS_HTTP_PATH);
77 $pageObjectGUI->setProfileBackUrl(ILIAS_HTTP_PATH);
78 $text = $pageObjectGUI->getHTML();
79
80 $readingTimeTransformation = $this->refinery->string()->estimatedReadingTime();
81 $readingTime = new PageReadingTime($readingTimeTransformation->transform($text));
82
83 $pageMetrics = new PageMetrics(
84 $command->getContentPageId(),
85 $command->getContentPageId(),
86 $command->getLanguage(),
88 );
89 $this->pageMetricsRepository->store($pageMetrics);
90 }
ensurePageObjectExists(int $contentPageId, string $language)
@ilCtrl_Calls ilContentPagePageGUI: ilPageEditorGUI, ilEditClipboardGUI, ilMDEditorGUI @ilCtrl_Calls ...

References ILIAS\ContentPage\PageMetrics\Entity\PageMetrics\$readingTime, ILIAS\ContentPage\PageMetrics\PageMetricsService\ensurePageObjectExists(), ILIAS\ContentPage\PageMetrics\Command\StorePageMetricsCommand\getContentPageId(), ILIAS\ContentPage\PageMetrics\Command\StorePageMetricsCommand\getLanguage(), and ILIAS\Repository\refinery().

+ Here is the call graph for this function:

Field Documentation

◆ $pageMetricsRepository

PageMetricsRepository ILIAS\ContentPage\PageMetrics\PageMetricsService::$pageMetricsRepository
private

◆ $refinery

Factory ILIAS\ContentPage\PageMetrics\PageMetricsService::$refinery
private

The documentation for this class was generated from the following file: