Actualización

This commit is contained in:
Xes
2025-04-10 12:24:57 +02:00
parent 8969cc929d
commit 45420b6f0d
39760 changed files with 4303286 additions and 0 deletions

View File

@@ -0,0 +1,233 @@
<?php
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\EasyExtendsBundle\Bundle;
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
class BundleMetadata
{
/**
* @var BundleInterface
*/
protected $bundle;
/**
* @var string|bool
*/
protected $vendor = false;
/**
* @var bool
*/
protected $valid = false;
/**
* @var string
*/
protected $namespace;
/**
* @var string
*/
protected $name;
/**
* @var bool
*/
protected $extendedDirectory = false;
/**
* @var bool
*/
protected $extendedNamespace = false;
/**
* @var array
*/
protected $configuration = array();
/**
* @var OrmMetadata
*/
protected $ormMetadata = null;
/**
* @var OdmMetadata
*/
protected $odmMetadata = null;
/**
* @var PhpcrMetadata
*/
protected $phpcrMetadata = null;
/**
* @param BundleInterface $bundle
* @param array $configuration
*/
public function __construct(BundleInterface $bundle, array $configuration = array())
{
$this->bundle = $bundle;
$this->configuration = $configuration;
$this->buildInformation();
}
/**
* @return bool
*/
public function isExtendable()
{
// does not extends Application bundle ...
return !(
strpos($this->getClass(), $this->configuration['namespace']) === 0
|| strpos($this->getClass(), 'Symfony') === 0
);
}
/**
* @return string
*/
public function getClass()
{
return get_class($this->bundle);
}
/**
* @return bool
*/
public function isValid()
{
return $this->valid;
}
/**
* @return string
*/
public function getExtendedDirectory()
{
return $this->extendedDirectory;
}
/**
* @return string
*/
public function getVendor()
{
return $this->vendor;
}
/**
* @return string
*/
public function getExtendedNamespace()
{
return $this->extendedNamespace;
}
/**
* @return string
*/
public function getNamespace()
{
return $this->namespace;
}
/**
* return the bundle name.
*
* @return string return the bundle name
*/
public function getName()
{
return $this->name;
}
/**
* @return BundleInterface
*/
public function getBundle()
{
return $this->bundle;
}
/**
* @return OdmMetadata
*/
public function getOdmMetadata()
{
return $this->odmMetadata;
}
/**
* @return OrmMetadata
*/
public function getOrmMetadata()
{
return $this->ormMetadata;
}
/**
* @return PhpcrMetadata
*/
public function getPhpcrMetadata()
{
return $this->phpcrMetadata;
}
/**
* build basic information and check if the bundle respect the following convention
* Vendor/BundleNameBundle/VendorBundleNameBundle.
*
* if the bundle does not respect this convention then the easy extends command will ignore
* this bundle
*/
protected function buildInformation()
{
$information = explode('\\', $this->getClass());
if (!$this->isExtendable()) {
$this->valid = false;
return;
}
if (count($information) != 3) {
$this->valid = false;
return;
}
if ($information[0].$information[1] != $information[2]) {
$this->valid = false;
return;
}
$this->name = $information[count($information) - 1];
$this->vendor = $information[0];
$this->namespace = sprintf('%s\\%s', $this->vendor, $information[1]);
$this->extendedDirectory =
str_replace(':vendor', $this->vendor, $this->configuration['application_dir']).
DIRECTORY_SEPARATOR.
$information[1];
$this->extendedNamespace = sprintf('%s\\%s',
str_replace(':vendor', $this->vendor, $this->configuration['namespace']),
$information[1]
);
$this->valid = true;
$this->ormMetadata = new OrmMetadata($this);
$this->odmMetadata = new OdmMetadata($this);
$this->phpcrMetadata = new PhpcrMetadata($this);
}
}

View File

