Version.php 24.8 KB
Newer Older
1
<?php
2 3
namespace T3o\TerFe2\Domain\Model;

4 5
/*
 * This file is part of the TYPO3 CMS project.
6
 *
7 8 9
 * It is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, either version 2
 * of the License, or any later version.
10
 *
11 12
 * For the full copyright and license information, please read the
 * LICENSE.txt file that was distributed with this source code.
13
 *
14 15
 * The TYPO3 project - inspiring people to share!
 */
16

17 18
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;

19 20 21
/**
 * Single version of an extension
 */
22
class Version extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
23 24 25 26
{

    /**
     * Title of the extension
27
     *
28 29 30
     * @var string
     * @validate NotEmpty
     */
31
    protected $title = '';
32 33 34

    /**
     * Description of the extension
35
     *
36 37
     * @var string
     */
38
    protected $description = '';
39 40 41

    /**
     * Hash of the t3x file
42
     *
43 44
     * @var string
     */
45
    protected $fileHash = '';
46 47 48

    /**
     * Author
49
     *
50
     * @var \T3o\TerFe2\Domain\Model\Author
51
     */
52
    protected $author;
53 54 55

    /**
     * The version number as integer
56
     *
57
     * @var int
58 59
     * @validate NotEmpty
     */
60
    protected $versionNumber = 0;
61 62 63

    /**
     * The version number in format "x.x.x"
64
     *
65 66 67
     * @var string
     * @validate NotEmpty
     */
68
    protected $versionString = '';
69 70 71

    /**
     * Upload date and time
72
     *
73
     * @var int
74 75
     * @validate NotEmpty
     */
76
    protected $uploadDate = 0;
77 78 79

    /**
     * The user comment for this version
80
     *
81 82
     * @var string
     */
83
    protected $uploadComment = '';
84 85 86

    /**
     * Count of downloads for this version
87
     *
88
     * @var int
89
     */
90
    protected $downloadCounter = 0;
91 92 93

    /**
     * Count of downloads for this version made in frontend
94
     *
95
     * @var int
96
     */
97
    protected $frontendDownloadCounter = 0;
98 99 100

    /**
     * State of the extension (beta, stable, obsolete, etc.)
101
     *
102 103
     * @var string
     */
104
    protected $state = '';
105 106 107

    /**
     * The category of the extension manager (frontend plugin, backend module, etc.)
108
     *
109 110
     * @var string
     */
111
    protected $emCategory = '';
112 113 114

    /**
     * Loading order in Extension Manager
115
     *
116 117
     * @var string
     */
118
    protected $loadOrder = '';
119 120 121

    /**
     * Priority
122
     *
123 124
     * @var string
     */
125
    protected $priority = '';
126 127 128

    /**
     * Information if extension is shy
129
     *
130
     * @var bool
131
     */
132
    protected $shy = false;
133 134 135

    /**
     * Internal
136
     *
137
     * @var bool
138
     */
139
    protected $internal = false;
140 141 142

    /**
     * Whether extension will be loaded in Frontend or not
143
     *
144
     * @var bool
145
     */
146
    protected $doNotLoadInFe = false;
147 148 149

    /**
     * Whether an upload folder will be created or not
150
     *
151
     * @var bool
152
     */
153
    protected $uploadfolder = false;
154 155 156

    /**
     * Whether to clear cache on load or not
157
     *
158
     * @var bool
159
     */
160
    protected $clearCacheOnLoad = false;
161 162 163

    /**
     * Module identifier
164
     *
165 166
     * @var string
     */
167
    protected $module = '';
168 169 170

    /**
     * Names of dirs to create on load
171
     *
172 173
     * @var string
     */
174
    protected $createDirs = '';
175 176 177

    /**
     * Information which existing DB tables will be modified
178
     *
179 180
     * @var string
     */
181
    protected $modifyTables = '';
182 183 184

    /**
     * Lock type
185
     *
186 187
     * @var string
     */
188
    protected $lockType = '';
189 190 191

    /**
     * CGL compliance
192
     *
193 194
     * @var string
     */
195
    protected $cglCompliance = '';
196 197 198

    /**
     * Note for the CGL compliance
199
     *
200 201
     * @var string
     */
202
    protected $cglComplianceNote = '';
203 204 205

    /**
     * Review state (-2=outdated, -1=insecure, 0=standard, 1=reviewed)
206
     *
207
     * @var int
208
     */
209
    protected $reviewState = 0;
210 211 212

    /**
     * Relation to manual object of ter_doc extension
213
     *
214 215
     * @var string
     */
216
    protected $manual = '';
217 218 219

    /**
     * Check if a manual is existing in this version
220
     *
221
     * @var bool
222
     */
223
    protected $hasManual = false;
224 225 226

    /**
     * Software relations
227
     *
228
     * @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\T3o\TerFe2\Domain\Model\Relation>
229 230
     * @lazy
     */
231
    protected $softwareRelations;
232 233 234

    /**
     * Parent extension object
235
     *
236
     * @var \T3o\TerFe2\Domain\Model\Extension
237
     */
238
    protected $extension;
239 240 241

    /**
     * Extension provider
242
     *
243 244
     * @var string
     */
245
    protected $extensionProvider = '';
246 247 248

    /**
     * Has zip file
249
     *
250
     * @var bool
251
     */
252
    protected $hasZipFile = false;
253 254 255

    /**
     * Has images
256
     *
257
     * @var bool
258
     */
259
    protected $hasImages = false;
260 261 262

    /**
     * File size of the t3x file
263
     *
264
     * @var int
265
     */
266
    protected $t3xFileSize = 0;
267 268 269

    /**
     * File size of the zip file
270
     *
271
     * @var int
272
     */
273
    protected $zipFileSize = 0;
274

275 276 277 278 279
    /**
     * @var string
     */
    protected $composerInfo = '';

280
    /**
281
     * Constructor. Initializes all ObjectStorage instances.
282 283 284
     */
    public function __construct()
    {
285
        $this->softwareRelations = new ObjectStorage();
286 287 288 289 290 291 292
    }

    /**
     * Setter for title
     *
     * @param string $title Title of the extension
     */
293
    public function setTitle(string $title)
294 295 296 297 298 299 300 301 302
    {
        $this->title = $title;
    }

    /**
     * Getter for title
     *
     * @return string Title of the extension
     */
303
    public function getTitle(): string
304 305 306 307 308 309 310 311 312
    {
        return $this->title;
    }

    /**
     * Setter for description
     *
     * @param string $description Description of the extension
     */
313
    public function setDescription(string $description)
314 315 316 317 318 319 320 321 322
    {
        $this->description = $description;
    }

    /**
     * Getter for description
     *
     * @return string Description of the extension
     */
323
    public function getDescription(): string
324 325 326 327 328 329 330 331 332
    {
        return $this->description;
    }

    /**
     * Setter for fileHash
     *
     * @param string $fileHash Hash of the t3x file
     */
333
    public function setFileHash(string $fileHash)
334 335 336 337 338 339 340 341 342
    {
        $this->fileHash = $fileHash;
    }

    /**
     * Getter for fileHash
     *
     * @return string Hash of the t3x file
     */
343
    public function getFileHash(): string
344 345 346 347 348 349 350
    {
        return $this->fileHash;
    }

    /**
     * Setter for Author
     *
351
     * @param \T3o\TerFe2\Domain\Model\Author $author Author
352
     */
353
    public function setAuthor(Author $author)
354 355 356 357 358 359 360
    {
        $this->author = $author;
    }

    /**
     * Getter for Author
     *
361
     * @return \T3o\TerFe2\Domain\Model\Author Author
362
     */
363
    public function getAuthor()
364 365 366 367 368 369 370
    {
        return $this->author;
    }

    /**
     * Setter for versionNumber
     *
371
     * @param int $versionNumber The version number
372
     */
373
    public function setVersionNumber(int $versionNumber)
374 375 376 377 378 379 380
    {
        $this->versionNumber = $versionNumber;
    }

    /**
     * Getter for versionNumber
     *
381
     * @return int The version number
382
     */
383
    public function getVersionNumber(): int
384 385 386 387 388 389 390 391 392
    {
        return $this->versionNumber;
    }

    /**
     * Setter for versionString
     *
     * @param string $versionString The version number in format "x.x.x"
     */
393
    public function setVersionString(string $versionString)
394 395 396 397 398 399 400 401 402
    {
        $this->versionString = $versionString;
    }

    /**
     * Getter for versionString
     *
     * @return string The version number in format "x.x.x"
     */
403
    public function getVersionString(): string
404 405 406 407 408 409 410
    {
        return $this->versionString;
    }

    /**
     * Setter for uploadDate
     *
411
     * @param int $uploadDate Upload date and time
412
     */
413
    public function setUploadDate(int $uploadDate)
414 415 416 417 418 419 420
    {
        $this->uploadDate = $uploadDate;
    }

    /**
     * Getter for uploadDate
     *
421
     * @return int Upload date and time
422
     */
423
    public function getUploadDate(): int
424 425 426 427 428 429 430 431 432
    {
        return $this->uploadDate;
    }

    /**
     * Setter for uploadComment
     *
     * @param string $uploadComment The user comment for this version
     */
433
    public function setUploadComment(string $uploadComment)
434 435 436 437 438 439 440 441 442
    {
        $this->uploadComment = $uploadComment;
    }

    /**
     * Getter for uploadComment
     *
     * @return string The user comment for this version
     */
443
    public function getUploadComment(): string
444 445 446 447 448 449 450
    {
        return $this->uploadComment;
    }

    /**
     * Setter for downloadCounter
     *
451
     * @param int $downloadCounter Count of downloads
452
     */
453
    public function setDownloadCounter(int $downloadCounter)
454
    {
455
        $this->downloadCounter = $downloadCounter;
456 457 458 459 460
    }

    /**
     * Increment downloadCounter
     *
461 462
     * @param int $downloads Count of downloads
     * @param bool $frontend Downloads were made in frontend
463
     */
464
    public function incrementDownloadCounter(int $downloads = 1, bool $frontend = true)
465 466
    {
        if (!empty($frontend)) {
467
            $this->frontendDownloadCounter += $downloads;
468
        } else {
469
            $this->downloadCounter += $downloads;
470 471 472 473 474 475 476
        }
        $this->extension->recalculateDownloads();
    }

    /**
     * Getter for downloadCounter
     *
477
     * @return int Count of downloads
478
     */
479
    public function getDownloadCounter(): int
480
    {
481
        return $this->downloadCounter;
482 483 484 485 486
    }

    /**
     * Setter for frontendDownloadCounter
     *
487
     * @param int $frontendDownloadCounter Download count
488
     */
489
    public function setFrontendDownloadCounter(int $frontendDownloadCounter)
490
    {
491
        $this->frontendDownloadCounter = $frontendDownloadCounter;
492 493 494 495 496
    }

    /**
     * Getter for frontendDownloadCounter
     *
497
     * @return int Download count
498
     */
499
    public function getFrontendDownloadCounter(): int
500
    {
501
        return $this->frontendDownloadCounter;
502 503 504 505 506
    }

    /**
     * Returns all downloads
     *
507
     * @return int All downloads from external source and frontend
508
     */
509
    public function getAllDownloads(): int
510 511 512
    {
        $frontendDownloads = $this->getFrontendDownloadCounter();
        $downloads = $this->getDownloadCounter();
513

514
        return $frontendDownloads + $downloads;
515 516 517 518 519 520 521
    }

    /**
     * Setter for state
     *
     * @param string $state State of the extension (beta, stable, obsolete, etc.)
     */
522
    public function setState(string $state)
523 524 525 526 527 528 529 530 531
    {
        $this->state = $state;
    }

    /**
     * Getter for state
     *
     * @return string State of the extension (beta, stable, obsolete, etc.)
     */
532
    public function getState(): string
533 534 535 536 537 538 539 540 541
    {
        return $this->state;
    }

    /**
     * Setter for emCategory
     *
     * @param string $emCategory The category of the extension manager (frontend plugin, backend module, etc.)
     */
542
    public function setEmCategory(string $emCategory)
543 544 545 546 547 548 549 550 551
    {
        $this->emCategory = $emCategory;
    }

    /**
     * Getter for emCategory
     *
     * @return string The category of the extension manager (frontend plugin, backend module, etc.)
     */
552
    public function getEmCategory(): string
553 554 555 556 557 558 559 560 561
    {
        return $this->emCategory;
    }

    /**
     * Setter for loadOrder
     *
     * @param string $loadOrder Loading order in Extension Manager
     */
562
    public function setLoadOrder(string $loadOrder)
563 564 565 566 567 568 569 570 571
    {
        $this->loadOrder = $loadOrder;
    }

    /**
     * Getter for loadOrder
     *
     * @return string Loading order in Extension Manager
     */
572
    public function getLoadOrder(): string
573 574 575 576 577 578 579 580 581
    {
        return $this->loadOrder;
    }

    /**
     * Setter for priority
     *
     * @param string $priority Priority
     */
582
    public function setPriority(string $priority)
583 584 585 586 587 588 589 590 591
    {
        $this->priority = $priority;
    }

    /**
     * Getter for priority
     *
     * @return string Priority
     */
592
    public function getPriority(): string
593 594 595 596 597 598 599
    {
        return $this->priority;
    }

    /**
     * Setter for shy
     *
600
     * @param bool $shy Information if extension is shy
601
     */
602
    public function setShy(bool $shy)
603
    {
604
        $this->shy = $shy;
605 606 607 608 609
    }

    /**
     * Getter for shy
     *
610
     * @return bool Information if extension is shy
611
     */
612
    public function getShy(): bool
613 614 615 616 617 618 619
    {
        return $this->shy;
    }

    /**
     * Setter for internal
     *
620
     * @param bool $internal Internal
621
     */
622
    public function setInternal(bool $internal)
623
    {
624
        $this->internal = $internal;
625 626 627 628 629
    }

    /**
     * Getter for internal
     *
630
     * @return bool Internal
631
     */
632
    public function getInternal(): bool
633 634 635 636 637 638 639 640 641
    {
        return $this->internal;
    }

    /**
     * Setter for module
     *
     * @param string $module Module identifier
     */
642
    public function setModule(string $module)
643 644 645 646 647 648 649 650 651
    {
        $this->module = $module;
    }

    /**
     * Getter for module
     *
     * @return string Module identifier
     */
652
    public function getModule(): string
653 654 655 656 657 658 659
    {
        return $this->module;
    }

    /**
     * Setter for doNotLoadInFe
     *
660
     * @param bool $doNotLoadInFe Whether extension will be loaded in Frontend or not
661
     */
662
    public function setDoNotLoadInFe(bool $doNotLoadInFe)
663
    {
664
        $this->doNotLoadInFe = $doNotLoadInFe;
665 666 667 668 669
    }

    /**
     * Getter for doNotLoadInFe
     *
670
     * @return bool Whether extension will be loaded in Frontend or not
671
     */
672
    public function getDoNotLoadInFe(): bool
673 674 675 676 677 678 679
    {
        return $this->doNotLoadInFe;
    }

    /**
     * Setter for uploadfolder
     *
680
     * @param bool $uploadfolder Whether an upload folder will be created or not
681
     */
682
    public function setUploadfolder(bool $uploadfolder)
683
    {
684
        $this->uploadfolder = $uploadfolder;
685 686 687 688 689
    }

    /**
     * Getter for uploadfolder
     *
690
     * @return bool Whether an upload folder will be created or not
691
     */
692
    public function getUploadfolder(): bool
693 694 695 696 697 698 699 700 701
    {
        return $this->uploadfolder;
    }

    /**
     * Setter for createDirs
     *
     * @param string $createDirs Names of dirs to create on load
     */
702
    public function setCreateDirs(string $createDirs)
703 704 705 706 707 708 709 710 711
    {
        $this->createDirs = $createDirs;
    }

    /**
     * Getter for createDirs
     *
     * @return string Names of dirs to create on load
     */
712
    public function getCreateDirs(): string
713 714 715 716 717 718 719 720 721
    {
        return $this->createDirs;
    }

    /**
     * Setter for modifyTables
     *
     * @param string $modifyTables Information which existing DB tables will be modified
     */
722
    public function setModifyTables(string $modifyTables)
723 724 725 726 727 728 729 730 731
    {
        $this->modifyTables = $modifyTables;
    }

    /**
     * Getter for modifyTables
     *
     * @return string Information which existing DB tables will be modified
     */
732
    public function getModifyTables(): string
733 734 735 736 737 738 739
    {
        return $this->modifyTables;
    }

    /**
     * Setter for clearCacheOnLoad
     *
740
     * @param bool $clearCacheOnLoad Whether to clear cache on load or not
741
     */
742
    public function setClearCacheOnLoad(bool $clearCacheOnLoad)
743
    {
744
        $this->clearCacheOnLoad = $clearCacheOnLoad;
745 746 747 748 749
    }

    /**
     * Getter for clearCacheOnLoad
     *
750
     * @return bool Whether to clear cache on load or not
751
     */
752
    public function getClearCacheOnLoad(): bool
753 754 755 756 757 758 759 760 761
    {
        return $this->clearCacheOnLoad;
    }

    /**
     * Setter for lockType
     *
     * @param string $lockType Lock type
     */
762
    public function setLockType(string $lockType)
763 764 765 766 767 768 769 770 771
    {
        $this->lockType = $lockType;
    }

    /**
     * Getter for lockType
     *
     * @return string Lock type
     */
772
    public function getLockType(): string
773 774 775 776 777 778 779 780 781
    {
        return $this->lockType;
    }

    /**
     * Setter for cglCompliance
     *
     * @param string $cglCompliance CGL compliance
     */
782
    public function setCglCompliance(string $cglCompliance)
783 784 785 786 787 788 789 790 791
    {
        $this->cglCompliance = $cglCompliance;
    }

    /**
     * Getter for cglCompliance
     *
     * @return string CGL compliance
     */
792
    public function getCglCompliance(): string
793 794 795 796 797 798 799 800 801
    {
        return $this->cglCompliance;
    }

    /**
     * Setter for cglComplianceNote
     *
     * @param string $cglComplianceNote Note for the CGL compliance
     */
802
    public function setCglComplianceNote(string $cglComplianceNote)
803 804 805 806 807 808 809 810 811
    {
        $this->cglComplianceNote = $cglComplianceNote;
    }

    /**
     * Getter for cglComplianceNote
     *
     * @return string Note for the CGL compliance
     */
812
    public function getCglComplianceNote(): string
813 814 815 816 817 818 819
    {
        return $this->cglComplianceNote;
    }

    /**
     * Setter for reviewState
     *
820
     * @param int $reviewState Review state
821
     */
822
    public function setReviewState(int $reviewState)
823 824 825 826 827 828 829
    {
        $this->reviewState = $reviewState;
    }

    /**
     * Getter for reviewState
     *
830
     * @return int Review state
831
     */
832
    public function getReviewState(): int
833
    {
834
        return $this->reviewState;
835 836 837 838 839 840 841
    }

    /**
     * Setter for manual
     *
     * @param string $manual Relation to manual object of ter_doc extension
     */
842
    public function setManual(string $manual)
843 844 845 846 847 848 849 850 851
    {
        $this->manual = $manual;
    }

    /**
     * Getter for manual
     *
     * @return string Relation to manual object of ter_doc extension
     */
852
    public function getManual(): string
853 854 855 856 857 858 859
    {
        return $this->manual;
    }

    /**
     * Setter for has_manual
     *
860
     * @param bool $hasManual Check if version has manual
861
     */
862
    public function setHasManual(bool $hasManual)
863
    {
864
        $this->hasManual = $hasManual;
865 866 867 868 869
    }

    /**
     * Getter for has_manual
     *
870
     * @return bool $hasManual Check if version has manual
871
     */
872
    public function getHasManual(): bool
873 874 875 876 877 878 879
    {
        return $this->hasManual;
    }

    /**
     * Setter for softwareRelations
     *
880
     * @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage $softwareRelations Relations
881
     */
882
    public function setSoftwareRelations(ObjectStorage $softwareRelations)
883 884 885 886 887 888 889
    {
        $this->softwareRelations = $softwareRelations;
    }

    /**
     * Getter for softwareRelations
     *
890
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage Relations
891
     */
892
    public function getSoftwareRelations(): ObjectStorage
893 894 895 896 897 898 899 900 901
    {
        return $this->softwareRelations;
    }

    /**
     * Get filtered relations
     *
     * @return array Relations
     */
902
    public function getFilteredSoftwareRelations(): array
903 904
    {
        if (empty($this->softwareRelations)) {
905
            return [];
906 907
        }

908
        $relations = [];
909 910 911 912 913 914 915 916 917 918 919 920 921 922

        foreach ($this->softwareRelations as $relation) {
            $relationKey = $relation->getRelationKey();
            if (!empty($relationKey)) {
                $relations[] = $relation;
            }
        }

        return $relations;
    }

    /**
     * Adds a relation
     *
923
     * @param \T3o\TerFe2\Domain\Model\Relation $softwareRelation The relation to be added
924
     */
925
    public function addSoftwareRelation(Relation $softwareRelation)
926 927 928 929 930 931 932 933 934
    {
        $this->softwareRelations->attach($softwareRelation);
        // @todo implement the missing method
        //$this->buildSoftwareRelationList($this->softwareRelations);
    }

    /**
     * Removes a relation
     *
935
     * @param \T3o\TerFe2\Domain\Model\Relation $softwareRelation The relation to be removed
936
     */
937
    public function removeSoftwareRelation(Relation $softwareRelation)
938 939 940 941 942 943 944 945 946
    {
        $this->softwareRelations->detach($softwareRelation);
        // @todo implement the missing method
        // $this->buildSoftwareRelationList($this->softwareRelations);
    }

    /**
     * Returns all software relations which are conflicts
     *
947
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $conflicts
948
     */
949
    public function getConflicts(): ObjectStorage
950
    {
951
        $conflicts = new ObjectStorage();
952
        foreach ($this->getSoftwareRelations() as $softwareRelation) {
953
            /** @var \T3o\TerFe2\Domain\Model\Relation $softwareRelation */
954 955 956 957 958
            $relationKey = $softwareRelation->getRelationKey();
            if ($softwareRelation->getRelationType() == 'conflicts' and !empty($relationKey)) {
                $conflicts->attach($softwareRelation);
            }
        }
959

960 961 962 963 964 965
        return $conflicts;
    }

    /**
     * Returns all software relations which are dependencies
     *
966
     * @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage $dependencies
967
     */
968
    public function getDependencies(): ObjectStorage
969
    {
970
        $dependencies = new ObjectStorage();
971
        foreach ($this->getSoftwareRelations() as $softwareRelation) {
972
            /** @var \T3o\TerFe2\Domain\Model\Relation $softwareRelation */
973 974 975 976 977
            $relationKey = $softwareRelation->getRelationKey();
            if ($softwareRelation->getRelationType() == 'depends' and !empty($relationKey)) {
                $dependencies->attach($softwareRelation);
            }
        }
978

979 980 981 982 983 984
        return $dependencies;
    }

    /**
     * Setter for extension
     *
985
     * @param \T3o\TerFe2\Domain\Model\Extension $extension extension
986
     */
987
    public function setExtension(Extension $extension)
988 989 990 991 992 993 994
    {
        $this->extension = $extension;
    }

    /**
     * Getter for extension
     *
995
     * @return \T3o\TerFe2\Domain\Model\Extension extension
996
     */
997
    public function getExtension(): Extension
998 999 1000 1001 1002 1003 1004 1005 1006
    {
        return $this->extension;
    }

    /**
     * Setter for extensionProvider
     *
     * @param string $extensionProvider Extension Provider
     */
1007
    public function setExtensionProvider(string $extensionProvider)
1008 1009 1010 1011 1012 1013 1014 1015 1016
    {
        $this->extensionProvider = $extensionProvider;
    }

    /**
     * Getter for extensionProvider
     *
     * @return string Extension Provider
     */
1017
    public function getExtensionProvider(): string
1018 1019 1020 1021 1022 1023 1024
    {
        return $this->extensionProvider;
    }

    /**
     * Setter for hasZipFile
     *
1025
     * @param bool $hasZipFile Has zip file
1026
     */
1027
    public function setHasZipFile(bool $hasZipFile)
1028
    {
1029
        $this->hasZipFile = $hasZipFile;
1030 1031 1032 1033 1034
    }

    /**
     * Getter for hasZipFile
     *
1035
     * @return bool Has zip file
1036
     */
1037
    public function getHasZipFile(): bool
1038 1039 1040 1041 1042 1043 1044
    {
        return $this->hasZipFile;
    }

    /**
     * Setter for hasImages
     *
1045
     * @param bool $hasImages Has images
1046
     */
1047
    public function setHasImages(bool $hasImages)
1048
    {
1049
        $this->hasImages = $hasImages;
1050 1051 1052 1053 1054
    }

    /**
     * Getter for hasImages
     *
1055
     * @return bool Has images
1056
     */
1057
    public function getHasImages(): bool
1058 1059 1060 1061 1062 1063 1064
    {
        return $this->hasImages;
    }

    /**
     * Setter for t3xFileSize
     *
1065
     * @param int $t3xFileSize File size
1066
     */
1067
    public function setT3xFileSize(int $t3xFileSize)
1068
    {
1069
        $this->t3xFileSize = $t3xFileSize;
1070 1071 1072 1073 1074
    }

    /**
     * Getter for t3xFileSize
     *
1075
     * @return int File size
1076
     */
1077
    public function getT3xFileSize(): int
1078
    {
1079
        return $this->t3xFileSize;
1080 1081 1082 1083 1084
    }

    /**
     * Setter for zipFileSize
     *
1085
     * @param int $zipFileSize File size
1086
     */
1087
    public function setZipFileSize(int $zipFileSize)
1088
    {
1089
        $this->zipFileSize = $zipFileSize;
1090 1091 1092 1093 1094
    }

    /**
     * Getter for zipFileSize
     *
1095
     * @return int File size
1096
     */
1097
    public function getZipFileSize(): int
1098
    {
1099
        return $this->zipFileSize;
1100 1101
    }

1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117
    /**
     * @return string
     */
    public function getComposerInfo()
    {
        return $this->composerInfo;
    }

    /**
     * @param string $composerInfo
     */
    public function setComposerInfo(string $composerInfo)
    {
        $this->composerInfo = $composerInfo;
    }

1118 1119
    /** Helper functions */

1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
    /**
     * @return string
     */
    public function getComposerName()
    {
        $composerName = '';
        if ($this->composerInfo !== '') {
            $composerInfoAsArray = json_decode($this->composerInfo, true);
            if (!empty($composerInfoAsArray)) {
                $composerName = $composerInfoAsArray['name'];
            }
        }

        return $composerName;
    }

1136
    /**
1137
     * @return \T3o\TerFe2\Domain\Model\Relation
1138
     */
1139
    public function getTypo3Dependency()
1140
    {
1141
        $typo3Dependency = null;
1142
        foreach ($this->softwareRelations as $relation) {
1143
            /** @var \T3o\TerFe2\Domain\Model\Relation $relation */
1144
            if ($relation->getRelationType() === 'depends' && $relation->getRelationKey() === 'typo3' && ($relation->getMinimumVersion() > 0 || $relation->getMaximumVersion() > 0)) {
1145 1146 1147 1148 1149 1150 1151 1152
                $typo3Dependency = $relation;
                break;
            }
        }

        return $typo3Dependency;
    }

1153 1154 1155 1156 1157 1158 1159 1160
    /**
     * @return array
     */
    public function getMatrixOfSupportedTypo3Versions(): array
    {
        // @todo: Get these versions automatically
        $typo3Versions = [
            '7 LTS' => 7006000,
1161 1162
            '8 LTS' => 8007000,
            '9 LTS' => 9005000
1163 1164 1165 1166
        ];
        $supportedTypo3Versions = [];

        foreach ($typo3Versions as $label => $mainVersion) {
1167
            $supportedTypo3Versions[$label] = \T3o\TerFe2\Utility\VersionUtility::doesExtensionSupportTypo3Version($this->getExtension(), $mainVersion);
1168 1169 1170 1171
        }

        return $supportedTypo3Versions;
    }
1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187

    /**
     * @return bool
     */
    public function hasTypo3Dependency()
    {
        return $this->getTypo3Dependency() !== null;
    }

    /**
     * @return bool
     */
    public function isLive()
    {
        return $this->getReviewState() >= 0;
    }
1188
}