1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
<?php
/*
* This file is part of the ICanBoogie package.
*
* (c) Olivier Laviale <olivier.laviale@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace ICanBoogie\Module;
/**
* Module descriptor options.
*
* @package ICanBoogie\Module
*/
final class Descriptor
{
/**
* Defines the category for the module.
*
* When modules are listed they are usually grouped by category. The category is also often
* used to create the main navigation menu of the admin interface.
*
* The category of the module is translated within the `module_category` scope.
*/
const CATEGORY = 'category';
/**
* Defines the PHP class of the module.
*
* If the class is not defined it is resolved during indexing using the {@link NS}
* tag and the following pattern : `<namespace>\Module`.
*/
const CLASSNAME = 'class';
/**
* Defines a short description of what the module do.
*/
const DESCRIPTION = 'description';
/**
* Defines the state of the module.
*/
const DISABLED = 'disabled';
/**
* Defines extra values.
*/
const EXTRA = 'extra';
/**
* Defines the parent module the module inherits from.
*/
const INHERITS = 'extends'; // TODO-20101017: change to 'inherits' once the transition is over
/**
* Defines the identifier of the module.
*
* If the identifier is not defined the name of the module directory is used instead.
*/
const ID = 'id';
/**
* Defines the state of the module.
*
* Required modules are always enabled.
*/
const REQUIRED = 'required';
/**
* Defines the modules that the module requires.
*
* The required modules are defined using an array of identifiers.
*/
const REQUIRES = 'requires';
/**
* Defines the models of the module.
*/
const MODELS = 'models';
/**
* Defines the namespace of the module.
*
* This attribute must be defined at construct time.
*/
const NS = 'namespace';
/**
* Path to the module's directory.
*
* This tag is resolved when the module is indexed.
*/
const PATH = 'path';
/**
* General permission of the module.
*/
const PERMISSION = 'permission';
/**
* Defines the permissions added by the module.
*/
const PERMISSIONS = 'permissions';
/**
* Defines the title of the module.
*
* The title of the module is translated within the `module_title` scope.
*/
const TITLE = 'title';
/**
* Defines the weight of the module.
*
* The weight of the module is resolved during modules indexing according to the
* {@link EXTENDS} and {@link REQUIRES} tags.
*/
const WEIGHT = 'weight';
/**
* Normalizes a descriptor array.
*
* @param array $descriptor
*
* @return array
*/
static public function normalize(array $descriptor)
{
return $descriptor + [
Descriptor::CATEGORY => null,
Descriptor::CLASSNAME => $descriptor[Descriptor::NS] . '\Module',
Descriptor::DESCRIPTION => null,
Descriptor::DISABLED => false,
Descriptor::EXTRA => [],
Descriptor::INHERITS => null,
Descriptor::ID => null,
Descriptor::MODELS => [],
Descriptor::PATH => null,
Descriptor::PERMISSION => null,
Descriptor::PERMISSIONS => [],
Descriptor::REQUIRED => false,
Descriptor::REQUIRES => [],
Descriptor::WEIGHT => 0
];
}
private function __construct() {}
}