Skip to content
This repository was archived by the owner on Jun 24, 2020. It is now read-only.

Commit f037866

Browse files
author
Steven Rombauts
committed
Do not force naming conventions on extensions and components
1 parent 76e30b9 commit f037866

File tree

4 files changed

+12
-63
lines changed

4 files changed

+12
-63
lines changed

README.md

+4-22
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,12 @@ To make your extension installable through Composer, add a `composer.json` file
1717
"name": "vendor/com_name",
1818
"type": "joomla-extension",
1919
"require": {
20-
"nooku/nooku-framework": "dev-develop"
20+
"nooku/nooku-framework": "2.*"
2121
}
2222
}
2323
```
2424

25-
Note: the `nooku/nooku-framework` framework requirement will also install this installer plugin. If you did not build your package on top of the [Nooku Framework](http://github.com/nooku/nooku-framework), you can simply require this plugin instead: `"nooku/installer": "*"`.
26-
27-
#### Package name
28-
29-
The `name` attribute of your composer.json manifest must always be in the following format: `vendor/xyz_name`, where `xyz` is any of the following:
30-
31-
* `com` (component)
32-
* `plg` (plugin)
33-
* `mod` (module)
34-
* `tpl` (template)
35-
* `pkg` ([package](http://docs.joomla.org/Package))
36-
* `lib` (library)
37-
* `lng` (language)
38-
* `file` (file package)
39-
40-
This prefix indicates the type of package your extension contains. Refer to the Joomla documentation for a list of the [the available types](http://docs.joomla.org/Manifest_files#Root_element).
41-
42-
Any other naming format will be rejected.
25+
Note: the `nooku/nooku-framework` framework requirement will also install this installer plugin. If you did not build your package on top of the [Nooku Framework](http://github.com/nooku/nooku-framework), you can simply require this plugin instead: `"nooku/installer": "1.*"`.
4326

4427
#### Repository layout
4528

@@ -63,7 +46,7 @@ Your package's `composer.json` file should contain at least the following direct
6346
"type": "nooku-component",
6447
"license": "GPLv3",
6548
"require": {
66-
"nooku/installer": "*"
49+
"nooku/installer": "1.*"
6750
},
6851
"autoload": {
6952
"files": ["autoload.php"]
@@ -77,7 +60,6 @@ Place this `composer.json` file in the root folder of your component's repositor
7760
The following settings are required to make your component installable through Composer:
7861

7962
* The `type` directive must be set to `nooku-component`.
80-
* The `name` directive must end with the `-component` suffix.
8163
* You must make sure to require the `nooku/installer` package so that Composer knows how to handle your package.
8264
* You must include the `autoload` directive. You do not, however, need to include the `autoload.php` file yourself. The plugin will autogenerate it for you if it's not found in the repository.
8365

@@ -92,7 +74,7 @@ To install the framework, create a composer.json manifest in your Joomla install
9274
```json
9375
{
9476
"require": {
95-
"nooku/nooku-framework": "dev-develop"
77+
"nooku/nooku-framework": "2.*"
9678
},
9779
"minimum-stability": "dev"
9880
}

src/Nooku/Composer/Installer/JoomlaExtension.php

-37
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
*/
2626
class JoomlaExtension extends LibraryInstaller
2727
{
28-
protected $_package_prefixes = array('com', 'plg', 'mod', 'tpl', 'pkg', 'file', 'lib', 'lng');
29-
3028
protected $_application = null;
3129
protected $_credentials = array();
3230
protected $_config = null;
@@ -74,14 +72,6 @@ protected function _initialize()
7472
*/
7573
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
7674
{
77-
if (!$this->_isValidName($package->getPrettyName()))
78-
{
79-
throw new \InvalidArgumentException(
80-
'Invalid package name `'.$package->getPrettyName().'`. '.
81-
'Name should be of the format `vendor/xyz_name`, where xyz is a valid Joomla extension type (' . implode(', ', $this->_package_prefixes) . ').'
82-
);
83-
}
84-
8575
parent::install($repo, $package);
8676

8777
if(!$this->_application->install($this->getInstallPath($package)))
@@ -103,14 +93,6 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa
10393
*/
10494
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
10595
{
106-
if (!$this->_isValidName($target->getPrettyName()))
107-
{
108-
throw new \InvalidArgumentException(
109-
'Invalid package name `'.$target->getPrettyName().'`. '.
110-
'Name should be of the format `vendor/xyz_name`, where xyz is a valid Joomla extension type (' . implode(', ', $this->_package_prefixes) . ').'
111-
);
112-
}
113-
11496
parent::update($repo, $initial, $target);
11597

11698
if(!$this->_application->update($this->getInstallPath($target)))
@@ -265,25 +247,6 @@ protected function _bootstrap()
265247
}
266248
}
267249

268-
/**
269-
* Checks to see if the given package name confirms to our naming convention.
270-
*
271-
* @param $packageName
272-
* @return bool
273-
*/
274-
protected function _isValidName($packageName)
275-
{
276-
list(, $name) = explode('/', $packageName);
277-
278-
if (is_null($name) || empty($name)) {
279-
return false;
280-
}
281-
282-
list($prefix, ) = explode('_', $name, 2);
283-
284-
return in_array($prefix, $this->_package_prefixes);
285-
}
286-
287250
/**
288251
* Initializes the Koowa plugin
289252
*/

src/Nooku/Composer/Installer/NookuComponent.php

-4
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,6 @@ class NookuComponent extends LibraryInstaller
3434
*/
3535
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
3636
{
37-
if (substr($package->getPrettyName(), -strlen('-component')) !== '-component') {
38-
throw new \InvalidArgumentException('The name of any package typed `nooku-component` must be formatted as `vendor/name-component`. Aborting.');
39-
}
40-
4137
parent::install($repo, $package);
4238

4339
$this->_installAutoloader($package);

src/Nooku/Composer/Installer/NookuFramework.php

+8
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ class NookuFramework extends JoomlaExtension
2525
*/
2626
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
2727
{
28+
if (!$this->_isValidName($package->getPrettyName()))
29+
{
30+
throw new \InvalidArgumentException(
31+
'Invalid package name `'.$package->getPrettyName().'`. '.
32+
'The `nooku-framework` composer type can only install the `nooku/nooku-framework` package.'
33+
);
34+
}
35+
2836
parent::install($repo, $package);
2937

3038
$query = 'UPDATE #__extensions SET enabled = 1 WHERE type = \'plugin\' AND element = \'koowa\' AND folder = \'system\'';

0 commit comments

Comments
 (0)