Actualización

This commit is contained in:
xesmyd committed 2025-04-10 12:24:57 +02:00
1 parent 8969cc929d
commit 45420b6f0d
39760 files changed
+4303286

No files matched your search

@@ -0,0 +1,57 @@
<?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\CoreBundle\Model\Adapter;
class AdapterChain implements AdapterInterface
{
protected $adapters = array();
/**
* @param AdapterInterface $adapter
*/
public function addAdapter(AdapterInterface $adapter)
{
$this->adapters[] = $adapter;
}
/**
* {@inheritdoc}
*/
public function getNormalizedIdentifier($model)
{
foreach ($this->adapters as $adapter) {
$identifier = $adapter->getNormalizedIdentifier($model);
if ($identifier) {
return $identifier;
}
}
return;
}
/**
* {@inheritdoc}
*/
public function getUrlsafeIdentifier($model)
{
foreach ($this->adapters as $adapter) {
$safeIdentifier = $adapter->getUrlsafeIdentifier($model);
if ($safeIdentifier) {
return $safeIdentifier;
}
}
return;
}
}
@@ -0,0 +1,38 @@
<?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\CoreBundle\Model\Adapter;
interface AdapterInterface
{
const ID_SEPARATOR = '~';
/**
* Get the identifiers for this model class as a string.
*
* @param object $model
*
* @return string a string representation of the identifiers for this instance
*/
public function getNormalizedIdentifier($model);
/**
* Get the identifiers as a string that is save to use in an url.
*
* This is similar to getNormalizedIdentifier but guarantees an id that can
* be used in an URL.
*
* @param object $model
*
* @return string string representation of the id that is save to use in an url
*/
public function getUrlsafeIdentifier($model);
}
@@ -0,0 +1,71 @@
<?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\CoreBundle\Model\Adapter;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ORM\EntityManagerInterface;
/**
* This is a port of the DoctrineORMAdminBundle / ModelManager class.
*/
class DoctrineORMAdapter implements AdapterInterface
{
/**
* @var ManagerRegistry
*/
protected $registry;
/**
* @param ManagerRegistry $registry
*/
public function __construct(ManagerRegistry $registry)
{
$this->registry = $registry;
}
/**
* {@inheritdoc}
*/
public function getNormalizedIdentifier($entity)
{
if (is_scalar($entity)) {
throw new \RunTimeException('Invalid argument, object or null required');
}
if (!$entity) {
return;
}
$manager = $this->registry->getManagerForClass(get_class($entity));
if (!$manager instanceof EntityManagerInterface) {
return;
}
if (!$manager->getUnitOfWork()->isInIdentityMap($entity)) {
return;
}
return implode(self::ID_SEPARATOR, $manager->getUnitOfWork()->getEntityIdentifier($entity));
}
/**
* {@inheritdoc}
*
* The ORM implementation does nothing special but you still should use
* this method when using the id in a URL to allow for future improvements.
*/
public function getUrlsafeIdentifier($entity)
{
return $this->getNormalizedIdentifier($entity);
}
}
@@ -0,0 +1,80 @@
<?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\CoreBundle\Model\Adapter;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\ODM\PHPCR\DocumentManager;
/**
* This is a port of the DoctrineORMAdminBundle / ModelManager class.
*/
class DoctrinePHPCRAdapter implements AdapterInterface
{
/**
* @var ManagerRegistry
*/
protected $registry;
/**
* @param ManagerRegistry $registry
*/
public function __construct(ManagerRegistry $registry)
{
$this->registry = $registry;
}
/**
* {@inheritdoc}
*/
public function getNormalizedIdentifier($document)
{
if (is_scalar($document)) {
throw new \RunTimeException('Invalid argument, object or null required');
}
if (!$document) {
return;
}
$manager = $this->registry->getManagerForClass($document);
if (!$manager instanceof DocumentManager) {
return;
}
if (!$manager->contains($document)) {
return;
}
$class = $manager->getClassMetadata(get_class($document));
return $class->getIdentifierValue($document);
}
/**
* Currently only the leading slash is removed.
*
* TODO: do we also have to encode certain characters like spaces or does that happen automatically?
*
* {@inheritdoc}
*/
public function getUrlsafeIdentifier($document)
{
$id = $this->getNormalizedIdentifier($document);
if (null !== $id) {
return substr($id, 1);
}
return;
}
}
@@ -0,0 +1,52 @@
<?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\CoreBundle\Model;
use Doctrine\ODM\MongoDB\DocumentManager;
/**
* @author Hugo Briand <briand@ekino.com>
*/
abstract class BaseDocumentManager extends BaseManager
{
/**
* Make sure the code is compatible with legacy code.
*
* @param $name
*
* @return mixed
*/
public function __get($name)
{
if ($name === 'dm') {
return $this->getObjectManager();
}
throw new \RuntimeException(sprintf('The property %s does not exists', $name));
}
/**
* {@inheritdoc}
*/
public function getConnection()
{
return $this->getObjectManager()->getConnection();
}
/**
* @return DocumentManager
*/
public function getDocumentManager()
{
return $this->getObjectManager();
}
}
@@ -0,0 +1,52 @@
<?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\CoreBundle\Model;
use Doctrine\ORM\EntityManager;
/**
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
*/
abstract class BaseEntityManager extends BaseManager
{
/**
* Make sure the code is compatible with legacy code.
*
* @param $name
*
* @return mixed
*/
public function __get($name)
{
if ($name === 'em') {
return $this->getObjectManager();
}
throw new \RuntimeException(sprintf('The property %s does not exists', $name));
}
/**
* {@inheritdoc}
*/
public function getConnection()
{
return $this->getEntityManager()->getConnection();
}
/**
* @return EntityManager
*/
public function getEntityManager()
{
return $this->getObjectManager();
}
}
+171
View File
@@ -0,0 +1,171 @@
<?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\CoreBundle\Model;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Common\Persistence\ObjectRepository;
/**
* @author Hugo Briand <briand@ekino.com>
*/
abstract class BaseManager implements ManagerInterface
{
/**
* @var ManagerRegistry
*/
protected $registry;
/**
* @var string
*/
protected $class;
/**
* @param string $class
* @param ManagerRegistry $registry
*/
public function __construct($class, ManagerRegistry $registry)
{
$this->registry = $registry;
$this->class = $class;
}
/**
* @return ObjectManager
*/
public function getObjectManager()
{
$manager = $this->registry->getManagerForClass($this->class);
if (!$manager) {
throw new \RuntimeException(sprintf(
'Unable to find the mapping information for the class %s.'
.' Please check the `auto_mapping` option'
.' (http://symfony.com/doc/current/reference/configuration/doctrine.html#configuration-overview)'
.' or add the bundle to the `mappings` section in the doctrine configuration.',
$this->class
));
}
return $manager;
}
/**
* {@inheritdoc}
*/
public function getClass()
{
return $this->class;
}
/**
* {@inheritdoc}
*/
public function findAll()
{
return $this->getRepository()->findAll();
}
/**
* {@inheritdoc}
*/
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
{
return $this->getRepository()->findBy($criteria, $orderBy, $limit, $offset);
}
/**
* {@inheritdoc}
*/
public function findOneBy(array $criteria, array $orderBy = null)
{
return $this->getRepository()->findOneBy($criteria, $orderBy);
}
/**
* {@inheritdoc}
*/
public function find($id)
{
return $this->getRepository()->find($id);
}
/**
* {@inheritdoc}
*/
public function create()
{
return new $this->class();
}
/**
* {@inheritdoc}
*/
public function save($entity, $andFlush = true)
{
$this->checkObject($entity);
$this->getObjectManager()->persist($entity);
if ($andFlush) {
$this->getObjectManager()->flush();
}
}
/**
* {@inheritdoc}
*/
public function delete($entity, $andFlush = true)
{
$this->checkObject($entity);
$this->getObjectManager()->remove($entity);
if ($andFlush) {
$this->getObjectManager()->flush();
}
}
/**
* {@inheritdoc}
*/
public function getTableName()
{
return $this->getObjectManager()->getClassMetadata($this->class)->table['name'];
}
/**
* Returns the related Object Repository.
*
* @return ObjectRepository
*/
protected function getRepository()
{
return $this->getObjectManager()->getRepository($this->class);
}
/**
* @param $object
*
* @throws \InvalidArgumentException
*/
protected function checkObject($object)
{
if (!$object instanceof $this->class) {
throw new \InvalidArgumentException(sprintf(
'Object must be instance of %s, %s given',
$this->class, is_object($object) ? get_class($object) : gettype($object)
));
}
}
}
@@ -0,0 +1,61 @@
<?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\CoreBundle\Model;
use Doctrine\Common\Persistence\ObjectManager;
abstract class BasePHPCRManager extends BaseManager
{
/**
* Make sure the code is compatible with legacy code.
*
* @param $name
*
* @return mixed
*/
public function __get($name)
{
if ($name === 'dm') {
return $this->getObjectManager();
}
throw new \RuntimeException(sprintf('The property %s does not exists', $name));
}
/**
* {@inheritdoc}
*
* @throws \LogicException Each call
*/
public function getConnection()
{
throw new \LogicException('PHPCR does not use a database connection.');
}
/**
* {@inheritdoc}
*
* @throws \LogicException Each call
*/
public function getTableName()
{
throw new \LogicException('PHPCR does not use a reference name for a list of data.');
}
/**
* @return ObjectManager
*/
public function getDocumentManager()
{
return $this->getObjectManager();
}
}
@@ -0,0 +1,102 @@
<?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\CoreBundle\Model;
use Doctrine\DBAL\Connection;
/**
* @author Sylvain Deloux <sylvain.deloux@ekino.com>
*/
interface ManagerInterface
{
/**
* Return the Entity class name.
*
* @return string
*/
public function getClass();
/**
* Find all entities in the repository.
*
* @return array
*/
public function findAll();
/**
* Find entities by a set of criteria.
*
* @param array $criteria
* @param array|null $orderBy
* @param int|null $limit
* @param int|null $offset
*
* @return array
*/
public function findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null);
/**
* Find a single entity by a set of criteria.
*
* @param array $criteria
* @param array|null $orderBy
*
* @return object|null
*/
public function findOneBy(array $criteria, array $orderBy = null);
/**
* Finds an entity by its primary key / identifier.
*
* @param mixed $id The identifier
*
* @return object
*/
public function find($id);
/**
* Create an empty Entity instance.
*
* @return object
*/
public function create();
/**
* Save an Entity.
*
* @param object $entity The Entity to save
* @param bool $andFlush Flush the EntityManager after saving the object?
*/
public function save($entity, $andFlush = true);
/**
* Delete an Entity.
*
* @param object $entity The Entity to delete
* @param bool $andFlush Flush the EntityManager after deleting the object?
*/
public function delete($entity, $andFlush = true);
/**
* Get the related table name.
*
* @return string
*/
public function getTableName();
/**
* Get the DB driver connection.
*
* @return Connection
*/
public function getConnection();
}
+131
View File
@@ -0,0 +1,131 @@
<?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\CoreBundle\Model;
/**
* @author Hugo Briand <briand@ekino.com>
*/
class Metadata implements MetadataInterface
{
/**
* @var string
*/
protected $title;
/**
* @var string
*/
protected $description;
/**
* @var mixed
*/
protected $image;
/**
* @var string
*/
protected $domain;
/**
* @var array
*/
protected $options;
/**
* @param string $title
* @param string $description
* @param mixed $image
* @param string $domain
* @param array $options
*/
public function __construct($title, $description = null, $image = null, $domain = null, array $options = array())
{
$this->title = $title;
$this->description = $description;
$this->image = $image !== null ? $image : 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOcAAADnCAYAAADl9EEgAAAXfWlDQ1BJQ0MgUHJvZmlsZQAAWAmtWWVYVU3Xnn0KOBy6u7u7u7sbgUN3NyopUkoISIoggqCCQYmIiCCCiKACBiAhkiqooAjIu0F93ufH9/779nWdvW/W3GvNmlkzs/daAMDQgg8NDUSQAxAUHBluqafJbu/gyE7wFhACKkAHhAEG7xERqmFubgz+57U9Aa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i+BRCFXULPoBcwGIZJIFutLXIGbJRUkiyF/RMlAFUf9klaSLoV+mlGGKZ15lJWRzZ49n6OLc4pri3ubZ5X3Kd8l/nABVUFCwZdCVcL+IjIiv0QfiZ0Vt5Ngk1iSbJKKllaRgWT6ZbPkzOSp5CcUShWdlFiUpuBV4KzKoDqpdl7dSYNXY1dzXOumdo6Ol66yHoXeB/0ugyLDaCMvY3cTX9MQsyBzdwszSyUrQWsmG1JbhO223ZL9hMNDxyancuesY/Eufq72btp4MXd6D8hj1XPcq8+71afOt9gvzT8kwCFQPYgvmAReCXOhM2HfIjgiXaNKox/EvIpdiFuP3zlOfIL1JH8iexIm6V1ya0puaniayymbdPvTfhmpmZVZ17 Line truncated
$this->domain = $domain;
$this->options = $options;
}
/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* @return mixed
*/
public function getImage()
{
return $this->image;
}
/**
* @return string
*/
public function getDomain()
{
return $this->domain;
}
/**
* @return array
*/
public function getOptions()
{
return $this->options;
}
/**
* @param string $name The option key
* @param mixed $default The default value if option not found
*
* @return mixed
*/
public function getOption($name, $default = null)
{
return array_key_exists($name, $this->options) ? $this->options[$name] : $default;
}
/**
* Sets an option.
*
* @param $name
* @param $option
*/
public function setOption($name, $option)
{
$this->options[$name] = $option;
}
/**
* Sets all options.
*
* @param array $options
*/
public function setOptions(array $options)
{
$this->options = $options;
}
}
@@ -0,0 +1,51 @@
<?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\CoreBundle\Model;
/**
* @author Hugo Briand <briand@ekino.com>
*/
interface MetadataInterface
{
/**
* @return string
*/
public function getTitle();
/**
* @return string
*/
public function getDescription();
/**
* @return mixed
*/
public function getImage();
/**
* @return string
*/
public function getDomain();
/**
* @return array
*/
public function getOptions();
/**
* @param string $name The option key
* @param mixed $default The default value if option not found
*
* @return mixed
*/
public function getOption($name, $default = null);
}
@@ -0,0 +1,30 @@
<?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\CoreBundle\Model;
use Sonata\DatagridBundle\Pager\PagerInterface;
/**
* @author Raphaël Benitte <benitteraphael@gmail.com>
*/
interface PageableManagerInterface
{
/**
* @param array $criteria
* @param int $page
* @param int $limit
* @param array $sort
*
* @return PagerInterface
*/
public function getPager(array $criteria, $page, $limit = 10, array $sort = array());
}