Coder Social home page Coder Social logo

doctrine-extensions's People

Contributors

bartekgruszka avatar beregond avatar chives avatar jarekw avatar norberttech avatar rn0 avatar szymach avatar wasper avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

doctrine-extensions's Issues

Uploadable with doctrine inheritance not working

example to reproduce:

/**
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 */
class Person
{
    // ...
}
/**
 * @Entity
 */
class Employee extends Person
{
    /**
     * @ORM\Column(type="string", length=255, nullable=true)
     * @FSi\Uploadable(targetField="file")
     */
    private $filePath;

    private $file;
}

Exception:

Mapping "Uploadable" in property "filePath" of class "Person" has 
"targetField" set to "file", which doesn't exist.

Common interface for files

It would be very helpful if all files from bundle extends from \SplFileInfo. If someone use this with symfony (doctrine-extensions-bundle) we could add return type hint in methods. Symfony already extends from it and \SplfileInfo doesnt need the file to exist:

SplFileInfo::__construct( string $file_name )
Creates a new SplFileInfo object for the file_name specified. The file does not need to exist, or be readable.

Get object identifier from metadata, not reflection

If we have private id property in base class like this:

/** @MappedSuperclass */
class Upper {
    /** @Id */
    private $id;
    public getId() {return this->id;}
}
/** @Entity */
class Lower extends Upper {
}

ReflectionException : Property Lower::$id does not exist

it should be changed here and probably in both cases (Proxy and object) this should work:

$em->getClassMetadata(get_class($object))->getIdentifierValues($object);

Error with translations using joined table inheritance

Case:

  1. Entity A has translations in Entity AT.
  2. Entity B extends A through joined inheritance and has translations in Entity BT.
  3. Translated fields for B are shared between AT and BT.
  4. Persisting and instance of B, which only has translated fields stored in the AT fails. That is because the empty fields stored in BT cause the whole translation to be removed and you cannot have an AT row without a corresponding BT one. Example below:
class A
{
   /**
    * @var string
    **/
   public $locale;

   /**
    * @var string|null
    **/
   public $fieldA;

   /**
    * @var AT[]
    **/
   public $aTranslations;
}

class B extends A 
{
   /**
    * @var string|null
    **/
   public $fieldB;

   /**
    * @var BT[]
    **/
   public $bTranslations;
}

class AT 
{
   /**
    * @var string
    **/
   public $locale;

   /**
    * @var string|null
    **/
   public $fieldA;

   /**
    * @var A
    **/
   public $translatedEntity;
}

class BT 
{
   /**
    * @var string
    **/
   public $locale;

   /**
    * @var string|null
    **/
   public $fieldB;

   /**
    * @var B
    **/
   public $translatedEntity;
}

$instanceOfB = new B();
$instanceOfB->locale = 'en';
$instanceOfB->fieldA = 'value';
// Since `fieldB` is null, the empty BT translation is going to be removed.
// This means AT is not created or removed.
$instanceOfB->fieldB = 'value';
// Only now both translations will be properly created, because the `fieldB` field is not `null`

Simplify library logic

Current implementation assumes possibility of multiple adapters (ORM/ODM etc.), which has never (and probably will never) be implemented.

Translation fails if relation is handled by the translation entity

Assuming you have an entity with a relation handled by it's translation, it will fail during save if the value for the field of that relation is null. Of course initially you need to pass an array or an ArrayCollection instance to the file in the constructor, which solves the problem during creation. The issue arises in a situation when:

  1. There are no objects in the said relation.
  2. The translated object is fetched via the entity manager (so the constructor is omitted).
  3. You edit the object through a form where the field for that relation does not exist.

This will result in a null value being copied to the translation class's field. To get around this, you need to add a lifecycle callback (like postLoad) to the translated entity, that will properly set the value.

This is not a huge issue and it does not require a hack to get around, but perhaps we could check for a null value and if the field to which it is copied is a relation, set an empty array instead?

Remove entity bug

When trying to remove entity that have filekey but file not longer exists (somebody remove it manualy) exception is throwed but entity is removed.
I think it would be enough to check if file exists before removing it.

Branches

JarekW created branch findby at fsi-open/doctrine-extensions 10 minutes ago

Any good reason for that? New branch means also new version at packagist.
@chives maybe some user permissions should be revoked only to read?

copying default object translation as an annotation option

... that is set per field

@Translatable\Translatable(mappedBy="translations", copyFromDefault=true)

This is useful when working with translatable collections. When collection is translatable you must have at least one element in collection to not show elements from default translation element. There's no way to have nothing in specific language when default translation have some elements.

i'm aware that this might introduce some complications with something that depend on default translations

Allow setting translations via a single method

Current implementation requires public access for modifying translated fields. This is troublesome in a situation, where you would like to only have read access to entity properties. We could add an option of setting the translation via a specified method, which would inject a populated translation object for the requested locale.

[Gedmo] Value from default language always used for slug creation

When you have a sluggable entity and create a new translation in a language different than the default one, it pretty much always creates the slug based on the value from the default translation. This creates a duplicate slug in a wrong language, with added suffix (like -1). If you change the slug-related field afterwards, it will regenerate the slug in the proper locale.

Generate new key

There is something wrong with "generateNewKey" method in UploadableListener

PHP Notice:  Undefined offset: 3 in
/www/fsi-open-demo/vendor/fsi/doctrine-extensions/lib/FSi/DoctrineExtensions/Uploadable/UploadableListener.php
on line 566

I'm getting this errer very often.

Get and set files property through reflection

If class has file field but doesn't has setter for it, for example file is set in constructor, then NoSuchPropertyException is thrown down here

It should be done as doctrine do this - through reflection.

revert #8

Moreover getters should also change. Current implementation with PropertyAccessor block developers from using php7 return types declaration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.