@param \Protobuf\Compiler\Entity $entity

@return string
184787
protected function generateRegisterAllExtensionsMethod(Entity $entity)
    {
        $lines      = [];
        $fields     = [];
        $descriptor = $entity->getDescriptor();
        $extensions = $descriptor->getExtensionList() ?: [];
        $messages   = $descriptor->getMessageTypeList() ?: [];

        foreach ($messages as $message) {

            if ( ! $message->hasExtensionList()) {
                continue;
            }

            foreach ($message->getExtensionList() as $extension) {
                $fields[] = $extension;
            }
        }

        foreach ($fields as $field) {
            $type  = $field->getTypeName();
            $name  = $this->getCamelizedName($field);

            $ref     = $this->getEntity($type);
            $class   = $ref->getNamespacedName();
            $lines[] = '$registry->add(' . $class . '::' . $name. '());';
        }

        foreach ($extensions as $field) {
            $type  = $field->getTypeName();
            $name  = $this->getCamelizedName($field);

            $lines[] = '$registry->add(self::' . $name . '());';
        }

        $body       = implode(PHP_EOL, $lines);
        $method     = MethodGenerator::fromArray([
            'static'     => true,
            'body'       => $body,
            'name'       => 'registerAllExtensions',
            'parameters' => [
                [
                    'name' => 'registry',
                    'type' => '\Protobuf\Extension\ExtensionRegistry'
                ]
            ],
            'docblock'   => [
                'shortDescription' => "Register all extensions",
                'tags'             => [
                    [
                        'name'        => 'param',
                        'description' => '\Protobuf\Extension\ExtensionRegistry',
                    ]
                ]
            ]
        ]);

        return $method;
    }
624257
protected function resolveMigrationTableName(Model $entity): string
    {
        if (! \is_null($table = $this->getConfig('migration'))) {
            return $this->bindWithKey($entity, $table);
        }

        if ($this->getConfig('shared', true) === true) {
            return $this->bindWithKey($entity, $this->getTablePrefix().'_migrations');
        }

        return 'tenant_migrations';
    }
1035468
protected function generateBody(Entity $entity)
    {
        $lines      = [];
        $fields     = [];
        $extensions = [];
        $descriptor = $entity->getDescriptor();

        if ($descriptor->hasOptions()) {
            $lines   = $this->createOptionsBody($entity);
            $lines[] = null;
        }

        foreach (($descriptor->getFieldList() ?: []) as $field) {
            $values = $this->generateFieldBody($field);
            $fields = array_merge($fields, $this->addIndentation($values, 2));
        }

        foreach (($descriptor->getExtensionList() ?: []) as $field) {
            $values     = $this->generateFieldBody($field);
            $extensions = array_merge($extensions, $this->addIndentation($values, 2));
        }

        $lines[] = "return \google\protobuf\DescriptorProto::fromArray([";
        $lines[] = "    'name'      => " . var_export($descriptor->getName(), true) . ",";

        if ( ! empty($fields)) {
            $lines[] = "    'field'     => [";
            $lines   = array_merge($lines, $fields);
            $lines[] = "    ],";
        }

        if ( ! empty($extensions)) {
            $lines[] = "    'extension' => [";
            $lines   = array_merge($lines, $extensions);
            $lines[] = "    ],";
        }

        if ($descriptor->hasOptions()) {
            $lines[] = "    'options' => \$options";
        }

        $lines[] = "]);";

        return $lines;
    }
166593
protected function HLGetIdByCode($entity)
    {
        $filter = [
            'filter' => ['=NAME' => $entity],
        ];
        $hlblock = HighloadBlockTable::getRow($filter);

        return !empty($hlblock['ID']) ? $hlblock['ID'] : null;
    }
251935
public function dcDateIssued($entity)
    {
        if (!$entity->displayMetaDates) {
            return '';
        }
        $published = ($entity->published !== null) ? $entity->published->format('c') : null;
        return $this->_render(self::ATTR_PROP, 'DC.date.issued', $published);
    }
253109
public function generateBody(Entity $entity)
    {
        $innerLoop = $this->addIndentation($this->generateInnerLoop($entity), 1);

        $body[] = '$reader = $context->getReader();';
        $body[] = '$length = $context->getLength();';
        $body[] = '$stream = $context->getStream();';
        $body[] = null;
        $body[] = '$limit = ($length !== null)';
        $body[] = '    ? ($stream->tell() + $length)';
        $body[] = '    : null;';
        $body[] = null;
        $body[] = 'while ($limit === null || $stream->tell() < $limit) {';

        $body = array_merge($body, $innerLoop);

        $body[] = null;
        $body[] = '}';

        return $body;
    }
