4 code examples of PHP Oro\Component\PhpUtils\ClassGenerator extracted from open source projects
public function generate(array $schema, ClassGenerator $class): void
{
if (!$this->supports($schema)) {
return;
}
$fields = $this->storage->getFieldMap()[$schema['class']];
if (empty($fields)) {
return;
}
$class->setExtends(ExtendFallback::class);
foreach ($fields as $singularName => $fieldName) {
$this->generateGetter($singularName, $fieldName, $class);
$this->generateDefaultGetter($singularName, $fieldName, $class);
$this->generateDefaultSetter($singularName, $fieldName, $class);
}
$this->generateCloneLocalizedFallbackValueAssociationsMethod($fields, $class);
}
public function generate(array $schema, ClassGenerator $class): void
{
if (!empty($schema['inherit'])) {
$class->addExtend($schema['inherit']);
} elseif ('Custom' === $schema['type']) {
// generate 'id' property and '__toString' method only for Custom entity without inheritance
$class->addProperty('id')->setProtected();
$class->addMethod('getId')->addBody('return $this->id;');
$this->generateToStringMethod($schema, $class);
}
$this->generateConstructor($schema, $class);
$class->addImplement(ExtendEntityInterface::class);
$this->generateProperties('property', $schema, $class);
$this->generateProperties('relation', $schema, $class);
$this->generateProperties('default', $schema, $class);
$this->generateCollectionMethods($schema, $class);
}
public function generate(array $schema, ClassGenerator $class): void
{
$class->addImplement(ActivityInterface::class);
parent::generate($schema, $class);
}
public function generate(array $schema, ClassGenerator $class): void
{
if (!$class->hasProperty(self::SERIALIZED_DATA_FIELD)) {
return;
}
if ($class->hasMethod('getSerializedData')) {
$class->getMethod('getSerializedData')->addComment('@internal');
$class->getMethod('setSerializedData')->addComment('@internal');
}
$class->addTrait(SerializedFieldsTrait::class);
if (!empty($schema['serialized_property']) && $this->isDebug) {
foreach (array_keys($schema['serialized_property']) as $fieldName) {
$class->addComment(sprintf('@property $%s', $fieldName));
}
}
}