ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
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 PageMetricsRepository $pageMetricsRepository, private 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 33 of file PageMetricsService.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 35 of file PageMetricsService.php.

38  {
39  }

Member Function Documentation

◆ doesPageExistsForLanguage()

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

Definition at line 41 of file PageMetricsService.php.

References ilPageObject\_exists().

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

41  : bool
42  {
43  return ilContentPagePage::_exists(self::OBJ_TYPE, $contentPageId, $language, true);
44  }
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 46 of file PageMetricsService.php.

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

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

46  : void
47  {
48  if (!$this->doesPageExistsForLanguage($contentPageId, $language)) {
49  $pageObject = new ilContentPagePage();
50  $pageObject->setParentId($contentPageId);
51  $pageObject->setId($contentPageId);
52  $pageObject->setLanguage($language);
53  $pageObject->createFromXML();
54  }
55  }
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 87 of file PageMetricsService.php.

87  : PageMetrics
88  {
89  return $this->pageMetricsRepository->findBy(
90  $command->getContentPageId(),
91  $command->getContentPageId(),
92  $command->getLanguage()
93  );
94  }

◆ store()

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

Definition at line 60 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().

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

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