@@ -0,0 +1,148 @@
<?php
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\EasyExtendsBundle\Bundle;
use Symfony\Component\Finder\Finder;
class OdmMetadata
{
/**
* @var string
*/
protected $mappingDocumentDirectory;
/**
* @var string
*/
protected $extendedMappingDocumentDirectory;
/**
* @var string
*/
protected $documentDirectory;
/**
* @var string
*/
protected $extendedDocumentDirectory;
/**
* @var string
*/
protected $extendedSerializerDirectory;
/**
* @param BundleMetadata $bundleMetadata
*/
public function __construct(BundleMetadata $bundleMetadata)
{
$this->mappingDocumentDirectory = sprintf('%s/Resources/config/doctrine/', $bundleMetadata->getBundle()->getPath());
$this->extendedMappingDocumentDirectory = sprintf('%s/Resources/config/doctrine/', $bundleMetadata->getExtendedDirectory());
$this->documentDirectory = sprintf('%s/Document', $bundleMetadata->getBundle()->getPath());
$this->extendedDocumentDirectory = sprintf('%s/Document', $bundleMetadata->getExtendedDirectory());
$this->extendedSerializerDirectory = sprintf('%s/Resources/config/serializer', $bundleMetadata->getExtendedDirectory());
}
/**
* @return string
*/
public function getMappingDocumentDirectory()
{
return $this->mappingDocumentDirectory;
}
/**
* @return string
*/
public function getExtendedMappingDocumentDirectory()
{
return $this->extendedMappingDocumentDirectory;
}
/**
* @return string
*/
public function getDocumentDirectory()
{
return $this->documentDirectory;
}
/**
* @return string
*/
public function getExtendedDocumentDirectory()
{
return $this->extendedDocumentDirectory;
}
/**
* @return string
*/
public function getExtendedSerializerDirectory()
{
return $this->extendedSerializerDirectory;
}
/**
* @return array|\Iterator
*/
public function getDocumentMappingFiles()
{
try {
$f = new Finder();
$f->name('*.mongodb.xml.skeleton');
$f->in($this->getMappingDocumentDirectory());
return $f->getIterator();
} catch (\Exception $e) {
return array();
}
}
/**
* @return array
*/
public function getDocumentNames()
{
$names = array();
try {
$f = new Finder();
$f->name('*.mongodb.xml.skeleton');
$f->in($this->getMappingDocumentDirectory());
foreach ($f->getIterator() as $file) {
$name = explode('.', basename($file));
$names[] = $name[0];
}
} catch (\Exception $e) {
}
return $names;
}
/**
* @return array|\Iterator
*/
public function getRepositoryFiles()
{
try {
$f = new Finder();
$f->name('*Repository.php');
$f->in($this->getDocumentDirectory());
return $f->getIterator();
} catch (\Exception $e) {
return array();
}
}
}

View File

@@ -0,0 +1,150 @@
<?php
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\EasyExtendsBundle\Bundle;
use Symfony\Component\Finder\Finder;
class OrmMetadata
{
/**
* @var string
*/
protected $mappingEntityDirectory;
/**
* @var string
*/
protected $extendedMappingEntityDirectory;
/**
* @var string
*/
protected $entityDirectory;
/**
* @var string
*/
protected $extendedEntityDirectory;
/**
* @var string
*/
protected $extendedSerializerDirectory;
/**
* @param BundleMetadata $bundleMetadata
*/
public function __construct(BundleMetadata $bundleMetadata)
{
$this->mappingEntityDirectory = sprintf('%s/Resources/config/doctrine/', $bundleMetadata->getBundle()->getPath());
$this->extendedMappingEntityDirectory = sprintf('%s/Resources/config/doctrine/', $bundleMetadata->getExtendedDirectory());
$this->entityDirectory = sprintf('%s/Entity', $bundleMetadata->getBundle()->getPath());
$this->extendedEntityDirectory = sprintf('%s/Entity', $bundleMetadata->getExtendedDirectory());
$this->extendedSerializerDirectory = sprintf('%s/Resources/config/serializer', $bundleMetadata->getExtendedDirectory());
}
/**
* @return string
*/
public function getMappingEntityDirectory()
{
return $this->mappingEntityDirectory;
}
/**
* @return string
*/
public function getExtendedMappingEntityDirectory()
{
return $this->extendedMappingEntityDirectory;
}
/**
* @return string
*/
public function getEntityDirectory()
{
return $this->entityDirectory;
}
/**
* @return string
*/
public function getExtendedEntityDirectory()
{
return $this->extendedEntityDirectory;
}
/**
* @return string
*/
public function getExtendedSerializerDirectory()
{
return $this->extendedSerializerDirectory;
}
/**
* @return array|\Iterator
*/
public function getEntityMappingFiles()
{
try {
$f = new Finder();
$f->name('*.orm.xml.skeleton');
$f->name('*.orm.yml.skeleton');
$f->in($this->getMappingEntityDirectory());
return $f->getIterator();
} catch (\Exception $e) {
return array();
}
}
/**
* @return array
*/
public function getEntityNames()
{
$names = array();
try {
$f = new Finder();
$f->name('*.orm.xml.skeleton');
$f->name('*.orm.yml.skeleton');
$f->in($this->getMappingEntityDirectory());
foreach ($f->getIterator() as $file) {
$name = explode('.', basename($file));
$names[] = $name[0];
}
} catch (\Exception $e) {
}
return $names;
}
/**
* @return array|\Iterator
*/
public function getRepositoryFiles()
{
try {
$f = new Finder();
$f->name('*Repository.php');
$f->in($this->getEntityDirectory());
return $f->getIterator();
} catch (\Exception $e) {
return array();
}
}
}

