ILIAS  trunk Revision v11.0_alpha-1831-g8615d53dadb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ILIAS\ContentPage\PageMetrics\PageMetricsService Class Reference
+ Inheritance diagram for ILIAS\ContentPage\PageMetrics\PageMetricsService:
+ Collaboration diagram for ILIAS\ContentPage\PageMetrics\PageMetricsService:

Public Member Functions

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

Protected Member Functions

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

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'
 
const UI_TAB_ID_MD = 'meta_data'
 

Detailed Description

Definition at line 37 of file PageMetricsService.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 39 of file PageMetricsService.php.

42  {
43  }

Member Function Documentation

◆ doesPageExistsForLanguage()

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

Definition at line 45 of file PageMetricsService.php.

References ilPageObject\_exists().

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

45  : bool
46  {
47  return ilContentPagePage::_exists(self::OBJ_TYPE, $contentPageId, $language, true);
48  }
static _exists(string $a_parent_type, int $a_id, string $a_lang="", bool $a_no_cache=false)
Checks whether page exists.
+ 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 50 of file PageMetricsService.php.

References ILIAS\ContentPage\PageMetrics\PageMetricsService\doesPageExistsForLanguage().

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

50  : void
51  {
52  if (!$this->doesPageExistsForLanguage($contentPageId, $language)) {
53  $pageObject = new ilContentPagePage();
54  $pageObject->setParentId($contentPageId);
55  $pageObject->setId($contentPageId);
56  $pageObject->setLanguage($language);
57  $pageObject->createFromXML();
58  }
59  }
doesPageExistsForLanguage(int $contentPageId, string $language)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get()

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

Definition at line 91 of file PageMetricsService.php.

91  : PageMetrics
92  {
93  return $this->pageMetricsRepository->findBy(
94  $command->getContentPageId(),
95  $command->getContentPageId(),
96  $command->getLanguage()
97  );
98  }

◆ store()

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

Definition at line 64 of file PageMetricsService.php.

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

64  : void
65  {
66  $this->ensurePageObjectExists($command->getContentPageId(), $command->getLanguage());
67 
68  $pageObjectGUI = new ilContentPagePageGUI($command->getContentPageId(), 0, false, $command->getLanguage());
69  $pageObjectGUI->setEnabledTabs(false);
70  $pageObjectGUI->setFileDownloadLink(ILIAS_HTTP_PATH);
71  $pageObjectGUI->setFullscreenLink(ILIAS_HTTP_PATH);
72  $pageObjectGUI->setSourcecodeDownloadScript(ILIAS_HTTP_PATH);
73  $pageObjectGUI->setProfileBackUrl(ILIAS_HTTP_PATH);
74  $text = $pageObjectGUI->getHTML();
75 
76  $readingTimeTransformation = $this->refinery->string()->estimatedReadingTime();
77  $readingTime = new PageReadingTime($readingTimeTransformation->transform($text));
78 
79  $pageMetrics = new PageMetrics(
80  $command->getContentPageId(),
81  $command->getContentPageId(),
82  $command->getLanguage(),
83  $readingTime
84  );
85  $this->pageMetricsRepository->store($pageMetrics);
86  }
ensurePageObjectExists(int $contentPageId, string $language)
+ Here is the call graph for this function:

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