Common & useful classes, resources, extensions. Based on Symfony framework.
Located here: Meritoo\CommonBundle\Bundle\Descriptor
. Contains information about bundle such as:
- Name of bundle
- Short, simple name of bundle
- Name of configuration root node of bundle
- Root namespace of bundle
- Physical path of bundle
- Descriptor of the parent bundle
- Descriptor of the child bundle
- Names of files with data fixtures from bundle
There are 3 ways to create new instance:
$descriptor = new Descriptor(
'SimpleBundle',
'simple_test',
'Meritoo\Test\CommonBundle\Bundle\Descriptor',
'/tests/Bundle/Descriptor',
new Descriptor('ParentBundle', 'parent_test'),
new Descriptor('ChildBundle', 'child_test')
);
$descriptor = Descriptor::fromArray([
'name' => 'SimpleBundle',
'configurationRootName' => 'simple_test',
'rootNamespace' => 'Meritoo\Test\CommonBundle\Bundle\Descriptor',
'path' => '/tests/Bundle/Descriptor',
'parentBundleDescriptor' => [
'name' => 'ParentBundle',
'configurationRootName' => 'parent_test',
],
'childBundleDescriptor' => [
'name' => 'ChildBundle',
'configurationRootName' => 'child_test',
'rootNamespace' => 'Meritoo\Test\CommonBundle\Bundle\Descriptor\Child',
],
]);
$bundle = new SimpleBundle(),
$descriptor = Descriptor::fromBundle($bundle);
Useful when your bundle:
- Extends another bundle (has parent bundle) or
- Is extended by another bundle (has child bundle)
In those situations you can access descriptors of those bundles using methods:
$descriptor->getParentBundleDescriptor()
$descriptor->getChildBundleDescriptor()
Returns short, simple name of bundle
Example:
$descriptor = new Descriptor('SimpleBundle');
$shortName = $descriptor->getShortName(); // "simple"
Returns real/full path of directory from bundle with classes for the DataFixtures
$descriptor = new Descriptor('', '', '', 'path/of/bundle');
$path = $descriptor->getDataFixturesDirectoryPath(); // "/path/of/bundle/DataFixtures/ORM"
Returns information if given file belongs to this bundle
$descriptor = new Descriptor('', '', '', 'dapibus/venenatis/quam');
$hasFile = $descriptor->hasFile($filePath); // true
Returns an array representation of the descriptor
$descriptor = new Descriptor(
'PortaCommodoBundle',
'Commodo',
'Porta\CommodoBundle',
'etiam/risus/parturient'
);
$array = $descriptor->toArray();
/*
* Result:
*
* [
* 'name' => 'PortaCommodoBundle',
* 'shortName' => 'portacommodo',
* 'configurationRootName' => 'Commodo',
* 'rootNamespace' => 'Porta\CommodoBundle',
* 'path' => 'etiam/risus/parturient',
* 'dataFixtures' => [],
* ];
*/
- Configuration
- Dependency Injection Extension
- Descriptor of application
- Descriptor of bundle
- Descriptors of bundles
- Services:
- Tests
- Translations
- Twig extensions: