fsi-open / doctrine-extensions Goto Github PK
View Code? Open in Web Editor NEWDoctrine2 Extensions
License: MIT License
Doctrine2 Extensions
License: MIT License
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.
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.
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?
Conitnuation of #61
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);
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.
Since they are fairly simple and only used in this package, it would be best to simply extract the used functionality and deprecate the standalone packages.
Case:
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`
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:
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?
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.
Current implementation assumes possibility of multiple adapters (ORM/ODM etc.), which has never (and probably will never) be implemented.
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.
... 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
Missing cases:
mappedBy
, field
, targetEntity
with empty values.doctrine/doctrine2
since 2.5
dispatches postLoad
event after all associations are initialized so the custom hydrator is not needed anymore
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.
It removes the file, but the entity's field is still set to the old value.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.