hlubek-1220827799.diff
| Tests/Controller/F3_FLOW3_Controller_PackageTest.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Controller |
|
| 20 |
* @version $Id$ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Testcase for the Package Controller (CLI) |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Controller |
|
| 28 |
* @version $Id$ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Controller_PackageTest extends F3_Testing_BaseTestCase {
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
/** |
|
| 35 |
* @test |
|
| 36 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 37 |
*/ |
|
| 38 |
public function testCreateActionCallsPackageManagerCreatePackage() {
|
|
| 39 |
// get mocked Packagemanager |
|
| 40 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 41 |
|
|
| 42 |
$packageManager->expects($this->once()) |
|
| 43 |
->method('createPackage')
|
|
| 44 |
->with($this->equalTo('FooBarPackageName'));
|
|
| 45 |
|
|
| 46 |
$packageController = new F3_FLOW3_Controller_Package($this->componentFactory, $packageManager); |
|
| 47 |
$packageController->injectPackageManager($packageManager); |
|
| 48 |
$packageController->initializeController(); |
|
| 49 |
|
|
| 50 |
$argumentPackageKey = new F3_FLOW3_MVC_Controller_Argument('packageKey','Text', $this->componentFactory);
|
|
| 51 |
$packageControllerArguments = $packageController->getArguments(); |
|
| 52 |
$packageControllerArguments['packageKey']->setValue('FooBarPackageName');
|
|
| 53 |
|
|
| 54 |
$packageController->createAction(); |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
/** |
|
| 58 |
* @test |
|
| 59 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 60 |
*/ |
|
| 61 |
public function testActivateActionCallsPackageManagerActivatePackage() {
|
|
| 62 |
// get mocked Packagemanager |
|
| 63 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 64 |
|
|
| 65 |
$packageManager->expects($this->once()) |
|
| 66 |
->method('activatePackage')
|
|
| 67 |
->with($this->equalTo('FooBarPackageName'));
|
|
| 68 |
|
|
| 69 |
$packageController = new F3_FLOW3_Controller_Package($this->componentFactory, $packageManager); |
|
| 70 |
$packageController->injectPackageManager($packageManager); |
|
| 71 |
$packageController->initializeController(); |
|
| 72 |
|
|
| 73 |
$argumentPackageKey = new F3_FLOW3_MVC_Controller_Argument('packageKey','Text', $this->componentFactory);
|
|
| 74 |
$packageControllerArguments = $packageController->getArguments(); |
|
| 75 |
$packageControllerArguments['packageKey']->setValue('FooBarPackageName');
|
|
| 76 |
|
|
| 77 |
$packageController->activateAction(); |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
/** |
|
| 81 |
* @test |
|
| 82 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 83 |
*/ |
|
| 84 |
public function testDeactivateActionCallsPackageManagerDeactivatePackage() {
|
|
| 85 |
// get mocked Packagemanager |
|
| 86 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 87 |
|
|
| 88 |
$packageManager->expects($this->once()) |
|
| 89 |
->method('deactivatePackage')
|
|
| 90 |
->with($this->equalTo('FooBarPackageName'));
|
|
| 91 |
|
|
| 92 |
$packageController = new F3_FLOW3_Controller_Package($this->componentFactory, $packageManager); |
|
| 93 |
$packageController->injectPackageManager($packageManager); |
|
| 94 |
$packageController->initializeController(); |
|
| 95 |
|
|
| 96 |
$argumentPackageKey = new F3_FLOW3_MVC_Controller_Argument('packageKey','Text', $this->componentFactory);
|
|
| 97 |
$packageControllerArguments = $packageController->getArguments(); |
|
| 98 |
$packageControllerArguments['packageKey']->setValue('FooBarPackageName');
|
|
| 99 |
|
|
| 100 |
$packageController->deactivateAction(); |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
|
|
| 104 |
/** |
|
| 105 |
* @test |
|
| 106 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 107 |
*/ |
|
| 108 |
public function testCreateActionWithoutPackageKeyCallsHelpAction() {
|
|
| 109 |
// get mocked Packagemanager |
|
| 110 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 111 |
|
|
| 112 |
// mock method helpAction (and only that) for Package Controller |
|
| 113 |
$packageController = $this->getMock('F3_FLOW3_Controller_Package',
|
|
| 114 |
array('helpAction'),
|
|
| 115 |
array($this->componentFactory, $packageManager)); |
|
| 116 |
|
|
| 117 |
$packageController->expects($this->once()) |
|
| 118 |
->method('helpAction');
|
|
| 119 |
|
|
| 120 |
$packageController->initializeController(); |
|
| 121 |
|
|
| 122 |
$packageController->createAction(); |
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
|
|
| 126 |
/** |
|
| 127 |
* @test |
|
| 128 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 129 |
*/ |
|
| 130 |
public function testDefaultActionCallsHelpAction() {
|
|
| 131 |
// get mocked Packagemanager |
|
| 132 |
$packageManager = $this->getMock('F3_FLOW3_Package_ManagerInterface');
|
|
| 133 |
|
|
| 134 |
// mock method helpAction (and only that) for Package Controller |
|
| 135 |
$packageController = $this->getMock('F3_FLOW3_Controller_Package',
|
|
| 136 |
array('helpAction'),
|
|
| 137 |
array($this->componentFactory, $packageManager)); |
|
| 138 |
|
|
| 139 |
$packageController->expects($this->once()) |
|
| 140 |
->method('helpAction');
|
|
| 141 |
|
|
| 142 |
$packageController->initializeController(); |
|
| 143 |
|
|
| 144 |
$packageController->defaultAction(); |
|
| 145 |
} |
|
| 146 |
|
|
| 147 |
|
|
| 148 |
|
|
| 149 |
|
|
| 150 |
|
|
| 151 |
} |
|
| 152 |
|
|
| 153 |
?> |
|
| Tests/Package/F3_FLOW3_Package_MetaTest.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Tests |
|
| 20 |
* @version $Id:F3_FLOW3_Package_Test.php 201 2007-03-30 11:18:30Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Testcase for the package meta class |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Tests |
|
| 28 |
* @version $Id:F3_FLOW3_Package_Test.php 201 2007-03-30 11:18:30Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Package_MetaTest extends F3_Testing_BaseTestCase {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* @test |
|
| 35 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 36 |
*/ |
|
| 37 |
public function getPackageMetaWorks() {
|
|
| 38 |
$package = new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'TestPackage/');
|
|
| 39 |
$packageMeta = $package->getPackageMeta(); |
|
| 40 |
$this->assertEquals('TestPackage', $packageMeta->getPackageKey());
|
|
| 41 |
$this->assertEquals('Test package', $packageMeta->getTitle());
|
|
| 42 |
$this->assertEquals('0.0.1', $packageMeta->getVersion());
|
|
| 43 |
$this->assertEquals('This package is used for testing the package- and component manager', $packageMeta->getDescription());
|
|
| 44 |
$this->assertEquals('Alpha', $packageMeta->getState());
|
|
| 45 |
$this->assertEquals(array('System', 'Testing'), $packageMeta->getCategories());
|
|
| 46 |
|
|
| 47 |
$parties = $packageMeta->getParties(); |
|
| 48 |
$this->assertTrue(is_array($parties)); |
|
| 49 |
$person1 = $parties[0]; |
|
| 50 |
$this->assertType('F3_FLOW3_Package_Meta_Person', $person1);
|
|
| 51 |
$this->assertEquals('LeadDeveloper', $person1->getRole());
|
|
| 52 |
$this->assertEquals('Robert Lemke', $person1->getName());
|
|
| 53 |
$this->assertEquals('robert@typo3.org', $person1->getEmail());
|
|
| 54 |
$person2 = $parties[1]; |
|
| 55 |
$this->assertEquals('Smith Ltd.', $person2->getCompany());
|
|
| 56 |
$this->assertEquals('jsmith', $person2->getRepositoryUserName());
|
|
| 57 |
$organisation1 = $parties[2]; |
|
| 58 |
$this->assertType('F3_FLOW3_Package_Meta_Company', $organisation1);
|
|
| 59 |
$this->assertEquals('Sponsor', $organisation1->getRole());
|
|
| 60 |
$this->assertEquals('John Doe Co.', $organisation1->getName());
|
|
| 61 |
$this->assertEquals('info@johndoe.com', $organisation1->getEmail());
|
|
| 62 |
$this->assertEquals('www.johndoe.com', $organisation1->getWebsite());
|
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
/** |
|
| 66 |
* Check reading the package constraints from meta information |
|
| 67 |
* |
|
| 68 |
* @test |
|
| 69 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 70 |
*/ |
|
| 71 |
public function getPackageMetaConstraintsWorks() {
|
|
| 72 |
$package = new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'TestPackage/');
|
|
| 73 |
$packageMeta = $package->getPackageMeta(); |
|
| 74 |
|
|
| 75 |
$constraints = $packageMeta->getConstraints('depends');
|
|
| 76 |
$this->assertTrue(is_array($constraints)); |
|
| 77 |
|
|
| 78 |
$this->assertType('F3_FLOW3_Package_Meta_PackageConstraint', $constraints[0]);
|
|
| 79 |
$this->assertEquals('depends', $constraints[0]->getConstraintType());
|
|
| 80 |
$this->assertEquals('FLOW3', $constraints[0]->getValue());
|
|
| 81 |
$this->assertEquals('1.0.0', $constraints[0]->getMinVersion());
|
|
| 82 |
$this->assertEquals('1.9.9', $constraints[0]->getMaxVersion());
|
|
| 83 |
$this->assertType('F3_FLOW3_Package_Meta_SystemConstraint', $constraints[1]);
|
|
| 84 |
$this->assertNull($constraints[1]->getValue()); |
|
| 85 |
$this->assertEquals('PHP', $constraints[1]->getType());
|
|
| 86 |
$this->assertEquals('5.1.0', $constraints[1]->getMinVersion());
|
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
|
|
| 90 |
/** |
|
| 91 |
* Check constructing the meta information model then |
|
| 92 |
* creating a Package.xml |
|
| 93 |
* |
|
| 94 |
* @test |
|
| 95 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 96 |
*/ |
|
| 97 |
public function testMetaModelToXML() {
|
|
| 98 |
$packageManager = $this->componentFactory->getComponent('F3_FLOW3_Package_ManagerInterface');
|
|
| 99 |
|
|
| 100 |
$meta = new F3_FLOW3_Package_Meta('YetAnotherTestPackage');
|
|
| 101 |
$meta->setTitle('Yet another test package');
|
|
| 102 |
$meta->setDescription('A test package to test the creation of the Package.xml by the Package Manager');
|
|
| 103 |
$meta->setVersion('0.1.1');
|
|
| 104 |
$meta->setState('Beta');
|
|
| 105 |
$meta->addCategory('Testing');
|
|
| 106 |
$meta->addCategory('System');
|
|
| 107 |
$meta->addParty(new F3_FLOW3_Package_Meta_Person('LeadDeveloper',
|
|
| 108 |
'Robert Lemke', 'robert@typo3.org', 'http://www.flow3.org', 'TYPO3 Association', 'robert')); |
|
| 109 |
$meta->addParty(new F3_FLOW3_Package_Meta_Company(null, 'Acme Inc.', 'info@acme.com', 'http://www.acme.com')); |
|
| 110 |
$meta->addConstraint(new F3_FLOW3_Package_Meta_PackageConstraint('depends',
|
|
| 111 |
'FLOW3', '1.0.0', '1.9.9')); |
|
| 112 |
$meta->addConstraint(new F3_FLOW3_Package_Meta_SystemConstraint('suggests',
|
|
| 113 |
'Memory', '16M')); |
|
| 114 |
|
|
| 115 |
$xml = $meta->getPackageXML(); |
|
| 116 |
|
|
| 117 |
$this->assertXmlStringEqualsXmlFile($packageManager->getPackage('FLOW3')->getResourcesPath() . 'Fixtures/Package.xml', $xml);
|
|
| 118 |
} |
|
| 119 |
} |
|
| 120 |
?> |
|
| Tests/Package/F3_FLOW3_Package_ManagerTest.php (Arbeitskopie) | ||
|---|---|---|
| 142 | 142 |
$packageManager->initialize(); |
| 143 | 143 |
$this->assertEquals('TestPackage', $packageManager->getCaseSensitivePackageKey('testpackage'));
|
| 144 | 144 |
} |
| 145 |
|
|
| 146 |
/** |
|
| 147 |
* Check creating a new package folder, given a package key |
|
| 148 |
* |
|
| 149 |
* @test |
|
| 150 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 151 |
*/ |
|
| 152 |
public function testCreatePackageCreatesPackageFolderAndReturnsPackage() {
|
|
| 153 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 154 |
$packageManager->initialize(); |
|
| 155 |
|
|
| 156 |
$package = $packageManager->createPackage('YetAnotherTestPackage');
|
|
| 157 |
|
|
| 158 |
$this->assertType('F3_FLOW3_Package_PackageInterface', $package);
|
|
| 159 |
$this->assertEquals('YetAnotherTestPackage', $package->getPackageKey());
|
|
| 160 |
|
|
| 161 |
$this->assertTrue($packageManager->isPackageAvailable('YetAnotherTestPackage'));
|
|
| 162 |
} |
|
| 163 |
|
|
| 164 |
/** |
|
| 165 |
* Check creating a package creates the mandatory Package.xml |
|
| 166 |
* (this doesn't check the content of the file) |
|
| 167 |
* |
|
| 168 |
* @test |
|
| 169 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 170 |
*/ |
|
| 171 |
public function testCreatePackageCreatesPackageMetaFile() {
|
|
| 172 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 173 |
$packageManager->initialize(); |
|
| 174 |
|
|
| 175 |
$packageManager->createPackage('YetAnotherTestPackage');
|
|
| 176 |
|
|
| 177 |
$packagePath = $packageManager->getPackagePath('YetAnotherTestPackage');
|
|
| 178 |
$this->assertTrue(is_file($packagePath . F3_FLOW3_Package_Package::DIRECTORY_META . F3_FLOW3_Package_Package::FILENAME_PACKAGEINFO), |
|
| 179 |
'Mandatory Package.xml was created'); |
|
| 180 |
} |
|
| 181 |
|
|
| 182 |
public function testCreatePackageWithMetadataCreatesPackageXML() {
|
|
| 183 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 184 |
$packageManager->initialize(); |
|
| 185 |
|
|
| 186 |
$meta = $this->getMock('F3_FLOW3_Package_Meta', array('getPackageXML'), array('YetAnotherTestPackage'));
|
|
| 187 |
|
|
| 188 |
$packageXML = '<package><key>YetAnotherTestPackage</key></package>'; |
|
| 189 |
$meta->expects($this->once()) |
|
| 190 |
->method('getPackageXML')
|
|
| 191 |
->will($this->returnValue($packageXML)); |
|
| 192 |
|
|
| 193 |
$packageManager->createPackage('YetAnotherTestPackage', $meta);
|
|
| 194 |
|
|
| 195 |
$packagePath = $packageManager->getPackagePath('YetAnotherTestPackage');
|
|
| 196 |
$this->assertStringEqualsFile($packagePath . F3_FLOW3_Package_Package::DIRECTORY_META . F3_FLOW3_Package_Package::FILENAME_PACKAGEINFO, |
|
| 197 |
$packageXML); |
|
| 198 |
} |
|
| 199 |
|
|
| 200 |
/** |
|
| 201 |
* Check create package creates the folders for |
|
| 202 |
* classes, configuration, documentation, resources and tests |
|
| 203 |
* |
|
| 204 |
* @test |
|
| 205 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 206 |
*/ |
|
| 207 |
public function testCreatePackageCreatesClassesConfigurationDocumentationResourcesAndTestsFolders() {
|
|
| 208 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 209 |
$packageManager->initialize(); |
|
| 210 |
|
|
| 211 |
$packageManager->createPackage('YetAnotherTestPackage');
|
|
| 212 |
|
|
| 213 |
$packagePath = $packageManager->getPackagePath('YetAnotherTestPackage');
|
|
| 214 |
$this->assertTrue(is_dir($packagePath . F3_FLOW3_Package_Package::DIRECTORY_CLASSES)); |
|
| 215 |
$this->assertTrue(is_dir($packagePath . F3_FLOW3_Package_Package::DIRECTORY_CONFIGURATION)); |
|
| 216 |
$this->assertTrue(is_dir($packagePath . F3_FLOW3_Package_Package::DIRECTORY_DOCUMENTATION)); |
|
| 217 |
$this->assertTrue(is_dir($packagePath . F3_FLOW3_Package_Package::DIRECTORY_RESOURCES)); |
|
| 218 |
$this->assertTrue(is_dir($packagePath . F3_FLOW3_Package_Package::DIRECTORY_TESTS)); |
|
| 219 |
} |
|
| 220 |
|
|
| 221 |
/** |
|
| 222 |
* @test |
|
| 223 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 224 |
*/ |
|
| 225 |
public function testCreatePackageThrowsExceptionForInvalidPackageKey() {
|
|
| 226 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 227 |
$packageManager->initialize(); |
|
| 228 |
|
|
| 229 |
try {
|
|
| 230 |
$packageManager->createPackage('Invalid_Package_Key');
|
|
| 231 |
} catch(Exception $exception) {
|
|
| 232 |
$this->assertEquals(1220722210, $exception->getCode(), 'createPackage() throwed an exception but with an unexpected error code.'); |
|
| 233 |
} |
|
| 234 |
|
|
| 235 |
$this->assertFalse(is_dir(FLOW3_PATH_PACKAGES . 'Invalid_Package_Key'), 'Package folder with invalid package key was created'); |
|
| 236 |
} |
|
| 237 |
|
|
| 238 |
/** |
|
| 239 |
* Check handling of duplicate package keys in package creation |
|
| 240 |
* |
|
| 241 |
* @test |
|
| 242 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 243 |
*/ |
|
| 244 |
public function testCreatePackageThrowsExceptionForExistingPackageKey() {
|
|
| 245 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 246 |
$packageManager->initialize(); |
|
| 247 |
|
|
| 248 |
try {
|
|
| 249 |
$packageManager->createPackage('TestPackage');
|
|
| 250 |
} catch(Exception $exception) {
|
|
| 251 |
$this->assertEquals(1220722873, $exception->getCode(), 'createPackage() throwed an exception but with an unexpected error code.'); |
|
| 252 |
return; |
|
| 253 |
} |
|
| 254 |
$this->fail('Create package didnt throw an exception for an existing package key');
|
|
| 255 |
} |
|
| 256 |
|
|
| 257 |
/** |
|
| 258 |
* @test |
|
| 259 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 260 |
*/ |
|
| 261 |
public function testCreatePackageCreatesDeactivatedPackage() {
|
|
| 262 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 263 |
$packageManager->initialize(); |
|
| 264 |
|
|
| 265 |
$packageKey = 'YetAnotherTestPackage'; |
|
| 266 |
$packageManager->createPackage($packageKey); |
|
| 267 |
|
|
| 268 |
$this->assertFalse($packageManager->isPackageActive($packageKey)); |
|
| 269 |
} |
|
| 270 |
|
|
| 271 |
|
|
| 272 |
/** |
|
| 273 |
* Check package key validation accepts only valid keys |
|
| 274 |
* |
|
| 275 |
* @test |
|
| 276 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 277 |
*/ |
|
| 278 |
public function getPackageKeyValidationWorks() {
|
|
| 279 |
$this->assertFalse($this->packageManager->isPackageKeyValid('Invalid_Package_Key'));
|
|
| 280 |
$this->assertFalse($this->packageManager->isPackageKeyValid('invalidPackageKey'));
|
|
| 281 |
$this->assertFalse($this->packageManager->isPackageKeyValid('1nvalidPackageKey'));
|
|
| 282 |
$this->assertTrue($this->packageManager->isPackageKeyValid('ValidPackageKey'));
|
|
| 283 |
} |
|
| 284 |
|
|
| 285 |
/* |
|
| 286 |
public function testCreatePackageCreatesPackageMetaData() {
|
|
| 287 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 288 |
$packageManager->initialize(); |
|
| 289 |
|
|
| 290 |
$metadata = new F3_FLOW3_Package_Meta(); |
|
| 291 |
|
|
| 292 |
$package = $packageManager->createPackage('YetAnotherTestPackage', $metadata);
|
|
| 293 |
} |
|
| 294 |
*/ |
|
| 295 |
|
|
| 296 |
/** |
|
| 297 |
* @test |
|
| 298 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 299 |
*/ |
|
| 300 |
public function testDeacivatePackageRemovesPackageFromActivePackages() {
|
|
| 301 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 302 |
$packageManager->initialize(); |
|
| 303 |
|
|
| 304 |
$packageKey = 'YetAnotherTestPackage'; |
|
| 305 |
|
|
| 306 |
$packageManager->createPackage($packageKey); |
|
| 307 |
$packageManager->activatePackage($packageKey); |
|
| 308 |
$packageManager->deactivatePackage($packageKey); |
|
| 309 |
|
|
| 310 |
$this->assertFalse($packageManager->isPackageActive($packageKey)); |
|
| 311 |
} |
|
| 312 |
|
|
| 313 |
/** |
|
| 314 |
* @test |
|
| 315 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 316 |
*/ |
|
| 317 |
public function testActivatePackagesAddsPackageToActivePackages() {
|
|
| 318 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 319 |
$packageManager->initialize(); |
|
| 320 |
|
|
| 321 |
$packageKey = 'YetAnotherTestPackage'; |
|
| 322 |
$packageManager->createPackage($packageKey); |
|
| 323 |
$packageManager->activatePackage($packageKey); |
|
| 324 |
|
|
| 325 |
$this->assertTrue($packageManager->isPackageActive($packageKey)); |
|
| 326 |
} |
|
| 327 |
|
|
| 328 |
|
|
| 329 |
/** |
|
| 330 |
* @test |
|
| 331 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 332 |
*/ |
|
| 333 |
public function testRemovePackageThrowsErrorIfPackageIsNotAvailable() {
|
|
| 334 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 335 |
$packageManager->initialize(); |
|
| 336 |
|
|
| 337 |
try {
|
|
| 338 |
$packageManager->removePackage('PrettyUnlikelyThatThisPackageExists');
|
|
| 339 |
} catch (Exception $exception) {
|
|
| 340 |
$this->assertEquals(1166543253, $exception->getCode(), 'removePackage() throwed an exception.'); |
|
| 341 |
return; |
|
| 342 |
} |
|
| 343 |
$this->fail('removePackage() did not throw an exception while asking for the path to a non existent package.');
|
|
| 344 |
} |
|
| 345 |
|
|
| 346 |
/** |
|
| 347 |
* @test |
|
| 348 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 349 |
*/ |
|
| 350 |
public function testRemovePackgeThrowsErrorIfPackageIsProtected() {
|
|
| 351 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 352 |
$packageManager->initialize(); |
|
| 353 |
try {
|
|
| 354 |
$packageManager->removePackage('PHP6');
|
|
| 355 |
} catch (Exception $exception) {
|
|
| 356 |
$this->assertEquals(1220722120, $exception->getCode(), 'removePackage() throwed an exception.'); |
|
| 357 |
return; |
|
| 358 |
} |
|
| 359 |
$this->fail('removePackage() did not throw an exception while asking for removing a protected package.');
|
|
| 360 |
} |
|
| 361 |
|
|
| 362 |
/** |
|
| 363 |
* @test |
|
| 364 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 365 |
*/ |
|
| 366 |
public function testRemovePackageRemovesPackageFromAvailablePackages() {
|
|
| 367 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 368 |
$packageManager->initialize(); |
|
| 369 |
|
|
| 370 |
$packageKey = 'YetAnotherTestPackage'; |
|
| 371 |
$packageManager->createPackage($packageKey); |
|
| 372 |
$packageManager->removePackage($packageKey); |
|
| 373 |
|
|
| 374 |
$this->assertFalse($packageManager->isPackageAvailable($packageKey)); |
|
| 375 |
} |
|
| 376 |
|
|
| 377 |
/** |
|
| 378 |
* @test |
|
| 379 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 380 |
*/ |
|
| 381 |
public function testRemovePackageRemovesPackageFromActivePackages() {
|
|
| 382 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 383 |
$packageManager->initialize(); |
|
| 384 |
|
|
| 385 |
$packageKey = 'YetAnotherTestPackage'; |
|
| 386 |
$packageManager->createPackage($packageKey); |
|
| 387 |
$packageManager->activatePackage($packageKey); |
|
| 388 |
$packageManager->removePackage($packageKey); |
|
| 389 |
|
|
| 390 |
$this->assertFalse($packageManager->isPackageActive($packageKey)); |
|
| 391 |
} |
|
| 392 |
|
|
| 393 |
/** |
|
| 394 |
* @test |
|
| 395 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 396 |
*/ |
|
| 397 |
public function testRemovePackageRemovesPackageDirectoryFromFilesystem() {
|
|
| 398 |
$packageManager = new F3_FLOW3_Package_Manager(); |
|
| 399 |
$packageManager->initialize(); |
|
| 400 |
|
|
| 401 |
$packageKey = 'YetAnotherTestPackage'; |
|
| 402 |
$packageManager->createPackage($packageKey); |
|
| 403 |
$packagePath = $packageManager->getPackagePath($packageKey); |
|
| 404 |
|
|
| 405 |
$packageManager->removePackage($packageKey); |
|
| 406 |
|
|
| 407 |
$this->assertFalse(file_exists($packagePath), $packagePath); |
|
| 408 |
} |
|
| 409 |
|
|
| 410 |
|
|
| 411 |
/** |
|
| 412 |
* Remove directories of packages created by tests |
|
| 413 |
* |
|
| 414 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 415 |
*/ |
|
| 416 |
protected function tearDown() {
|
|
| 417 |
$yetAnotherTestPackagePath = FLOW3_PATH_PACKAGES . '/' . 'YetAnotherTestPackage'; |
|
| 418 |
if(is_dir($yetAnotherTestPackagePath)) {
|
|
| 419 |
F3_FLOW3_Utility_Files::removeDirectoryRecursively($yetAnotherTestPackagePath); |
|
| 420 |
} |
|
| 421 |
} |
|
| 422 | 145 |
} |
| 423 | 146 |
?> |
| Tests/Package/F3_FLOW3_Package_PackageTest.php (Arbeitskopie) | ||
|---|---|---|
| 36 | 36 |
* @author Robert Lemke <robert@typo3.org> |
| 37 | 37 |
*/ |
| 38 | 38 |
public function constructThrowsPackageDoesNotExistException() {
|
| 39 |
$mockPackageManager = $this->getMock('F3_FLOW3_Package_Manager', array(), array(), '', FALSE);
|
|
| 40 |
new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'ThisPackageSurelyDoesNotExist', $mockPackageManager);
|
|
| 39 |
new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'ThisPackageSurelyDoesNotExist');
|
|
| 40 | 41 |
} |
| 41 | 42 |
|
| 42 | 43 |
/** |
| ... | ... | |
| 47 | 48 |
* @author Robert Lemke <robert@typo3.org> |
| 48 | 49 |
*/ |
| 49 | 50 |
public function constructThrowsInvalidPathException() {
|
| 51 |
$mockPackageManager = $this->getMock('F3_FLOW3_Package_Manager', array(), array(), '', FALSE);
|
|
| 52 |
new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'TestPackage', $mockPackageManager);
|
|
| 50 |
new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'TestPackage');
|
|
| 51 | 53 |
} |
| 52 | 54 |
|
| 53 | 55 |
/** |
| ... | ... | |
| 56 | 58 |
* @author Robert Lemke <robert@typo3.org> |
| 57 | 59 |
*/ |
| 58 | 60 |
public function constructRejectsInvalidPackageKeys() {
|
| 61 |
$mockPackageManager = $this->getMock('F3_FLOW3_Package_Manager', array(), array(), '', FALSE);
|
|
| 62 |
new F3_FLOW3_Package_Package('Invalid_Package_Key', FLOW3_PATH_PACKAGES . 'TestPackage/', $mockPackageManager);
|
|
| 59 |
new F3_FLOW3_Package_Package('Invalid_Package_Key', FLOW3_PATH_PACKAGES . 'TestPackage/');
|
|
| 60 | 63 |
} |
| 64 |
|
|
| 61 |
|
|
| 62 | 65 |
/** |
| 63 | 66 |
* Test the method getClassFiles() without initializing the package manager |
| 64 | 67 |
* |
| ... | ... | |
| 66 | 69 |
* @author Robert Lemke <robert@typo3.org> |
| 67 | 70 |
*/ |
| 68 | 71 |
public function getClassFilesWorks() {
|
| 72 |
$mockPackageManager = $this->getMock('F3_FLOW3_Package_Manager', array(), array(), '', FALSE);
|
|
| 73 |
$package = new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'TestPackage/', $mockPackageManager);
|
|
| 69 |
$package = new F3_FLOW3_Package_Package('TestPackage', FLOW3_PATH_PACKAGES . 'TestPackage/');
|
|
| 70 | 74 |
$classFiles = $package->getClassFiles(); |
| 71 | 75 |
|
| 72 | 76 |
$this->assertTrue(key_exists('F3_TestPackage_BasicClass', $classFiles), 'The BasicClass is not in the class files array!');
|
| Resources/Fixtures/Package.xml (Revision 0) | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> |
|
| 2 |
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://typo3.org/ns/2008/flow3/package" version="1.0"> |
|
| 3 |
<key>YetAnotherTestPackage</key> |
|
| 4 |
<title>Yet another test package</title> |
|
| 5 |
<description>A test package to test the creation of the Package.xml by the Package Manager</description> |
|
| 6 |
<version>0.1.1</version> |
|
| 7 |
<state>Beta</state> |
|
| 8 |
<categories> |
|
| 9 |
<category>Testing</category> |
|
| 10 |
<category>System</category> |
|
| 11 |
</categories> |
|
| 12 |
<parties> |
|
| 13 |
<person role="LeadDeveloper"> |
|
| 14 |
<name>Robert Lemke</name> |
|
| 15 |
<email>robert@typo3.org</email> |
|
| 16 |
<website>http://www.flow3.org</website> |
|
| 17 |
<company>TYPO3 Association</company> |
|
| 18 |
<repositoryUserName>robert</repositoryUserName> |
|
| 19 |
</person> |
|
| 20 |
<company> |
|
| 21 |
<name>Acme Inc.</name> |
|
| 22 |
<email>info@acme.com</email> |
|
| 23 |
<website>http://www.acme.com</website> |
|
| 24 |
</company> |
|
| 25 |
</parties> |
|
| 26 |
<constraints> |
|
| 27 |
<depends> |
|
| 28 |
<package minVersion="1.0.0" maxVersion="1.9.9">FLOW3</package> |
|
| 29 |
</depends> |
|
| 30 |
<suggests> |
|
| 31 |
<system type="Memory">16M</system> |
|
| 32 |
</suggests> |
|
| 33 |
</constraints> |
|
| 34 |
</package> |
|
| Classes/Controller/F3_FLOW3_Controller_Package.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage MVC |
|
| 20 |
* @version $Id$ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Package controller to handle packages from CLI (create/activate/deactivate packages) |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage MVC |
|
| 28 |
* @version $Id$ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Controller_Package extends F3_FLOW3_MVC_Controller_ActionController {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* @var F3_FLOW3_Package_ManagerInterface |
|
| 35 |
*/ |
|
| 36 |
protected $packageManager; |
|
| 37 |
|
|
| 38 |
/** |
|
| 39 |
* @var array |
|
| 40 |
*/ |
|
| 41 |
protected $supportedRequestTypes = array('F3_FLOW3_MVC_CLI_Request');
|
|
| 42 |
|
|
| 43 |
|
|
| 44 |
/** |
|
| 45 |
* Initializes this controller |
|
| 46 |
* |
|
| 47 |
* @return void |
|
| 48 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 49 |
*/ |
|
| 50 |
public function initializeController() {
|
|
| 51 |
$this->arguments->addNewArgument('packageKey');
|
|
| 52 |
} |
|
| 53 |
|
|
| 54 |
|
|
| 55 |
/** |
|
| 56 |
* Injects the package manager |
|
| 57 |
* |
|
| 58 |
* @param F3_FLOW3_Package_ManagerInterface $packageManager |
|
| 59 |
* @return void |
|
| 60 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 61 |
*/ |
|
| 62 |
public function injectPackageManager(F3_FLOW3_Package_ManagerInterface $packageManager) {
|
|
| 63 |
$this->packageManager = $packageManager; |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
|
|
| 67 |
/** |
|
| 68 |
* default action (no arguments given) |
|
| 69 |
* @return void |
|
| 70 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 71 |
*/ |
|
| 72 |
public function defaultAction() {
|
|
| 73 |
return $this->helpAction(); |
|
| 74 |
} |
|
| 75 |
|
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* create the package |
|
| 79 |
* |
|
| 80 |
* @return void |
|
| 81 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 82 |
*/ |
|
| 83 |
public function createAction() {
|
|
| 84 |
if ($this->arguments['packageKey'] == '') {
|
|
| 85 |
return $this->helpAction(); |
|
| 86 |
} else {
|
|
| 87 |
$this->packageManager->createPackage($this->arguments['packageKey']->getValue()); |
|
| 88 |
return 'new package "' . $this->arguments['packageKey'] . '" created.' . chr(10); |
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
|
|
| 93 |
/** |
|
| 94 |
* activate the package |
|
| 95 |
* |
|
| 96 |
* @return void |
|
| 97 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 98 |
*/ |
|
| 99 |
public function activateAction() {
|
|
| 100 |
if ($this->arguments['packageKey'] == '') {
|
|
| 101 |
return $this->helpAction(); |
|
| 102 |
} else {
|
|
| 103 |
$this->packageManager->activatePackage($this->arguments['packageKey']->getValue()); |
|
| 104 |
return 'package "' . $this->arguments['packageKey'] . '" activated.' . chr(10); |
|
| 105 |
} |
|
| 106 |
} |
|
| 107 |
|
|
| 108 |
|
|
| 109 |
/** |
|
| 110 |
* deactivate the package |
|
| 111 |
* |
|
| 112 |
* @return void |
|
| 113 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 114 |
*/ |
|
| 115 |
public function deactivateAction() {
|
|
| 116 |
if ($this->arguments['packageKey'] == '') {
|
|
| 117 |
return $this->helpAction(); |
|
| 118 |
} else {
|
|
| 119 |
$this->packageManager->deactivatePackage($this->arguments['packageKey']->getValue()); |
|
| 120 |
return 'package "' . $this->arguments['packageKey'] . '" deactivated.' . chr(10); |
|
| 121 |
} |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
|
|
| 125 |
/** |
|
| 126 |
* displays a help screen |
|
| 127 |
* |
|
| 128 |
* @return void |
|
| 129 |
* @author Tobias Liebig <mail_typo3@etobi.de> |
|
| 130 |
*/ |
|
| 131 |
public function helpAction() {
|
|
| 132 |
return chr(10) . |
|
| 133 |
'FLOW3 Package CLI Controller' . chr(10) . |
|
| 134 |
'Usage: php index_dev.php FLOW3 Package <command> package-key=<PACKAGE>' . chr(10). |
|
| 135 |
chr(10) . |
|
| 136 |
'<command>:' . chr(10) . |
|
| 137 |
' create - create a new package' . chr(10). |
|
| 138 |
' activate - activate a package' . chr(10). |
|
| 139 |
' deactivate - activate a package' . chr(10) |
|
| 140 |
; |
|
| 141 |
} |
|
| 142 |
} |
|
| 143 |
|
|
| 144 |
?> |
|
| Classes/Package/Meta/F3_FLOW3_Package_Meta_Company.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Package company party meta model |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Package_Meta_Company extends F3_FLOW3_Package_Meta_Party {
|
|
| 32 |
/** |
|
| 33 |
* @return string Party type "company" |
|
| 34 |
* @author Christoppher Hlubek <hlubek@networkteam.com> |
|
| 35 |
*/ |
|
| 36 |
protected function getPartyType() {
|
|
| 37 |
return 'company'; |
|
| 38 |
} |
|
| 39 |
|
|
| 40 |
} |
|
| 41 |
?> |
|
| Classes/Package/Meta/F3_FLOW3_Package_Meta_Person.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Package person party meta model |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Package_Meta_Person extends F3_FLOW3_Package_Meta_Party {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* Company of the person |
|
| 35 |
* |
|
| 36 |
* @var string |
|
| 37 |
*/ |
|
| 38 |
protected $company; |
|
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Repository user name of the person |
|
| 42 |
* |
|
| 43 |
* @var unknown_type |
|
| 44 |
*/ |
|
| 45 |
protected $repositoryUserName; |
|
| 46 |
|
|
| 47 |
/** |
|
| 48 |
* Meta person model constructor |
|
| 49 |
* |
|
| 50 |
* @param string $role |
|
| 51 |
* @param string $name |
|
| 52 |
* @param string $email |
|
| 53 |
* @param string $website |
|
| 54 |
* @param string $company |
|
| 55 |
* @param string $repositoryUserName |
|
| 56 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 57 |
*/ |
|
| 58 |
public function __construct($role, $name, $email = null, $website = null, $company = null, $repositoryUserName = null) {
|
|
| 59 |
parent::__construct($role, $name, $email, $website); |
|
| 60 |
|
|
| 61 |
$this->company = $company; |
|
| 62 |
$this->repositoryUserName = $repositoryUserName; |
|
| 63 |
} |
|
| 64 |
|
|
| 65 |
/** |
|
| 66 |
* @return string The company of the person |
|
| 67 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 68 |
*/ |
|
| 69 |
public function getCompany() {
|
|
| 70 |
return $this->company; |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
/** |
|
| 74 |
* @return string The repository username |
|
| 75 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 76 |
*/ |
|
| 77 |
public function getRepositoryUserName() {
|
|
| 78 |
return $this->repositoryUserName; |
|
| 79 |
} |
|
| 80 |
|
|
| 81 |
/** |
|
| 82 |
* @return string Party type "person" |
|
| 83 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 84 |
*/ |
|
| 85 |
protected function getPartyType() {
|
|
| 86 |
return 'person'; |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
/** |
|
| 90 |
* Write additional information for the person to the XMLWriter |
|
| 91 |
* |
|
| 92 |
* @param XMLWriter $xml |
|
| 93 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 94 |
*/ |
|
| 95 |
protected function writePartyXML(XMLWriter $xml) {
|
|
| 96 |
if(strlen($this->company)) $xml->writeElement('company', $this->company);
|
|
| 97 |
if(strlen($this->repositoryUserName)) $xml->writeElement('repositoryUserName', $this->repositoryUserName);
|
|
| 98 |
} |
|
| 99 |
} |
|
| 100 |
?> |
|
| Classes/Package/Meta/F3_FLOW3_Package_Meta_SystemConstraint.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* System constraint meta model |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Package_Meta_SystemConstraint extends F3_FLOW3_Package_Meta_Constraint {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* The type for a system scope constraint (e.g. "Memory") |
|
| 35 |
* |
|
| 36 |
* @var string |
|
| 37 |
*/ |
|
| 38 |
protected $type; |
|
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Meta system constraint constructor |
|
| 42 |
* |
|
| 43 |
* @param string $constraintType |
|
| 44 |
* @param string $type |
|
| 45 |
* @param string $value |
|
| 46 |
* @param string $minVersion |
|
| 47 |
* @param string $maxVersion |
|
| 48 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 49 |
*/ |
|
| 50 |
public function __construct($constraintType, $type, $value = null, $minVersion = null, $maxVersion = null) {
|
|
| 51 |
if(!strlen($value)) $value = null; |
|
| 52 |
parent::__construct($constraintType, $value, $minVersion, $maxVersion); |
|
| 53 |
$this->type = $type; |
|
| 54 |
} |
|
| 55 |
|
|
| 56 |
/** |
|
| 57 |
* @return string The system constraint type |
|
| 58 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 59 |
*/ |
|
| 60 |
public function getType() {
|
|
| 61 |
return $this->type; |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
/** |
|
| 65 |
* @see F3_FLOW3_Package_Meta_Constraint::getConstraintScope() |
|
| 66 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 67 |
*/ |
|
| 68 |
protected function getConstraintScope() {
|
|
| 69 |
return 'system'; |
|
| 70 |
} |
|
| 71 |
|
|
| 72 |
/** |
|
| 73 |
* Writes an additional type attribute to the system constraint element |
|
| 74 |
* |
|
| 75 |
* @param XMLWriter $xml |
|
| 76 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 77 |
*/ |
|
| 78 |
protected function writeConstraintXML(XMLWriter $xml) {
|
|
| 79 |
if(strlen($this->type)) $xml->writeAttribute('type', $this->type);
|
|
| 80 |
} |
|
| 81 |
} |
|
| 82 |
?> |
|
| Classes/Package/Meta/F3_FLOW3_Package_Meta_Party.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Party meta model for persons and companies |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
abstract class F3_FLOW3_Package_Meta_Party {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* The party role |
|
| 35 |
* |
|
| 36 |
* @var string |
|
| 37 |
*/ |
|
| 38 |
protected $role; |
|
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Name of the party |
|
| 42 |
* |
|
| 43 |
* @var string |
|
| 44 |
*/ |
|
| 45 |
protected $name; |
|
| 46 |
|
|
| 47 |
/** |
|
| 48 |
* Email of the party |
|
| 49 |
* |
|
| 50 |
* @var string |
|
| 51 |
*/ |
|
| 52 |
protected $email; |
|
| 53 |
|
|
| 54 |
/** |
|
| 55 |
* Website of the party |
|
| 56 |
* |
|
| 57 |
* @var string |
|
| 58 |
*/ |
|
| 59 |
protected $website; |
|
| 60 |
|
|
| 61 |
/** |
|
| 62 |
* Meta party model constructor |
|
| 63 |
* |
|
| 64 |
* @param string $role |
|
| 65 |
* @param string $name |
|
| 66 |
* @param string $email |
|
| 67 |
* @param string $website |
|
| 68 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 69 |
*/ |
|
| 70 |
public function __construct($role, $name, $email = null, $website = null) {
|
|
| 71 |
$this->role = $role; |
|
| 72 |
$this->name = $name; |
|
| 73 |
$this->email = $email; |
|
| 74 |
$this->website = $website; |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* @return string The role of the party |
|
| 79 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 80 |
*/ |
|
| 81 |
public function getRole() {
|
|
| 82 |
return $this->role; |
|
| 83 |
} |
|
| 84 |
|
|
| 85 |
/** |
|
| 86 |
* @return string The name of the party |
|
| 87 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 88 |
*/ |
|
| 89 |
public function getName() {
|
|
| 90 |
return $this->name; |
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
/** |
|
| 94 |
* @return string The email of the party |
|
| 95 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 96 |
*/ |
|
| 97 |
public function getEmail() {
|
|
| 98 |
return $this->email; |
|
| 99 |
} |
|
| 100 |
|
|
| 101 |
/** |
|
| 102 |
* @return string The website of the party |
|
| 103 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 104 |
*/ |
|
| 105 |
public function getWebsite() {
|
|
| 106 |
return $this->website; |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
/** |
|
| 110 |
* Write general party information to the XMLWriter. |
|
| 111 |
* |
|
| 112 |
* Subclasses can contribute to the XML with |
|
| 113 |
* writePartyXML(...). |
|
| 114 |
* |
|
| 115 |
* @param XMLWriter $xml |
|
| 116 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 117 |
*/ |
|
| 118 |
public function writeXML(XMLWriter $xml) {
|
|
| 119 |
$xml->startElement($this->getPartyType()); |
|
| 120 |
|
|
| 121 |
if(strlen($this->role)) $xml->writeAttribute('role', $this->role);
|
|
| 122 |
|
|
| 123 |
if(strlen($this->name)) $xml->writeElement('name', $this->name);
|
|
| 124 |
if(strlen($this->email)) $xml->writeElement('email', $this->email);
|
|
| 125 |
if(strlen($this->website)) $xml->writeElement('website', $this->website);
|
|
| 126 |
|
|
| 127 |
$this->writePartyXML($xml); |
|
| 128 |
|
|
| 129 |
$xml->endElement(); // party |
|
| 130 |
} |
|
| 131 |
|
|
| 132 |
/** |
|
| 133 |
* The party type will be used for the XML element name |
|
| 134 |
* of the party. |
|
| 135 |
* |
|
| 136 |
* @return string The type of the party (person, company) |
|
| 137 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 138 |
*/ |
|
| 139 |
protected abstract function getPartyType(); |
|
| 140 |
|
|
| 141 |
/** |
|
| 142 |
* Stub for subclass contribution to the party XML. |
|
| 143 |
* |
|
| 144 |
* @param XMLWriter $xml |
|
| 145 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 146 |
*/ |
|
| 147 |
protected function writePartyXML(XMLWriter $xml) {
|
|
| 148 |
|
|
| 149 |
} |
|
| 150 |
} |
|
| 151 |
?> |
|
| Classes/Package/Meta/F3_FLOW3_Package_Meta_PackageConstraint.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Package constraint meta model |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Package_Meta_PackageConstraint extends F3_FLOW3_Package_Meta_Constraint {
|
|
| 32 |
/** |
|
| 33 |
* @see F3_FLOW3_Package_Meta_Constraint::getConstraintScope() |
|
| 34 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 35 |
*/ |
|
| 36 |
protected function getConstraintScope() {
|
|
| 37 |
return 'package'; |
|
| 38 |
} |
|
| 39 |
} |
|
| 40 |
?> |
|
| Classes/Package/Meta/F3_FLOW3_Package_Meta_Constraint.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* Constraint meta model |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id:F3_FLOW3_Package_Meta.php 203 2007-03-30 13:17:37Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
abstract class F3_FLOW3_Package_Meta_Constraint {
|
|
| 32 |
|
|
| 33 |
/** |
|
| 34 |
* One of depends, conflicts or suggests |
|
| 35 |
* |
|
| 36 |
* @var string The constraint type |
|
| 37 |
*/ |
|
| 38 |
protected $constraintType; |
|
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* @var string The constraint name or value |
|
| 42 |
*/ |
|
| 43 |
protected $value; |
|
| 44 |
|
|
| 45 |
/** |
|
| 46 |
* @var string The minimum version |
|
| 47 |
*/ |
|
| 48 |
protected $minVersion; |
|
| 49 |
|
|
| 50 |
/** |
|
| 51 |
* @var string The maximum version |
|
| 52 |
*/ |
|
| 53 |
protected $maxVersion; |
|
| 54 |
|
|
| 55 |
/** |
|
| 56 |
* Meta constraint constructor |
|
| 57 |
* |
|
| 58 |
* @param string $constraintType |
|
| 59 |
* @param string $value |
|
| 60 |
* @param string $minVersion |
|
| 61 |
* @param string $maxVersion |
|
| 62 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 63 |
*/ |
|
| 64 |
public function __construct($constraintType, $value, $minVersion = null, $maxVersion = null) {
|
|
| 65 |
$this->constraintType = $constraintType; |
|
| 66 |
$this->value = $value; |
|
| 67 |
$this->minVersion = $minVersion; |
|
| 68 |
$this->maxVersion = $maxVersion; |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
/** |
|
| 72 |
* @return string The constraint name or value |
|
| 73 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 74 |
*/ |
|
| 75 |
public function getValue() {
|
|
| 76 |
return $this->value; |
|
| 77 |
} |
|
| 78 |
|
|
| 79 |
/** |
|
| 80 |
* @return string The minimum version |
|
| 81 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 82 |
*/ |
|
| 83 |
public function getMinVersion() {
|
|
| 84 |
return $this->minVersion; |
|
| 85 |
} |
|
| 86 |
|
|
| 87 |
/** |
|
| 88 |
* @return string The maximum version |
|
| 89 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 90 |
*/ |
|
| 91 |
public function getMaxVersion() {
|
|
| 92 |
return $this->maxVersion; |
|
| 93 |
} |
|
| 94 |
|
|
| 95 |
/** |
|
| 96 |
* @return string The constraint type (depends, conflicts, suggests) |
|
| 97 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 98 |
*/ |
|
| 99 |
public function getConstraintType() {
|
|
| 100 |
return $this->constraintType; |
|
| 101 |
} |
|
| 102 |
|
|
| 103 |
/** |
|
| 104 |
* Write the constraint to a XMLWriter instance. This will |
|
| 105 |
* usually be used from the F3_FLOW3_Package_Meta to output |
|
| 106 |
* the Package.xml. |
|
| 107 |
* |
|
| 108 |
* The subclasses use the writeConstraintXML(...) |
|
| 109 |
* template method to write additional XML. |
|
| 110 |
* |
|
| 111 |
* @param XMLWriter $xml: The XMLWriter to write to |
|
| 112 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 113 |
*/ |
|
| 114 |
public function writeXML(XMLWriter $xml) {
|
|
| 115 |
$xml->startElement($this->getConstraintScope()); |
|
| 116 |
|
|
| 117 |
if(strlen($this->minVersion)) $xml->writeAttribute('minVersion', $this->minVersion);
|
|
| 118 |
if(strlen($this->maxVersion)) $xml->writeAttribute('maxVersion', $this->maxVersion);
|
|
| 119 |
|
|
| 120 |
// This has to come before text(...) to allow for writing of additional attributes from subclasses |
|
| 121 |
$this->writeConstraintXML($xml); |
|
| 122 |
|
|
| 123 |
if(strlen($this->value)) $xml->text($this->value); |
|
| 124 |
|
|
| 125 |
$xml->endElement(); // constraint |
|
| 126 |
} |
|
| 127 |
|
|
| 128 |
/** |
|
| 129 |
* @return string The constraint scope (package, system) |
|
| 130 |
*/ |
|
| 131 |
protected abstract function getConstraintScope(); |
|
| 132 |
|
|
| 133 |
/** |
|
| 134 |
* Stub method for writing additional XML |
|
| 135 |
* in subclasses. |
|
| 136 |
* |
|
| 137 |
* @param XMLWriter $xml |
|
| 138 |
*/ |
|
| 139 |
protected function writeConstraintXML(XMLWriter $xml) {
|
|
| 140 |
|
|
| 141 |
} |
|
| 142 |
} |
|
| 143 |
|
|
| 144 |
?> |
|
| Classes/Package/F3_FLOW3_Package_Meta.php (Arbeitskopie) | ||
|---|---|---|
| 31 | 31 |
class F3_FLOW3_Package_Meta implements F3_FLOW3_Package_MetaInterface {
|
| 32 | 32 |
|
| 33 | 33 |
/** |
| 34 |
* @var string The package key |
|
| 34 |
* @var string The package key |
|
| 35 | 35 |
*/ |
| 36 | 36 |
protected $packageKey; |
| 37 | 37 |
|
| ... | ... | |
| 44 | 44 |
* @var string Package title |
| 45 | 45 |
*/ |
| 46 | 46 |
protected $title; |
| 47 |
|
|
| 48 |
/** |
|
| 49 |
* @var string Package description |
|
| 50 |
*/ |
|
| 51 |
protected $description; |
|
| 52 | 47 |
|
| 53 | 48 |
/** |
| 49 |
* Constructor |
|
| 54 |
* @var string Package state |
|
| 55 |
*/ |
|
| 56 |
protected $state; |
|
| 57 |
|
|
| 58 |
/** |
|
| 59 |
* @var Array of string Package categories |
|
| 60 |
*/ |
|
| 61 |
protected $categories; |
|
| 62 |
|
|
| 63 |
/** |
|
| 64 |
* @var Array of F3_FLOW3_Package_Meta_Party Package parties (person, company) |
|
| 65 |
*/ |
|
| 66 |
protected $parties; |
|
| 67 |
|
|
| 68 |
/** |
|
| 69 |
* @var Array of Array of F3_FLOW3_Package_Meta_Constraint Package constraints by constraint type (depends, conflicts, suggests) |
|
| 70 |
*/ |
|
| 71 |
protected $constraints; |
|
| 72 |
|
|
| 73 |
/** |
|
| 74 |
* @var Array of string Constraint types |
|
| 75 |
*/ |
|
| 76 |
protected $constraintTypes = array('depends', 'conflicts', 'suggests');
|
|
| 77 |
|
|
| 78 |
/** |
|
| 79 |
* Package meta data constructor |
|
| 80 | 50 |
* |
| 51 |
* @param string The package key |
|
| 52 |
* @param [SimpleXMLElement] If specified, the XML data (which must be valid package meta XML) will be used to set the meta properties |
|
| 81 |
* @param string $packageKey: The package key |
|
| 82 | 53 |
* @return void |
| 83 | 54 |
* @author Robert Lemke <robert@typo3.org> |
| 55 |
* @todo Validate the $packageMetaXML as soon as we have a DTD / Schema for it |
|
| 84 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 85 | 56 |
*/ |
| 57 |
public function __construct($packageKey, SimpleXMLElement $packageMetaXML = NULL) {
|
|
| 58 |
if ($packageMetaXML !== NULL) {
|
|
| 59 |
$this->packageKey = (string)$packageMetaXML->packageKey; |
|
| 60 |
$this->version = (string)$packageMetaXML->version; |
|
| 61 |
$this->title = (string)$packageMetaXML->title; |
|
| 86 |
public function __construct($packageKey) {
|
|
| 87 |
$this->packageKey = $packageKey; |
|
| 88 |
} |
|
| 89 |
|
|
| 90 |
/** |
|
| 91 |
* Set meta information from the package XML |
|
| 92 |
* |
|
| 93 |
* @param SimpleXMLElement $packageMetaXML |
|
| 94 |
* @author Robert Lemke <robert@typo3.org> |
|
| 95 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 96 |
* @todo Validate the $packageMetaXML against RelaxNG schema |
|
| 97 |
* @todo Nested too deep, refactor |
|
| 98 |
*/ |
|
| 99 |
public function setMetaFromXML(SimpleXMLElement $packageMetaXML) {
|
|
| 100 |
$this->version = (string)$packageMetaXML->version; |
|
| 101 |
$this->title = (string)$packageMetaXML->title; |
|
| 102 |
$this->description = (string)$packageMetaXML->description; |
|
| 103 |
$this->state = (string)$packageMetaXML->state; |
|
| 104 |
$this->categories = array(); |
|
| 105 |
if($packageMetaXML->categories) {
|
|
| 106 |
foreach($packageMetaXML->categories->category as $category) {
|
|
| 107 |
$this->categories[] = (string)$category; |
|
| 108 |
} |
|
| 109 | 62 |
} |
| 110 |
$this->parties = array(); |
|
| 111 |
if($packageMetaXML->parties) {
|
|
| 112 |
foreach($packageMetaXML->parties->person as $person) {
|
|
| 113 |
$role = (string)$person['role']; |
|
| 114 |
$this->parties[] = new F3_FLOW3_Package_Meta_Person($role, |
|
| 115 |
(string)$person->name, (string)$person->email, (string)$person->website, |
|
| 116 |
(string)$person->company, (string)$person->repositoryUserName); |
|
| 117 |
} |
|
| 118 |
foreach($packageMetaXML->parties->company as $company) {
|
|
| 119 |
$role = (string)$company['role']; |
|
| 120 |
$this->parties[] = new F3_FLOW3_Package_Meta_Company($role, |
|
| 121 |
(string)$company->name, (string)$company->email, (string)$company->website); |
|
| 122 |
} |
|
| 123 |
} |
|
| 124 |
foreach($this->constraintTypes as $constraintType) {
|
|
| 125 |
if($packageMetaXML->constraints->{$constraintType}) {
|
|
| 126 |
foreach($packageMetaXML->constraints->{$constraintType}->children() as $constraint) {
|
|
| 127 |
switch((string)$constraint->getName()) {
|
|
| 128 |
case 'package': |
|
| 129 |
$this->constraints[$constraintType][] = new F3_FLOW3_Package_Meta_PackageConstraint( |
|
| 130 |
$constraintType, (string)$constraint, (string)$constraint['minVersion'], |
|
| 131 |
(string)$constraint['maxVersion']); |
|
| 132 |
break; |
|
| 133 |
case 'system': |
|
| 134 |
$this->constraints[$constraintType][] = new F3_FLOW3_Package_Meta_SystemConstraint( |
|
| 135 |
$constraintType, (string)$constraint['type'], (string)$constraint, |
|
| 136 |
(string)$constraint['minVersion'], (string)$constraint['maxVersion']); |
|
| 137 |
break; |
|
| 138 |
} |
|
| 139 |
} |
|
| 140 |
} |
|
| 141 |
} |
|
| 142 | 63 |
} |
| 143 |
|
|
| 144 |
/** |
|
| 145 |
* Return package meta as XML string |
|
| 146 |
* |
|
| 147 |
* @return string The package meta in XML |
|
| 148 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 149 |
*/ |
|
| 150 |
public function getPackageXML() {
|
|
| 151 |
$xml = new XMLWriter(); |
|
| 152 |
$xml->openMemory(); |
|
| 153 |
$xml->setIndent(true); |
|
| 154 |
$xml->setIndentString(chr(9)); |
|
| 155 |
|
|
| 156 |
$xml->writeRaw('<?xml version="1.0" encoding="utf-8" standalone="yes" ?>' . chr(10));
|
|
| 157 |
$xml->startElement('package');
|
|
| 158 |
// Write namespace attributes raw |
|
| 159 |
$xml->writeAttribute('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
|
|
| 160 |
$xml->writeAttribute('xmlns', 'http://typo3.org/ns/2008/flow3/package');
|
|
| 161 |
$xml->writeAttribute('version', '1.0');
|
|
| 162 |
|
|
| 163 |
$xml->writeElement('key', $this->packageKey);
|
|
| 164 |
$xml->writeElement('title', $this->title);
|
|
| 165 |
$xml->writeElement('description', $this->description);
|
|
| 166 |
$xml->writeElement('version', $this->version);
|
|
| 167 |
$xml->writeElement('state', $this->state);
|
|
| 168 | 64 |
|
| 169 |
if($this->categories) {
|
|
| 170 |
$xml->startElement('categories');
|
|
| 171 |
foreach($this->categories as $category) {
|
|
| 172 |
$xml->writeElement('category', $category);
|
|
| 173 |
} |
|
| 174 |
$xml->endElement(); // categories |
|
| 175 |
} |
|
| 176 | 65 |
|
| 177 |
if($this->parties) {
|
|
| 178 |
$xml->startElement('parties');
|
|
| 179 |
foreach($this->parties as $party) {
|
|
| 180 |
$party->writeXML($xml); |
|
| 181 |
} |
|
| 182 |
$xml->endElement(); // parties |
|
| 183 |
} |
|
| 184 |
|
|
| 185 |
$xml->startElement('constraints');
|
|
| 186 |
foreach($this->constraintTypes as $constraintType) {
|
|
| 187 |
$constraints = $this->getConstraints($constraintType); |
|
| 188 |
if(count($constraints)) {
|
|
| 189 |
$xml->startElement($constraintType); |
|
| 190 |
foreach($constraints as $constraint) {
|
|
| 191 |
$constraint->writeXML($xml); |
|
| 192 |
} |
|
| 193 |
$xml->endElement(); // constraint type |
|
| 194 |
} |
|
| 195 |
} |
|
| 196 |
$xml->endElement(); // constraints |
|
| 197 |
|
|
| 198 |
$xml->endElement(); // package |
|
| 199 |
|
|
| 200 |
return $xml->outputMemory(); |
|
| 201 |
} |
|
| 202 |
|
|
| 203 |
/** |
|
| 204 |
* @return string The package key |
|
| 205 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 206 |
*/ |
|
| 207 |
public function getPackageKey() {
|
|
| 208 |
return $this->packageKey; |
|
| 209 |
} |
|
| 210 |
|
|
| 211 |
/** |
|
| 212 |
* @return string The package title |
|
| 213 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 214 |
*/ |
|
| 215 |
public function getTitle() {
|
|
| 216 |
return $this->title; |
|
| 217 |
} |
|
| 218 |
|
|
| 219 |
/** |
|
| 220 |
* @param string $title: The package title |
|
| 221 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 222 |
*/ |
|
| 223 |
public function setTitle($title) {
|
|
| 224 |
$this->title = $title; |
|
| 225 |
} |
|
| 226 |
|
|
| 227 |
/** |
|
| 228 |
* @return string The package version |
|
| 229 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 230 |
*/ |
|
| 231 |
public function getVersion() {
|
|
| 232 |
return $this->version; |
|
| 233 |
} |
|
| 234 |
|
|
| 235 |
/** |
|
| 236 |
* @param string $version: The package version to set |
|
| 237 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 238 |
*/ |
|
| 239 |
public function setVersion($version) {
|
|
| 240 |
$this->version = $version; |
|
| 241 |
} |
|
| 242 |
|
|
| 243 |
/** |
|
| 244 |
* @return string The package description |
|
| 245 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 246 |
*/ |
|
| 247 |
public function getDescription() {
|
|
| 248 |
return $this->description; |
|
| 249 |
} |
|
| 250 |
|
|
| 251 |
/** |
|
| 252 |
* @param string $description: The package description to set |
|
| 253 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 254 |
*/ |
|
| 255 |
public function setDescription($description) {
|
|
| 256 |
$this->description = $description; |
|
| 257 |
} |
|
| 258 |
|
|
| 259 |
/** |
|
| 260 |
* The package state can be one of: |
|
| 261 |
* Development, Alpha, Beta, ReleaseCandidate, Final or Obsolete |
|
| 262 |
* |
|
| 263 |
* @return string The package state |
|
| 264 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 265 |
*/ |
|
| 266 |
public function getState() {
|
|
| 267 |
return $this->state; |
|
| 268 |
} |
|
| 269 |
|
|
| 270 |
/** |
|
| 271 |
* @param string $state: The package state to set (Alpha, Beta, ...) |
|
| 272 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 273 |
* @todo Only accept valid states |
|
| 274 |
*/ |
|
| 275 |
public function setState($state) {
|
|
| 276 |
$this->state = $state; |
|
| 277 |
} |
|
| 278 |
|
|
| 279 |
/** |
|
| 280 |
* @return Array of string The package categories |
|
| 281 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 282 |
*/ |
|
| 283 |
public function getCategories() {
|
|
| 284 |
return $this->categories; |
|
| 285 |
} |
|
| 286 |
|
|
| 287 |
/** |
|
| 288 |
* Adds a package category |
|
| 289 |
* |
|
| 290 |
* @param string $category |
|
| 291 |
*/ |
|
| 292 |
public function addCategory($category) {
|
|
| 293 |
$this->categories[] = $category; |
|
| 294 |
} |
|
| 295 |
|
|
| 296 |
/** |
|
| 297 |
* @return Array of F3_FLOW3_Package_Meta_Party The package parties |
|
| 298 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 299 |
*/ |
|
| 300 |
public function getParties() {
|
|
| 301 |
return $this->parties; |
|
| 302 |
} |
|
| 303 |
|
|
| 304 |
/** |
|
| 305 |
* Add a party |
|
| 306 |
* |
|
| 307 |
* @param F3_FLOW3_Package_Meta_Party $party |
|
| 308 |
*/ |
|
| 309 |
public function addParty(F3_FLOW3_Package_Meta_Party $party) {
|
|
| 310 |
$this->parties[] = $party; |
|
| 311 |
} |
|
| 312 |
|
|
| 313 |
/** |
|
| 314 |
* @param string $constraintType: Type of the constraints to get: depends, conflicts, suggests |
|
| 315 |
* @return Array of F3_FLOW3_Package_Meta_Constraint Package constraints |
|
| 316 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 317 |
*/ |
|
| 318 |
public function getConstraints($constraintType) {
|
|
| 319 |
if(!isset($this->constraints[$constraintType])) return array(); |
|
| 320 |
return $this->constraints[$constraintType]; |
|
| 321 |
} |
|
| 322 |
|
|
| 323 |
/** |
|
| 324 |
* Add a constraint |
|
| 325 |
* |
|
| 326 |
* @param F3_FLOW3_Package_Meta_Constraint $constraint |
|
| 327 |
*/ |
|
| 328 |
public function addConstraint($constraint) {
|
|
| 329 |
$this->constraints[$constraint->getConstraintType()][] = $constraint; |
|
| 330 |
} |
|
| 331 | 66 |
} |
| 67 |
|
|
| 332 | 68 |
?> |
| Classes/Package/F3_FLOW3_Package_MetaInterface.php (Arbeitskopie) | ||
|---|---|---|
| 21 | 21 |
*/ |
| 22 | 22 |
|
| 23 | 23 |
/** |
| 24 |
* Interface for TYPO3 Package Meta information |
|
| 24 |
* Interface for Package Meta information |
|
| 25 | 25 |
* |
| 26 | 26 |
* @package FLOW3 |
| 27 | 27 |
* @subpackage Package |
| ... | ... | |
| 32 | 32 |
interface F3_FLOW3_Package_MetaInterface {
|
| 33 | 33 |
|
| 34 | 34 |
/** |
| 35 |
* Constructor |
|
| 35 |
* Package meta model constructor |
|
| 36 | 36 |
* |
| 37 |
* @param string The package key |
|
| 38 |
* @param [SimpleXMLElement] If specified, the XML data (which must be valid package meta XML) will be used to set the meta properties |
|
| 37 |
* @param string $packageKey: The package key |
|
| 38 | 39 |
* @return void |
| 39 | 40 |
*/ |
| 41 |
public function __construct($packageKey, SimpleXMLElement $packageMetaXML = NULL); |
|
| 40 |
public function __construct($packageKey); |
|
| 41 | 42 |
|
| 42 |
/** |
|
| 43 |
* @return string The package key |
|
| 44 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 45 |
*/ |
|
| 46 |
public function getPackageKey(); |
|
| 47 |
|
|
| 48 |
/** |
|
| 49 |
* @return string The package title |
|
| 50 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 51 |
*/ |
|
| 52 |
public function getTitle(); |
|
| 53 |
|
|
| 54 |
/** |
|
| 55 |
* @return string The package version |
|
| 56 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 57 |
*/ |
|
| 58 |
public function getVersion(); |
|
| 59 |
|
|
| 60 |
/** |
|
| 61 |
* @return string The package description |
|
| 62 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 63 |
*/ |
|
| 64 |
public function getDescription(); |
|
| 65 |
|
|
| 66 |
/** |
|
| 67 |
* @return string The package state |
|
| 68 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 69 |
*/ |
|
| 70 |
public function getState(); |
|
| 71 |
|
|
| 72 |
|
|
| 73 |
/** |
|
| 74 |
* @return Array of string The package categories |
|
| 75 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 76 |
*/ |
|
| 77 |
public function getCategories(); |
|
| 78 |
|
|
| 79 |
|
|
| 80 |
/** |
|
| 81 |
* @return Array of F3_FLOW3_Package_Meta_Party The package parties |
|
| 82 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 83 |
*/ |
|
| 84 |
public function getParties(); |
|
| 85 |
|
|
| 86 |
|
|
| 87 |
/** |
|
| 88 |
* @param string $constraintType: Type of the constraints to get: depends, conflicts, suggests |
|
| 89 |
* @return Array of F3_FLOW3_Package_Meta_Constraint Package constraints |
|
| 90 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 91 |
*/ |
|
| 92 |
public function getConstraints($constraintType); |
|
| 93 | 43 |
} |
| 94 | 44 |
?> |
| Classes/Package/F3_FLOW3_Package_Manager.php (Arbeitskopie) | ||
|---|---|---|
| 62 | 62 |
); |
| 63 | 63 |
|
| 64 | 64 |
/** |
| 65 |
* @var array Array of package keys that are protected and that should not be removed |
|
| 66 |
*/ |
|
| 67 |
protected $protectedPackages = array('FLOW3', 'PHP6');
|
|
| 68 |
|
|
| 69 |
/** |
|
| 70 | 65 |
* Initializes the package manager |
| 71 | 66 |
* |
| 72 | 67 |
* @return void |
| 73 | 68 |
* @author Robert Lemke <robert@typo3.org> |
| 74 | 69 |
*/ |
| 75 | 70 |
public function initialize() {
|
| 76 |
$this->rescanPackages(); |
|
| 77 |
$this->arrayOfActivePackages = $this->packages; |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
/** |
|
| 81 |
* Scans the package directory for available packages and stores them in available package list. |
|
| 82 |
* |
|
| 83 |
* @return void |
|
| 84 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 85 |
*/ |
|
| 86 |
public function rescanPackages() {
|
|
| 87 | 71 |
$this->packages = $this->scanAvailablePackages(); |
| 88 | 72 |
foreach (array_keys($this->packages) as $upperCamelCasedPackageKey) {
|
| 89 | 73 |
$this->packageKeys[strtolower($upperCamelCasedPackageKey)] = $upperCamelCasedPackageKey; |
| ... | ... | |
| 104 | 88 |
} |
| 105 | 89 |
|
| 106 | 90 |
/** |
| 107 |
* Returns TRUE if a package is activated or FALSE if it's not. |
|
| 108 |
* |
|
| 109 |
* @param string $packageKey: The key of the package to check |
|
| 110 |
* @return boolean TRUE if package is active, otherwise FALSE |
|
| 111 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 112 |
*/ |
|
| 113 |
public function isPackageActive($packageKey) {
|
|
| 114 |
if (!is_string($packageKey)) throw new InvalidArgumentException('The package key must be of type string, ' . gettype($packageKey) . ' given.', 1200402593);
|
|
| 115 |
return (key_exists($packageKey, $this->arrayOfActivePackages)); |
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
/** |
|
| 119 | 91 |
* Returns a F3_FLOW3_Package_PackageInterface object for the specified package. |
| 120 | 92 |
* A package is available, if the package directory contains valid meta information. |
| 121 | 93 |
* |
| ... | ... | |
| 147 | 119 |
* |
| 148 | 120 |
* @return array Array of F3_FLOW3_Package_Meta |
| 149 | 121 |
* @author Robert Lemke <robert@typo3.org> |
| 122 |
* @todo Implement activation / deactivation of packages |
|
| 150 | 123 |
*/ |
| 151 | 124 |
public function getActivePackages() {
|
| 125 |
return $this->packages; |
|
| 152 |
return $this->arrayOfActivePackages; |
|
| 153 | 126 |
} |
| 154 | 127 |
|
| 155 | 128 |
/** |
| ... | ... | |
| 195 | 168 |
} |
| 196 | 169 |
|
| 197 | 170 |
/** |
| 198 |
* Check the conformance of the given package key |
|
| 199 |
* |
|
| 200 |
* @param string $packageKey: The package key to validate |
|
| 201 |
*/ |
|
| 202 |
public function isPackageKeyValid($packageKey) {
|
|
| 203 |
return preg_match(F3_FLOW3_Package_Package::PATTERN_MATCH_PACKAGEKEY, $packageKey) == true; |
|
| 204 |
} |
|
| 205 |
|
|
| 206 |
/** |
|
| 207 |
* Create a package, given the package key |
|
| 208 |
* |
|
| 209 |
* @param String $packageKey |
|
| 210 |
* @return F3_FLOW3_Package_Package The newly created package |
|
| 211 |
* @todo Create non-empty Package.xml |
|
| 212 |
*/ |
|
| 213 |
public function createPackage($packageKey, F3_FLOW3_Package_Meta $packageMeta = null) {
|
|
| 214 |
if(!$this->isPackageKeyValid($packageKey)) throw new F3_FLOW3_Package_Exception_InvalidPackageKey('The package key "' . $packageKey . '" is invalid', 1220722210);
|
|
| 215 |
if($this->isPackageAvailable($packageKey)) throw new F3_FLOW3_Package_Exception_PackageKeyAlreadyExists('The package key "' . $packageKey . '" does already exist', 1220722873);
|
|
| 216 |
|
|
| 217 |
if($packageMeta == null) {
|
|
| 218 |
$packageMeta = new F3_FLOW3_Package_Meta($packageKey); |
|
| 219 |
} |
|
| 220 |
|
|
| 221 |
$packagePath = FLOW3_PATH_PACKAGES . $packageKey . '/'; |
|
| 222 |
F3_FLOW3_Utility_Files::createDirectoryRecursively($packagePath); |
|
| 223 |
|
|
| 224 |
foreach(array( |
|
| 225 |
F3_FLOW3_Package_Package::DIRECTORY_META, |
|
| 226 |
F3_FLOW3_Package_Package::DIRECTORY_CLASSES, |
|
| 227 |
F3_FLOW3_Package_Package::DIRECTORY_CONFIGURATION, |
|
| 228 |
F3_FLOW3_Package_Package::DIRECTORY_DOCUMENTATION, |
|
| 229 |
F3_FLOW3_Package_Package::DIRECTORY_RESOURCES, |
|
| 230 |
F3_FLOW3_Package_Package::DIRECTORY_TESTS |
|
| 231 |
) as $path) {
|
|
| 232 |
F3_FLOW3_Utility_Files::createDirectoryRecursively($packagePath . $path); |
|
| 233 |
} |
|
| 234 |
|
|
| 235 |
$packageXmlPath = $packagePath . F3_FLOW3_Package_Package::DIRECTORY_META . F3_FLOW3_Package_Package::FILENAME_PACKAGEINFO; |
|
| 236 |
$packageXml = $packageMeta->getPackageXML(); |
|
| 237 |
file_put_contents($packageXmlPath, $packageXml); |
|
| 238 |
|
|
| 239 |
$this->rescanPackages(); |
|
| 240 |
|
|
| 241 |
return $this->getPackage($packageKey); |
|
| 242 |
} |
|
| 243 |
|
|
| 244 |
/** |
|
| 245 |
* Deactivates a packe if it is in the list of active packages |
|
| 246 |
* |
|
| 247 |
* @param string $packageKey: The package to deactivate |
|
| 248 |
* @throws F3_FLOW3_Package_Exception_UnknownPackage if the specified package is not known |
|
| 249 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 250 |
*/ |
|
| 251 |
public function deactivatePackage($packageKey) {
|
|
| 252 |
if (key_exists($packageKey,$this->getActivePackages())) {
|
|
| 253 |
unset($this->arrayOfActivePackages[$packageKey]); |
|
| 254 |
} else {
|
|
| 255 |
throw new F3_FLOW3_Package_Exception_UnknownPackage('Package "' . $packageKey . '" is not available.', 1166543253);
|
|
| 256 |
} |
|
| 257 |
} |
|
| 258 |
|
|
| 259 |
/** |
|
| 260 |
* Activates a package |
|
| 261 |
* |
|
| 262 |
* @param string $packageKey: The package to activate |
|
| 263 |
* @author Thomas Hempel <thomas@typo3.org> |
|
| 264 |
*/ |
|
| 265 |
public function activatePackage($packageKey) {
|
|
| 266 |
$package = $this->getPackage($packageKey); |
|
| 267 |
$this->arrayOfActivePackages[$packageKey] = $package; |
|
| 268 |
} |
|
| 269 |
|
|
| 270 |
/** |
|
| 271 |
* Removes a package from registry and deletes it from filesystem |
|
| 272 |
* |
|
| 273 |
* @param string $packageKey: package to remove |
|
| 274 |
* @throws F3_FLOW3_Package_Exception_UnknownPackage if the specified package is not known |
|
| 275 |
*/ |
|
| 276 |
public function removePackage($packageKey) {
|
|
| 277 |
// check if the package key is protected |
|
| 278 |
if (in_array($packageKey, $this->protectedPackages)) throw new F3_FLOW3_Package_Exception_ProtectedPackageKey('The package "' . $packageKey . '" is protected and can not be removed.', 1220722120);
|
|
| 279 |
|
|
| 280 |
// check wether the package is available or not |
|
| 281 |
if (!$this->isPackageAvailable($packageKey)) throw new F3_FLOW3_Package_Exception_UnknownPackage('Package "' . $packageKey . '" is not available and can not be removed though.', 1166543253);
|
|
| 282 |
|
|
| 283 |
// deactivate package before we remove it |
|
| 284 |
if ($this->isPackageActive($packageKey)) {
|
|
| 285 |
$this->deactivatePackage($packageKey); |
|
| 286 |
} |
|
| 287 |
|
|
| 288 |
// unlink in filesystem |
|
| 289 |
$packagePath = $this->getPackagePath($packageKey); |
|
| 290 |
F3_FLOW3_Utility_Files::removeDirectoryRecursively($packagePath); |
|
| 291 |
|
|
| 292 |
// rescan packages |
|
| 293 |
$this->rescanPackages(); |
|
| 294 |
} |
|
| 295 |
|
|
| 296 |
/** |
|
| 297 | 171 |
* Scans all directories in the Packages/ directory for available packages. |
| 298 | 172 |
* For each package a F3_FLOW3_Package_ object is created and returned as |
| 299 | 173 |
* an array. |
| Classes/Package/Exception/F3_FLOW3_Package_Exception_ProtectedPackageKey.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id: F3_FLOW3_Package_Exception_InvalidPackageKey.php 1080 2008-08-05 19:38:38Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* An "Protected Package Key" exception |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id: F3_FLOW3_Package_Exception_InvalidPackageKey.php 1080 2008-08-05 19:38:38Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Package_Exception_ProtectedPackageKey extends F3_FLOW3_Package_Exception {
|
|
| 32 |
|
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
?> |
|
| Classes/Package/Exception/F3_FLOW3_Package_Exception_PackageKeyAlreadyExists.php (Revision 0) | ||
|---|---|---|
| 1 |
<?php |
|
| 2 |
declare(ENCODING = 'utf-8'); |
|
| 3 |
|
|
| 4 |
/* * |
|
| 5 |
* This script is part of the TYPO3 project - inspiring people to share! * |
|
| 6 |
* * |
|
| 7 |
* TYPO3 is free software; you can redistribute it and/or modify it under * |
|
| 8 |
* the terms of the GNU General Public License version 2 as published by * |
|
| 9 |
* the Free Software Foundation. * |
|
| 10 |
* * |
|
| 11 |
* This script is distributed in the hope that it will be useful, but * |
|
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- * |
|
| 13 |
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General * |
|
| 14 |
* Public License for more details. * |
|
| 15 |
* */ |
|
| 16 |
|
|
| 17 |
/** |
|
| 18 |
* @package FLOW3 |
|
| 19 |
* @subpackage Package |
|
| 20 |
* @version $Id: F3_FLOW3_Package_Exception_InvalidPackageKey.php 1080 2008-08-05 19:38:38Z robert $ |
|
| 21 |
*/ |
|
| 22 |
|
|
| 23 |
/** |
|
| 24 |
* An "Package Key Already Exists" exception |
|
| 25 |
* |
|
| 26 |
* @package FLOW3 |
|
| 27 |
* @subpackage Package |
|
| 28 |
* @version $Id: F3_FLOW3_Package_Exception_InvalidPackageKey.php 1080 2008-08-05 19:38:38Z robert $ |
|
| 29 |
* @license http://opensource.org/licenses/gpl-license.php GNU Public License, version 2 |
|
| 30 |
*/ |
|
| 31 |
class F3_FLOW3_Package_Exception_PackageKeyAlreadyExists extends F3_FLOW3_Package_Exception {
|
|
| 32 |
|
|
| 33 |
} |
|
| 34 |
|
|
| 35 |
?> |
|
| Classes/Package/F3_FLOW3_Package_ManagerInterface.php (Arbeitskopie) | ||
|---|---|---|
| 40 | 40 |
*/ |
| 41 | 41 |
public function initialize(); |
| 42 | 42 |
|
| 43 |
|
|
| 44 | 43 |
/** |
| 45 |
* Scans the package directory for available packages and stores them in available package list. |
|
| 46 |
* |
|
| 47 |
* @return void |
|
| 48 |
*/ |
|
| 49 |
public function rescanPackages(); |
|
| 50 |
|
|
| 51 |
/** |
|
| 52 | 44 |
* Returns TRUE if a package is available (the package's files exist in the packages directory) |
| 53 | 45 |
* or FALSE if it's not. If a package is available it doesn't mean neccessarily that it's active! |
| 54 | 46 |
* |
| ... | ... | |
| 56 | 48 |
* @return boolean TRUE if the package is available, otherwise FALSE |
| 57 | 49 |
*/ |
| 58 | 50 |
public function isPackageAvailable($packageKey); |
| 51 |
|
|
| 59 |
|
|
| 60 | 52 |
/** |
| 61 |
* Returns TRUE if a package is activated or FALSE if it's not. |
|
| 62 |
* |
|
| 63 |
* @param string $packageKey: The key of the package to check |
|
| 64 |
* @return boolean TRUE if package is active, otherwise FALSE |
|
| 65 |
*/ |
|
| 66 |
public function isPackageActive($packageKey); |
|
| 67 |
|
|
| 68 |
/** |
|
| 69 | 53 |
* Returns a F3_FLOW3_Package_PackageInterface object for the specified package. |
| 70 | 54 |
* A package is available, if the package directory contains valid meta information. |
| 71 | 55 |
* |
| ... | ... | |
| 83 | 67 |
public function getAvailablePackages(); |
| 84 | 68 |
|
| 85 | 69 |
/** |
| 70 |
* Returns an array of F3_FLOW3_Package_Meta objects of all active packages. |
|
| 86 |
* Returns an array of Package objects of all active packages. |
|
| 87 | 71 |
* A package is active, if it is available and has been activated in the package |
| 88 | 72 |
* manager settings. |
| 89 | 73 |
* |
| ... | ... | |
| 116 | 100 |
*/ |
| 117 | 101 |
public function getPackageClassesPath($packageKey); |
| 118 | 102 |
|
| 103 |
# public function activatePackage($packageKey); |
|
| 104 |
# public function deactivatePackage($packageKey); |
|
| 105 |
# public function removePackage($packageKey); |
|
| 106 |
# public function downloadPackageFromRepository($packageKey, $version); |
|
| 119 |
/** |
|
| 120 |
* Check the conformance of the given package key |
|
| 121 |
* |
|
| 122 |
* @param string $packageKey: The package key to validate |
|
| 123 |
*/ |
|
| 124 |
public function isPackageKeyValid($packageKey); |
|
| 125 |
|
|
| 126 |
/** |
|
| 127 |
* Create a new package, given the package key |
|
| 128 |
* |
|
| 129 |
* @param String $packageKey: The package key to use for the new package |
|
| 130 |
* @return F3_FLOW3_Package_Package The newly created package |
|
| 131 |
*/ |
|
| 132 |
public function createPackage($packageKey, F3_FLOW3_Package_Meta $packageMeta = null); |
|
| 133 |
|
|
| 134 |
/** |
|
| 135 |
* Deactivates a packe if it is in the list of active packages |
|
| 136 |
* |
|
| 137 |
* @param string $packageKey: The package to deactivate |
|
| 138 |
*/ |
|
| 139 |
public function deactivatePackage($packageKey); |
|
| 140 |
|
|
| 141 |
/** |
|
| 142 |
* Activates a package |
|
| 143 |
* |
|
| 144 |
* @param string $packageKey: The package to activate |
|
| 145 |
*/ |
|
| 146 |
public function activatePackage($packageKey); |
|
| 147 |
|
|
| 148 |
/** |
|
| 149 |
* Removes a package from registry and deletes it from filesystem |
|
| 150 |
* |
|
| 151 |
* @param string $packageKey: package to remove |
|
| 152 |
*/ |
|
| 153 |
public function removePackage($packageKey); |
|
| 154 |
|
|
| 155 |
|
|
| 156 |
# public function downloadPackageFromRepository($packageKey, $version); |
|
| 157 | 107 |
|
| 158 | 108 |
} |
| 159 | 109 |
?> |
| Classes/Package/F3_FLOW3_Package_Package.php (Arbeitskopie) | ||
|---|---|---|
| 33 | 33 |
const PATTERN_MATCH_PACKAGEKEY = '/^[A-Z][A-Za-z0-9]+$/'; |
| 34 | 34 |
|
| 35 | 35 |
const DIRECTORY_CLASSES = 'Classes/'; |
| 36 |
const DIRECTORY_TESTS = 'Tests/'; |
|
| 37 | 36 |
const DIRECTORY_CONFIGURATION = 'Configuration/'; |
| 38 | 37 |
const DIRECTORY_DOCUMENTATION = 'Documentation/'; |
| 39 | 38 |
const DIRECTORY_META = 'Meta/'; |
| ... | ... | |
| 55 | 54 |
/** |
| 56 | 55 |
* @var F3_FLOW3_Package_Meta Meta information about this package |
| 57 | 56 |
*/ |
| 57 |
protected $packageMeta; |
|
| 58 |
protected $packageMeta = null; |
|
| 59 | 58 |
|
| 60 | 59 |
/** |
| 61 | 60 |
* @var array Names and relative paths (to this package directory) of files containing classes |
| ... | ... | |
| 70 | 69 |
* @throws F3_FLOW3_Package_Exception_InvalidPackageKey if an invalid package key was passed |
| 71 | 70 |
* @throws F3_FLOW3_Package_Exception_InvalidPackagePath if an invalid package path was passed |
| 72 | 71 |
* @author Robert Lemke <robert@typo3.org> |
| 73 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 74 | 72 |
*/ |
| 75 | 73 |
public function __construct($packageKey, $packagePath) {
|
| 76 | 74 |
if (!preg_match(self::PATTERN_MATCH_PACKAGEKEY, $packageKey)) throw new F3_FLOW3_Package_Exception_InvalidPackageKey('"' . $packageKey . '" is not a valid package key.', 1217959510);
|
| ... | ... | |
| 79 | 77 |
|
| 80 | 78 |
$this->packageKey = $packageKey; |
| 81 | 79 |
$this->packagePath = $packagePath; |
| 80 |
$this->packageMeta = new F3_FLOW3_Package_Meta($packagePath . self::DIRECTORY_META . self::FILENAME_PACKAGEINFO); |
|
| 82 | 81 |
} |
| 83 | 82 |
|
| 84 | 83 |
/** |
| 85 | 84 |
* Returns the package meta object of this package. |
| 86 |
* |
|
| 87 |
* The meta data is lazily populated from the Package.xml |
|
| 88 | 85 |
* |
| 89 | 86 |
* @return F3_FLOW3_Package_Meta |
| 90 | 87 |
* @author Robert Lemke <robert@typo3.org> |
| 91 |
* @author Christopher Hlubek <hlubek@networkteam.com> |
|
| 92 | 88 |
*/ |
| 93 | 89 |
public function getPackageMeta() {
|
| 94 |
if($this->packageMeta == null) {
|
|
| 95 |
$this->packageMeta = new F3_FLOW3_Package_Meta($this->packageKey); |
|
| 96 |
$packageXml = simplexml_load_file($this->packagePath . self::DIRECTORY_META . self::FILENAME_PACKAGEINFO); |
|
| 97 |
if($packageXml) {
|
|
| 98 |
$this->packageMeta->setMetaFromXML($packageXml); |
|
| 99 |
} |
|
| 100 |
} |
|
| 101 | 90 |
return $this->packageMeta; |
| 102 | 91 |
} |
| 103 | 92 |
|