Skip to content

Commit

Permalink
remove support for deprecated notify change tracking policy
Browse files Browse the repository at this point in the history
  • Loading branch information
Guite committed Jan 16, 2024
1 parent cf04699 commit a60c461
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,6 @@ class Entities {
imports.add('Doctrine\\Common\\Collections\\Collection')
}
}
if (isBase && hasNotifyPolicy) {
imports.add('Doctrine\\Common\\NotifyPropertyChanged')
imports.add('Doctrine\\Common\\PropertyChangedListener')
}
if (isBase || loggable || hasTranslatableFields || tree != EntityTreeType.NONE) {
imports.add('Gedmo\\Mapping\\Annotation as Gedmo')
}
Expand Down Expand Up @@ -236,7 +232,7 @@ class Entities {
* inherit orm properties.
*/
#[ORM\MappedSuperclass]
abstract class Abstract«name.formatForCodeCapital»«IF isInheriting» extends BaseEntity«ENDIF» implements AbstractEntityInterface«IF it instanceof Entity»«IF it.hasNotifyPolicy», NotifyPropertyChanged«ENDIF»«IF it.hasTranslatableFields», Translatable«ENDIF»«ENDIF»
abstract class Abstract«name.formatForCodeCapital»«IF isInheriting» extends BaseEntity«ENDIF» implements AbstractEntityInterface«IF it instanceof Entity»«IF it.hasTranslatableFields», Translatable«ENDIF»«ENDIF»
{
«modelEntityBaseImplBody(app)»
}
Expand All @@ -255,13 +251,6 @@ class Entities {
* The tablename this object maps to
*/
protected string $_objectType = '«name.formatForCode»';
«IF it instanceof Entity && (it as Entity).hasNotifyPolicy»

/**
* List of change notification listeners
*/
protected array $_propertyChangedListeners = [];
«ENDIF»
«IF hasUploadFieldsEntity»

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ class EntityMethods {
'''

def dispatch generate(Entity it, Application app, Property thProp) '''
«propertyChangedListener»
«validationMethods»

«createUrlArgs»
Expand All @@ -56,34 +55,6 @@ class EntityMethods {
«ENDIF»
'''

def private propertyChangedListener(Entity it) '''
«IF hasNotifyPolicy»
/**
* Adds a property change listener.
*/
public function addPropertyChangedListener(PropertyChangedListener $listener): void
{
$this->_propertyChangedListeners[] = $listener;
}

/**
* Notify all registered listeners about a changed property.
*
* @param mixed $oldValue The old property value
* @param mixed $newValue The new property value
*/
protected function _onPropertyChanged(string $propName, $oldValue, $newValue): void
{
if ($this->_propertyChangedListeners) {
foreach ($this->_propertyChangedListeners as $listener) {
$listener->propertyChanged($this, $propName, $oldValue, $newValue);
}
}
}

«ENDIF»
'''
def private createUrlArgs(Entity it) '''
/**
* Creates url arguments array for easy creation of display urls.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,17 @@ import de.guite.modulestudio.metamodel.ArrayField
import de.guite.modulestudio.metamodel.BooleanField
import de.guite.modulestudio.metamodel.DatetimeField
import de.guite.modulestudio.metamodel.DerivedField
import de.guite.modulestudio.metamodel.Entity
import de.guite.modulestudio.metamodel.IntegerField
import de.guite.modulestudio.metamodel.NumberField
import de.guite.modulestudio.metamodel.NumberFieldType
import de.guite.modulestudio.metamodel.UserField
import org.zikula.modulestudio.generator.extensions.FormattingExtensions
import org.zikula.modulestudio.generator.extensions.ModelExtensions
import org.zikula.modulestudio.generator.extensions.ModelInheritanceExtensions
import org.zikula.modulestudio.generator.extensions.ModelJoinExtensions
import org.zikula.modulestudio.generator.extensions.Utils

class FileHelper {

extension FormattingExtensions = new FormattingExtensions
extension ModelExtensions = new ModelExtensions
extension ModelInheritanceExtensions = new ModelInheritanceExtensions
extension ModelJoinExtensions = new ModelJoinExtensions
extension Utils = new Utils

Expand Down Expand Up @@ -88,18 +83,11 @@ class FileHelper {
}
'''

def triggerPropertyChangeListeners(DerivedField it, String name) '''
«IF null !== entity && ((entity instanceof Entity && (entity as Entity).hasNotifyPolicy) || entity.getInheritingEntities.exists[hasNotifyPolicy])»
$this->_onPropertyChanged('«name.formatForCode»', $this->«name.formatForCode», $«name»);
«ENDIF»
'''

def private dispatch setterMethodImpl(DerivedField it, String name, String type, Boolean nullable) '''
«IF it instanceof NumberField»
$«name» = «IF it.numberType == NumberFieldType::DECIMAL»(string) «ENDIF»round((float) $«name», «scale»);
«ENDIF»
if ($this->«name.formatForCode» !== $«name») {
«triggerPropertyChangeListeners(name)»
«setterAssignment(name)»
}
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import de.guite.modulestudio.metamodel.DerivedField
import de.guite.modulestudio.metamodel.EmailField
import de.guite.modulestudio.metamodel.EmailValidationMode
import de.guite.modulestudio.metamodel.Entity
import de.guite.modulestudio.metamodel.EntityChangeTrackingPolicy
import de.guite.modulestudio.metamodel.EntityIdentifierStrategy
import de.guite.modulestudio.metamodel.EntityIndexType
import de.guite.modulestudio.metamodel.EntityLockType
Expand All @@ -28,11 +27,11 @@ import de.guite.modulestudio.metamodel.OneToOneRelationship
import de.guite.modulestudio.metamodel.StringField
import de.guite.modulestudio.metamodel.StringRole
import de.guite.modulestudio.metamodel.TextField
import de.guite.modulestudio.metamodel.TextRole
import de.guite.modulestudio.metamodel.UploadField
import de.guite.modulestudio.metamodel.UploadNamingScheme
import de.guite.modulestudio.metamodel.UrlField
import de.guite.modulestudio.metamodel.UserField
import de.guite.modulestudio.metamodel.TextRole

/**
* This class contains model related extension methods.
Expand Down Expand Up @@ -641,13 +640,6 @@ class ModelExtensions {
}
}

/**
* Checks whether this entity has enabled the notify tracking policy.
*/
def hasNotifyPolicy(Entity it) {
changeTrackingPolicy == EntityChangeTrackingPolicy.NOTIFY
}

/**
* Checks whether this entity has enabled optimistic locking.
*/
Expand Down

0 comments on commit a60c461

Please sign in to comment.