1320226
protected function generateBody(Entity $entity)
    {
        $descriptor = $entity->getDescriptor();
        $fields     = $descriptor->getFieldList() ?: [];

        $body[] = '$stream      = $context->getStream();';
        $body[] = '$writer      = $context->getWriter();';
        $body[] = '$sizeContext = $context->getComputeSizeContext();';
        $body[] = null;

        foreach ($fields as $field) {
            $lines = $this->generateRequiredFieldException($entity, $field);
            $body  = array_merge($body, $lines);
        }

        foreach ($fields as $field) {
            $lines = $this->generateFieldCondition($entity, $field);
            $body  = array_merge($body, $lines, [null]);
        }

        $extensionsField = $this->getUniqueFieldName($descriptor, 'extensions');
        $extensionsVar   = '$this->' . $extensionsField;

        $body[] = 'if (' . $extensionsVar . ' !== null) {';
        $body[] = '    ' . $extensionsVar . '->writeTo($context);';
        $body[] = '}';
        $body[] = null;
        $body[] = 'return $stream;';

        return $body;
    }
92069
private static function makeObject($entity)
    {
        $methodsGet = get_class_methods($entity);
        $methodsGet = array_filter($methodsGet, function($value) {
            return (bool) preg_match('/^get.*$/', $value);
        });
        $std = new \stdClass();
        foreach ($methodsGet as $attribute) {
            $name = str_replace('get', '', $attribute);
            $name = lcfirst($name);
            $std->$name = $entity->$attribute();
        }
        return $std;
    }
642349
protected function getEntityTable($entity)
    {
        if (!$entity instanceof EntityInterface) {
            $entity = $this->getEntityClass($entity);
        }
        return $this->tablePrefix . $entity::getTable() . $this->tableSuffix;
    }
137459
private function getEntityIdentifierValue($entity)
    {
        $entityMetaData = $this->entityManager->getEntityMetadataRegister()->getEntityMetadata($entity);

        return $entityMetaData ? $entityMetaData->getIdentifierValue() : null;
    }
142471
protected function buildEntityCreatePayload(EntityInterface $entity, array $context = []): string
    {
        return $this->getEntitySerializer()->serialize($entity, 'json', $context);
    }
738253
public function beforeSave(Event $event, Entity $entity) {
		if (isset($entity['ext'])) {
			$entity['ext'] = mb_strtolower($entity['ext']);
		}
		if (isset($entity['name'])) {
			$entity['name'] = ucwords($entity['name']);
		}
	}
1238527
protected function generateMethods(Entity $entity)
    {
        $descriptor = $entity->getDescriptor();
        $extensions = $descriptor->getExtensionList() ?: [];
        $methods    = [$this->generateRegisterAllExtensionsMethod($entity)];

        foreach ($extensions as $field) {
            $methods[] = $this->generateExtensionMethod($entity, $field);
        }

        return $methods;
    }
138561
public function getModelName($entity) {
        $classRef = new \ReflectionClass($entity);
        $classModelAnnotation = $this->annoReader->getClassAnnotation($classRef, 'Tpg\ExtjsBundle\Annotation\Model');
        if ($classModelAnnotation !== null) {
            if ($classModelAnnotation->name) {
                return $classModelAnnotation->name;
            } else {
                return str_replace("\\", ".", $classRef->getName());
            }
        }
        return null;
    }
344826
public function defaultRender($entity)
    {
        $value = htmlspecialchars($this->getPropertyValue($entity));

        if ($this->truncate === false) {
            $truncatedValue = $value;
        } else {
            $truncatedValue = substr($value, 0, intval($this->truncate));
            if (strlen($truncatedValue) < strlen($value)) {
                $truncatedValue .= '...';
            }
        }

        return '<a title="' . $value . '" href="' . $value . '" target="' . $this->target . '">' . $truncatedValue . '</a>';
    }
311268
private function getUserInputEntity($entity)
    {
        // Get rid of any special chars introduced.
        $entity = $this->makeSQLUnsafe($entity);

        // Only replace first occurrence.
        return preg_replace('/' . $this->getParams()['DBPREFIX'] . '/', '', $entity, 1);
    }
1040599
private function getEntityEncryptionIv($entity)
    {
        $iv = $entity->getIv();

        if (!$iv) {
            $iv = $this->cryptographyProvider->generateIV(CryptographyProviderInterface::PROPERTY_ENCRYPTION);
            $entity->setIv($iv);
        }

        return $iv;
    }