View File

@@ -0,0 +1,148 @@
<?php
/*
* This file is part of the Sonata Project package.
*
* (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Sonata\EasyExtendsBundle\Bundle;
use Symfony\Component\Finder\Finder;
class PhpcrMetadata
{
/**
* @var string
*/
protected $mappingDocumentDirectory;
/**
* @var string
*/
protected $extendedMappingDocumentDirectory;
/**
* @var string
*/
protected $documentDirectory;
/**
* @var string
*/
protected $extendedDocumentDirectory;
/**
* @var string
*/
protected $extendedSerializerDirectory;
/**
* @param BundleMetadata $bundleMetadata
*/
public function __construct(BundleMetadata $bundleMetadata)
{
$this->mappingDocumentDirectory = sprintf('%s/Resources/config/doctrine/', $bundleMetadata->getBundle()->getPath());
$this->extendedMappingDocumentDirectory = sprintf('%s/Resources/config/doctrine/', $bundleMetadata->getExtendedDirectory());
$this->documentDirectory = sprintf('%s/PHPCR', $bundleMetadata->getBundle()->getPath());
$this->extendedDocumentDirectory = sprintf('%s/PHPCR', $bundleMetadata->getExtendedDirectory());
$this->extendedSerializerDirectory = sprintf('%s/Resources/config/serializer', $bundleMetadata->getExtendedDirectory());
}
/**
* @return string
*/
public function getMappingDocumentDirectory()
{
return $this->mappingDocumentDirectory;
}
/**
* @return string
*/
public function getExtendedMappingDocumentDirectory()
{
return $this->extendedMappingDocumentDirectory;
}
/**
* @return string
*/
public function getDocumentDirectory()
{
return $this->documentDirectory;
}
/**
* @return string
*/
public function getExtendedDocumentDirectory()
{
return $this->extendedDocumentDirectory;
}
/**
* @return string
*/
public function getExtendedSerializerDirectory()
{
return $this->extendedSerializerDirectory;
}
/**
* @return array|\Iterator
*/
public function getDocumentMappingFiles()
{
try {
$f = new Finder();
$f->name('*.phpcr.xml.skeleton');
$f->in($this->getMappingDocumentDirectory());
return $f->getIterator();
} catch (\Exception $e) {
return array();
}
}
/**
* @return array
*/
public function getDocumentNames()
{
$names = array();
try {
$f = new Finder();
$f->name('*.phpcr.xml.skeleton');
$f->in($this->getMappingDocumentDirectory());
foreach ($f->getIterator() as $file) {
$name = explode('.', basename($file));
$names[] = $name[0];
}
} catch (\Exception $e) {
}
return $names;
}
/**
* @return array|\Iterator
*/
public function getRepositoryFiles()
{
try {
$f = new Finder();
$f->name('*Repository.php');
$f->in($this->getDocumentDirectory());
return $f->getIterator();
} catch (\Exception $e) {
return array();
}
}
}